diff hggit/compat.py @ 1088:c06d4656b77b

shared: fix compatibility with hg < 4.2
author Kevin Bullock <kbullock@ringworld.org>
date Sun, 24 Dec 2017 11:48:24 -0500
parents d96f998a718f
children 3799bf885c1d
line wrap: on
line diff
--- 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()