changeset 23458:756376ec6c12

bookmarks: factor out bookmark file opening for easier extensibility
author Ryan McElroy <rmcelroy@fb.com>
date Thu, 27 Nov 2014 00:24:25 -0800
parents fc76f55705eb
children 2e047b1558a5
files mercurial/bookmarks.py
diffstat 1 files changed, 13 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bookmarks.py	Tue Dec 02 17:19:20 2014 -0600
+++ b/mercurial/bookmarks.py	Thu Nov 27 00:24:25 2014 -0800
@@ -30,15 +30,7 @@
         dict.__init__(self)
         self._repo = repo
         try:
-            bkfile = None
-            if 'HG_PENDING' in os.environ:
-                try:
-                    bkfile = repo.vfs('bookmarks.pending')
-                except IOError, inst:
-                    if inst.errno != errno.ENOENT:
-                        raise
-            if bkfile is None:
-                bkfile = repo.vfs('bookmarks')
+            bkfile = self.getbkfile(repo)
             for line in bkfile:
                 line = line.strip()
                 if not line:
@@ -57,6 +49,18 @@
             if inst.errno != errno.ENOENT:
                 raise
 
+    def getbkfile(self, repo):
+        bkfile = None
+        if 'HG_PENDING' in os.environ:
+            try:
+                bkfile = repo.vfs('bookmarks.pending')
+            except IOError, 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