Patchwork [1,of,3] bookmarks: factor out bookmark file opening for easier extensibility

login
register
mail settings
Submitter Ryan McElroy
Date Dec. 1, 2014, 8:57 p.m.
Message ID <c4f7d3fbe855041951df.1417467442@devbig105.prn2.facebook.com>
Download mbox | patch
Permalink /patch/6933/
State Superseded
Commit 756376ec6c128b42239d3726f73cd7a47446d1af
Headers show

Comments

Ryan McElroy - Dec. 1, 2014, 8:57 p.m.
# HG changeset patch
# User Ryan McElroy <rmcelroy@fb.com>
# Date 1417076665 28800
#      Thu Nov 27 00:24:25 2014 -0800
# Node ID c4f7d3fbe855041951dfccb40b05031def426a2b
# Parent  a81c76106d9036060b3371f36b00ceefa5d60898
bookmarks: factor out bookmark file opening for easier extensibility

Patch

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -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