D941: remotenames: add a function to return the vfs object

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Wed Oct 4 21:53:36 UTC 2017


pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The statement was added at a lot of places and was going to be added at more
  places. So before that, let's turn that into a function.
  
  Also this is turned into a function so that we can plug in the support for
  shared repositories in future which is supported by hgremotenames extension.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D941

AFFECTED FILES
  mercurial/remotenames.py

CHANGE DETAILS

diff --git a/mercurial/remotenames.py b/mercurial/remotenames.py
--- a/mercurial/remotenames.py
+++ b/mercurial/remotenames.py
@@ -28,6 +28,11 @@
         remote += '/' + ref
     return remote
 
+def getremotevfs(repo):
+    """ returns a vfs object for .hg/remotenames/
+    """
+    return vfsmod.vfs(repo.vfs.join(remotenamedir))
+
 def readremotenamefile(repo, vfs, filename):
     """ reads a file from .hg/remotenames/ directory and yields it's content
 
@@ -54,7 +59,7 @@
     information, call the respective functions.
     """
 
-    vfs = vfsmod.vfs(repo.vfs.join(remotenamedir))
+    vfs = getremotevfs(repo)
 
     for bmentry in readremotenamefile(repo, vfs, 'bookmarks'):
         yield bmentry
@@ -66,7 +71,7 @@
     If remotepath is passed, the entries with the same remotepath are yielded
     only.
     """
-    vfs = vfsmod.vfs(repo.vfs.join(remotenamedir))
+    vfs = getremotevfs(repo)
     for bmentry in readremotenamefile(repo, vfs, 'bookmarks'):
         if bmentry[1] != remotepath:
             yield bmentry
@@ -78,7 +83,7 @@
     If remotepath is passed, the entries with the same remotepath are yielded
     only.
     """
-    vfs = vfsmod.vfs(repo.vfs.join(remotenamedir))
+    vfs = getremotevfs(repo)
     for bmentry in readremotenamefile(repo, vfs, 'branches'):
         if bmentry[1] != remotepath:
             yield bmentry
@@ -123,7 +128,7 @@
     respective files under ".hg/remotenames/" directory.
     """
 
-    vfs = vfsmod.vfs(repo.vfs.join(remotenamedir))
+    vfs = getremotevfs(repo)
     wlock = repo.wlock()
     try:
         if bookmarks:



To: pulkit, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list