Ticket #6796: unsupported-vcs-hg-r7031.diff
| File unsupported-vcs-hg-r7031.diff, 2.1 KB (added by cboos, 4 years ago) |
|---|
-
tracext/hg/backend.py
27 27 NoSuchChangeset, NoSuchNode 28 28 from trac.wiki import IWikiSyntaxProvider 29 29 30 hg_import_error = [] 30 31 try: 31 32 # The new `demandimport` mechanism doesn't play well with code relying 32 33 # on the `ImportError` exception being caught. … … 39 40 try: 40 41 from mercurial import demandimport 41 42 demandimport.enable(); 42 except ImportError :43 except ImportError, hg_import_error: 43 44 demandimport = None 44 45 45 46 from mercurial import hg 47 from mercurial.hg import repository 46 48 from mercurial.ui import ui 47 49 from mercurial.repo import RepoError 48 50 from mercurial.revlog import LookupError … … 50 52 from mercurial.util import pathto, cachefunc 51 53 from mercurial.cmdutil import walkchangerevs 52 54 from mercurial import extensions 55 from mercurial.extensions import loadall 53 56 57 # Note: due to the nature of demandimport, there will be no actual 58 # import error until those symbols get accessed, so here we go: 59 for sym in ("repository ui RepoError LookupError hex short nullid pathto " 60 "cachefunc walkchangerevs loadall".split()): 61 if repr(globals()[sym]) == "<unloaded module '%s'>" % sym: 62 hg_import_error.append(sym) 63 if hg_import_error: 64 hg_import_error = "Couldn't import symbols: "+','.join(hg_import_error) 65 54 66 if demandimport: 55 67 demandimport.disable(); 56 68 57 has_mercurial = True 58 except ImportError: 59 has_mercurial = False 69 except ImportError, e: 70 hg_import_error = e 60 71 ui = object 61 72 62 73 try: … … 123 134 124 135 def get_supported_types(self): 125 136 """Support for `repository_type = hg`""" 126 global has_mercurial 127 if has_mercurial: 137 global hg_import_error 138 if hg_import_error: 139 self.error = hg_import_error 140 yield ("hg", -1) 141 else: 128 142 yield ("hg", 8) 129 143 130 144 def get_repository(self, type, dir, authname):
