[PATCH 3 of 4] pull: activate a bookmark matching with the destination of the update
FUJIWARA Katsunori
foozy at lares.dti.ne.jp
Wed Feb 17 14:49:27 EST 2016
# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1455738393 -32400
# Thu Feb 18 04:46:33 2016 +0900
# Node ID b092aa9103651338b613e7d9255809bf2706f89b
# Parent 677cfb752ac33aff00ad51564acb44dcfd6724d8
pull: activate a bookmark matching with the destination of the update
Before this patch, "hg pull -u" doesn't activate a bookmark, which
matches with the explicit destination of the update: e.g. "--rev
BOOKMARK" or "URL#BOOKMARK".
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5566,6 +5566,10 @@ def postincoming(ui, repo, modheads, opt
pass # no-op update
elif bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
ui.status(_("updating bookmark %s\n") % repo._activebookmark)
+ elif brev in repo._bookmarks:
+ if brev != repo._activebookmark:
+ ui.status(_("(activating bookmark %s)\n") % brev)
+ bookmarks.activate(repo, brev)
return ret
if modheads > 1:
currentbranchheads = len(repo.branchheads())
diff --git a/tests/test-pull-update.t b/tests/test-pull-update.t
--- a/tests/test-pull-update.t
+++ b/tests/test-pull-update.t
@@ -137,6 +137,69 @@ rollback just rewinds bookmark, which is
$ hg bookmarks
* active-before-pull 5:9ed4148f9a91
+(discard pulled chagnes)
+
+ $ hg update -q 20a3d5b6ab59
+ $ hg rollback -q
+
+ $ hg -R ../t bookmark -d active-before-pull
+
+Test that updating activates the bookmark, which matches with the
+explicit destination of the update.
+
+ $ hg -R ../t bookmark -r bar bookmark-on-bar-tip
+
+(1) activating by --rev BOOKMARK
+
+ $ hg bookmark -f active-before-pull
+ $ hg bookmarks
+ * active-before-pull 4:20a3d5b6ab59
+
+ $ hg pull -u -r bookmark-on-bar-tip
+ pulling from $TESTTMP/t (glob)
+ searching for changes
+ adding changesets
+ adding manifests
+ adding file changes
+ added 2 changesets with 2 changes to 1 files
+ adding remote bookmark bookmark-on-bar-tip
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ (activating bookmark bookmark-on-bar-tip)
+
+ $ hg parents -q
+ 6:0c90a742bd4f
+ $ hg bookmarks
+ active-before-pull 4:20a3d5b6ab59
+ * bookmark-on-bar-tip 6:0c90a742bd4f
+
+(discard pulled changes)
+
+ $ hg update -q 20a3d5b6ab59
+ $ hg rollback -q
+
+(2) activating by URL#BOOKMARK
+
+ $ hg bookmark -f active-before-pull
+ $ hg bookmarks
+ * active-before-pull 4:20a3d5b6ab59
+
+ $ hg pull -u $TESTTMP/t#bookmark-on-bar-tip
+ pulling from $TESTTMP/t (glob)
+ searching for changes
+ adding changesets
+ adding manifests
+ adding file changes
+ added 2 changesets with 2 changes to 1 files
+ adding remote bookmark bookmark-on-bar-tip
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ (activating bookmark bookmark-on-bar-tip)
+
+ $ hg parents -q
+ 6:0c90a742bd4f
+ $ hg bookmarks
+ active-before-pull 4:20a3d5b6ab59
+ * bookmark-on-bar-tip 6:0c90a742bd4f
+
Test updating for multiple heads:
$ hg -R ../t update -q 20a3d5b6ab59
More information about the Mercurial-devel
mailing list