# HG changeset patch # User Kevin Bullock # Date 1514134104 18000 # Node ID c06d4656b77b9ea0edced971dc9de439fc94acec # Parent 3b20ecf51ed58e66493410677445543d231947f9 shared: fix compatibility with hg < 4.2 diff -r 3b20ecf51ed5 -r c06d4656b77b hggit/__init__.py --- a/hggit/__init__.py Mon Nov 27 22:03:18 2017 -0600 +++ b/hggit/__init__.py Sun Dec 24 11:48:24 2017 -0500 @@ -49,7 +49,6 @@ revset, scmutil, templatekw, - vfs as vfsmod, ) try: @@ -74,7 +73,6 @@ # baseset was added in hg 3.0 pass - demandimport.ignore.extend([ 'collections', ]) @@ -215,21 +213,13 @@ lambda *args: open(os.path.join(helpdir, 'git.rst')).read()) insort(help.helptable, entry) -def _gitvfs(repo): - """return a vfs suitable to read git related data""" - # Mercurial >= 3.3: repo.shared() - if repo.sharedpath != repo.path: - return vfsmod.vfs(repo.sharedpath) - else: - return repo.vfs - def reposetup(ui, repo): if not isinstance(repo, gitrepo.gitrepo): if (getattr(dirstate, 'rootcache', False) and (not ignoremod or getattr(ignore, 'readpats', False)) and hgutil.safehasattr(repo, 'vfs') and - os.path.exists(_gitvfs(repo).join('git'))): + os.path.exists(compat.gitvfs(repo).join('git'))): # only install our dirstate wrapper if it has a hope of working import gitdirstate if ignoremod: @@ -286,7 +276,7 @@ def git_cleanup(ui, repo): '''clean up Git commit map after history editing''' new_map = [] - vfs = _gitvfs(repo) + vfs = compat.gitvfs(repo) for line in vfs(GitHandler.map_file): gitsha, hgsha = line.strip().split(' ', 1) if hgsha in repo: diff -r 3b20ecf51ed5 -r c06d4656b77b hggit/compat.py --- a/hggit/compat.py Mon Nov 27 22:03:18 2017 -0600 +++ b/hggit/compat.py Sun Dec 24 11:48:24 2017 -0500 @@ -28,6 +28,22 @@ s = s.replace(c, '') return s +try: + from mercurial import vfs as vfsmod + hgvfs = vfsmod.vfs +except ImportError: + # vfsmod was extracted in hg 4.2 + from mercurial import scmutil + hgvfs = scmutil.vfs + +def gitvfs(repo): + """return a vfs suitable to read git related data""" + # Mercurial >= 3.3: repo.shared() + if repo.sharedpath != repo.path: + return hgvfs(repo.sharedpath) + else: + return repo.vfs + def passwordmgr(ui): try: realm = hgutil.urlreq.httppasswordmgrwithdefaultrealm() diff -r 3b20ecf51ed5 -r c06d4656b77b hggit/git_handler.py --- a/hggit/git_handler.py Mon Nov 27 22:03:18 2017 -0600 +++ b/hggit/git_handler.py Sun Dec 24 11:48:24 2017 -0500 @@ -25,7 +25,6 @@ phases, util as hgutil, url, - vfs as vfsmod, ) import _ssh @@ -110,7 +109,7 @@ # Mercurial >= 3.3: repo.shared() if dest_repo.sharedpath != dest_repo.path: - self.vfs = vfsmod.vfs(dest_repo.sharedpath) + self.vfs = compat.hgvfs(dest_repo.sharedpath) if compat.config(ui, 'bool', 'git', 'intree'): self.gitdir = self.repo.wvfs.join('.git') else: