diff mercurial/bookmarks.py @ 23360:e06daad65f85

bookmark: read pending data when appropriate If we are called by a hook and pending data exists, read it.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Sun, 28 Sep 2014 21:27:48 -0700
parents 197e17be5407
children 756376ec6c12
line wrap: on
line diff
--- a/mercurial/bookmarks.py	Wed Nov 12 16:54:57 2014 +0000
+++ b/mercurial/bookmarks.py	Sun Sep 28 21:27:48 2014 -0700
@@ -5,6 +5,7 @@
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
+import os
 from mercurial.i18n import _
 from mercurial.node import hex, bin
 from mercurial import encoding, error, util, obsolete, lock as lockmod
@@ -29,7 +30,16 @@
         dict.__init__(self)
         self._repo = repo
         try:
-            for line in repo.vfs('bookmarks'):
+            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')
+            for line in bkfile:
                 line = line.strip()
                 if not line:
                     continue