changeset 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 1b2957b27203
children 936b0ff34346
files mercurial/bookmarks.py tests/test-bundle2-exchange.t
diffstat 2 files changed, 15 insertions(+), 5 deletions(-) [+]
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
--- a/tests/test-bundle2-exchange.t	Wed Nov 12 16:54:57 2014 +0000
+++ b/tests/test-bundle2-exchange.t	Sun Sep 28 21:27:48 2014 -0700
@@ -166,7 +166,7 @@
   $ hg -R main push other --rev eea13746799a --bookmark book_eea1
   pushing to other
   searching for changes
-  pre-close-tip:eea13746799a draft 
+  pre-close-tip:eea13746799a draft book_eea1
   postclose-tip:eea13746799a public book_eea1
   b2x-transactionclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2-EXP=1 HG_NEW_OBSMARKERS=1 HG_NODE=eea13746799a9e0bfd88f29d3c2e9dc9389f524f HG_PHASES_MOVED=1 HG_SOURCE=push HG_URL=push
   changegroup hook: HG_BUNDLE2-EXP=1 HG_NODE=eea13746799a9e0bfd88f29d3c2e9dc9389f524f HG_SOURCE=push HG_URL=push
@@ -201,7 +201,7 @@
   added 1 changesets with 1 changes to 1 files (+1 heads)
   1 new obsolescence markers
   updating bookmark book_02de
-  pre-close-tip:02de42196ebe public 
+  pre-close-tip:02de42196ebe public book_02de
   postclose-tip:02de42196ebe draft book_02de
   b2x-transactionclose hook: HG_BOOKMARK_MOVED=1 HG_NEW_OBSMARKERS=1 HG_NODE=02de42196ebee42ef284b6780a87cdc96e8eaab6 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_URL=ssh://user@dummy/main
   changegroup hook: HG_NODE=02de42196ebee42ef284b6780a87cdc96e8eaab6 HG_SOURCE=pull HG_URL=ssh://user@dummy/main
@@ -226,7 +226,7 @@
   added 1 changesets with 1 changes to 1 files (+1 heads)
   1 new obsolescence markers
   updating bookmark book_42cc
-  pre-close-tip:42ccdea3bb16 public 
+  pre-close-tip:42ccdea3bb16 public book_42cc
   postclose-tip:42ccdea3bb16 draft book_42cc
   b2x-transactionclose hook: HG_BOOKMARK_MOVED=1 HG_NEW_OBSMARKERS=1 HG_NODE=42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_URL=http://localhost:$HGPORT/
   changegroup hook: HG_NODE=42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 HG_SOURCE=pull HG_URL=http://localhost:$HGPORT/
@@ -250,7 +250,7 @@
   remote: added 1 changesets with 1 changes to 1 files
   remote: 1 new obsolescence markers
   updating bookmark book_5fdd
-  remote: pre-close-tip:5fddd98957c8 draft 
+  remote: pre-close-tip:5fddd98957c8 draft book_5fdd
   remote: postclose-tip:5fddd98957c8 draft book_5fdd
   remote: b2x-transactionclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2-EXP=1 HG_NEW_OBSMARKERS=1 HG_NODE=5fddd98957c8a54a4d436dfe1da9d87f21a1b97b HG_SOURCE=serve HG_URL=remote:ssh:127.0.0.1
   remote: changegroup hook: HG_BUNDLE2-EXP=1 HG_NODE=5fddd98957c8a54a4d436dfe1da9d87f21a1b97b HG_SOURCE=serve HG_URL=remote:ssh:127.0.0.1