Patchwork [4,of,4] pull: deactivate a bookmark not matching with the destination of the update

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Feb. 17, 2016, 7:49 p.m.
Message ID <edf94fa667befb6164bb.1455738568@feefifofum>
Download mbox | patch
Permalink /patch/13246/
State Superseded
Commit 5d9578d9ad1aeda1f89f22612f1a04ce5a96ad71
Headers show

Comments

Katsunori FUJIWARA - Feb. 17, 2016, 7:49 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1455738393 -32400
#      Thu Feb 18 04:46:33 2016 +0900
# Node ID edf94fa667befb6164bbd600fda98fa7d74ce8f6
# Parent  b092aa9103651338b613e7d9255809bf2706f89b
pull: deactivate a bookmark not matching with the destination of the update

Before this patch, "hg pull -u" doesn't deactivate a current active
bookmark, which doesn't match with the explicit destination of the
update.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5570,6 +5570,11 @@  def postincoming(ui, repo, modheads, opt
             if brev != repo._activebookmark:
                 ui.status(_("(activating bookmark %s)\n") % brev)
             bookmarks.activate(repo, brev)
+        elif brev:
+            if repo._activebookmark:
+                ui.status(_("(leaving bookmark %s)\n") %
+                          repo._activebookmark)
+            bookmarks.deactivate(repo)
         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
@@ -200,6 +200,95 @@  explicit destination of the update.
      active-before-pull        4:20a3d5b6ab59
    * bookmark-on-bar-tip       6:0c90a742bd4f
 
+Test that updating deactivates current active bookmark, if the
+destination of the update is explicitly specified, and it doesn't
+match with the name of any exsiting bookmarks.
+
+(discard pulled changes)
+
+  $ hg update -q 20a3d5b6ab59
+  $ hg rollback -q
+
+(1) deactivating by --rev REV
+
+  $ hg bookmark -f active-before-pull
+  $ hg bookmarks
+   * active-before-pull        4:20a3d5b6ab59
+
+  $ hg pull -u -r 0c90a742bd4f
+  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
+  (leaving bookmark active-before-pull)
+
+  $ hg parents -q
+  6:0c90a742bd4f
+  $ hg bookmarks
+     active-before-pull        4:20a3d5b6ab59
+     bookmark-on-bar-tip       6:0c90a742bd4f
+
+(discard changes pulled)
+
+  $ hg update -q 20a3d5b6ab59
+  $ hg rollback -q
+
+(2) deactivating by --branch BRANCH
+
+  $ hg bookmark -f active-before-pull
+  $ hg bookmarks
+   * active-before-pull        4:20a3d5b6ab59
+
+  $ hg pull -u -b bar
+  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
+  (leaving bookmark active-before-pull)
+
+  $ hg parents -q
+  6:0c90a742bd4f
+  $ hg bookmarks
+     active-before-pull        4:20a3d5b6ab59
+     bookmark-on-bar-tip       6:0c90a742bd4f
+
+(discard changes pulled)
+
+  $ hg update -q 20a3d5b6ab59
+  $ hg rollback -q
+
+(3) deactivating by URL#ANOTHER-BRANCH
+
+  $ hg update -q default
+  $ hg bookmark -f active-before-pull
+  $ hg bookmarks
+   * active-before-pull        3:483b76ad4309
+
+  $ hg pull -u $TESTTMP/t#bar
+  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
+  (leaving bookmark active-before-pull)
+
+  $ hg parents -q
+  6:0c90a742bd4f
+  $ hg bookmarks
+     active-before-pull        3:483b76ad4309
+     bookmark-on-bar-tip       6:0c90a742bd4f
+
 Test updating for multiple heads:
 
   $ hg -R ../t update -q 20a3d5b6ab59
@@ -242,6 +331,11 @@  update", if pulling even from "URL#BRANC
 
 (2) update to "branch tip" on another topological branch, otherwise
 
+  $ hg bookmark -f active-before-pull
+  $ hg bookmarks
+   * active-before-pull        6:0c90a742bd4f
+     bookmark-on-bar-tip       6:0c90a742bd4f
+
   $ hg pull -u -r bar
   pulling from $TESTTMP/t (glob)
   searching for changes
@@ -250,8 +344,12 @@  update", if pulling even from "URL#BRANC
   adding file changes
   added 1 changesets with 1 changes to 1 files (+1 heads)
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (leaving bookmark active-before-pull)
 
   $ hg parents -q
   7:424b5eb9b087
+  $ hg bookmarks
+     active-before-pull        6:0c90a742bd4f
+     bookmark-on-bar-tip       6:0c90a742bd4f
 
   $ cd ..