diff mercurial/bookmarks.py @ 27186:34d26e22a2b0

bookmarks: hoist getbkfile out of bmstore class It's totally fine that this hook exists, but I don't see a need for it to live inside the bmstore class.
author Augie Fackler <augie@google.com>
date Wed, 11 Nov 2015 20:45:38 -0500
parents d52765831086
children d9dcc5c09d77
line wrap: on
line diff
--- a/mercurial/bookmarks.py	Wed Nov 11 20:43:25 2015 -0500
+++ b/mercurial/bookmarks.py	Wed Nov 11 20:45:38 2015 -0500
@@ -22,6 +22,25 @@
     util,
 )
 
+def _getbkfile(repo):
+    """Hook so that extensions that mess with the store can hook bm storage.
+
+    For core, this just handles wether we should see pending
+    bookmarks or the committed ones. Other extensions (like share)
+    may need to tweak this behavior further.
+    """
+    bkfile = None
+    if 'HG_PENDING' in os.environ:
+        try:
+            bkfile = repo.vfs('bookmarks.pending')
+        except IOError as inst:
+            if inst.errno != errno.ENOENT:
+                raise
+    if bkfile is None:
+        bkfile = repo.vfs('bookmarks')
+    return bkfile
+
+
 class bmstore(dict):
     """Storage for bookmarks.
 
@@ -41,7 +60,7 @@
         dict.__init__(self)
         self._repo = repo
         try:
-            bkfile = self.getbkfile(repo)
+            bkfile = _getbkfile(repo)
             for line in bkfile:
                 line = line.strip()
                 if not line:
@@ -60,24 +79,6 @@
             if inst.errno != errno.ENOENT:
                 raise
 
-    def getbkfile(self, repo):
-        """Hook so that extensions that mess with the store can hook bm storage.
-
-        For core, this just handles wether we should see pending
-        bookmarks or the committed ones. Other extensions (like share)
-        may need to tweak this behavior further.
-        """
-        bkfile = None
-        if 'HG_PENDING' in os.environ:
-            try:
-                bkfile = repo.vfs('bookmarks.pending')
-            except IOError as inst:
-                if inst.errno != errno.ENOENT:
-                    raise
-        if bkfile is None:
-            bkfile = repo.vfs('bookmarks')
-        return bkfile
-
     def recordchange(self, tr):
         """record that bookmarks have been changed in a transaction