Patchwork [6,of,7] bookmark: read pending data when appropriate

login
register
mail settings
Submitter Pierre-Yves David
Date Nov. 18, 2014, 11:40 p.m.
Message ID <70d34957c8eab543e1da.1416354003@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/6778/
State Accepted
Commit e06daad65f85f19334fc011307e148d4052724ad
Headers show

Comments

Pierre-Yves David - Nov. 18, 2014, 11:40 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1411964868 25200
#      Sun Sep 28 21:27:48 2014 -0700
# Node ID 70d34957c8eab543e1da1f7a23ed21d72b9772c5
# Parent  6512b8efc444db34ddeb1818e0743c33b46dafbf
bookmark: read pending data when appropriate

If we are called by a hook and pending data exists, read those.

Patch

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -3,10 +3,11 @@ 
 # Copyright 2008 David Soria Parra <dsp@php.net>
 #
 # 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
 import errno
 
@@ -27,11 +28,20 @@  class bmstore(dict):
 
     def __init__(self, repo):
         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
                 if ' ' not in line:
                     repo.ui.warn(_('malformed line in .hg/bookmarks: %r\n')
diff --git a/tests/test-bundle2-exchange.t b/tests/test-bundle2-exchange.t
--- a/tests/test-bundle2-exchange.t
+++ b/tests/test-bundle2-exchange.t
@@ -164,11 +164,11 @@  add extra data to test their exchange du
 
 push
   $ 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
   remote: adding changesets
   remote: adding manifests
@@ -199,11 +199,11 @@  pull over ssh
   adding manifests
   adding file changes
   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
   (run 'hg heads' to see heads, 'hg merge' to merge)
   $ hg -R other debugobsolete
@@ -224,11 +224,11 @@  pull over http
   adding manifests
   adding file changes
   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/
   (run 'hg heads .' to see heads, 'hg merge' to merge)
   $ cat main-error.log
@@ -248,11 +248,11 @@  push over ssh
   remote: adding manifests
   remote: adding file changes
   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
   $ hg -R other log -G
   o  6:5fddd98957c8 draft Nicolas Dumazet <nicdumz.commits@gmail.com> book_5fdd C