Patchwork [5,of,6,V4] update: consider successor changesets when moving active bookmark

login
register
mail settings
Submitter Sean Farley
Date Jan. 17, 2014, 8:14 p.m.
Message ID <2db9cc45ec27273af8ee.1389989671@laptop.local>
Download mbox | patch
Permalink /patch/3378/
State Accepted
Commit 67ee87a371b21d769c9ecd4cf0a1854176664d51
Headers show

Comments

Sean Farley - Jan. 17, 2014, 8:14 p.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1389829728 21600
#      Wed Jan 15 17:48:48 2014 -0600
# Node ID 2db9cc45ec27273af8ee1240390d051c585034d8
# Parent  3493a0afd287bf583236141cbc632725359b8927
update: consider successor changesets when moving active bookmark

Previously, when an obsolete changeset was bookmarked, successor changesets were not considered
when moving the bookmark forward. Now that a bare update will move to the tip most of the
successor changesets, we also update the bookmark logic to allow the bookmark to move with this
update.

Tests have been updated and keep issue4015 covered as well.

Patch

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -190,17 +190,16 @@  def update(repo, parents, node):
     cur = repo._bookmarkcurrent
     if not cur:
         return False
 
     if marks[cur] in parents:
-        old = repo[marks[cur]]
         new = repo[node]
         divs = [repo[b] for b in marks
                 if b.split('@', 1)[0] == cur.split('@', 1)[0]]
         anc = repo.changelog.ancestors([new.rev()])
         deletefrom = [b.node() for b in divs if b.rev() in anc or b == new]
-        if old.descendant(new):
+        if validdest(repo, repo[marks[cur]], new):
             marks[cur] = new.node()
             update = True
 
     if deletedivergent(repo, deletefrom, cur):
         update = True
diff --git a/tests/test-update-branches.t b/tests/test-update-branches.t
--- a/tests/test-update-branches.t
+++ b/tests/test-update-branches.t
@@ -227,17 +227,20 @@  the bookmark (issue4015)
   $ hg book bm
   moving bookmark 'bm' forward from 6efa171f091b
   $ hg bookmarks
    * bm                        5:ff252e8273df
 
-Test that 4 is detected as the no-argument destination from 3
+Test that 4 is detected as the no-argument destination from 3 and also moves
+the bookmark with it
   $ hg up --quiet 0          # we should be able to update to 3 directly
   $ hg up --quiet --hidden 3 # but not implemented yet.
+  $ hg book -f bm
   $ hg up
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hg id
-  d047485b3896+ (b1)
+  updating bookmark bm
+  $ hg book
+   * bm                        4:d047485b3896
 
 Test that 5 is detected as a valid destination from 1
   $ hg up --quiet 0          # we should be able to update to 3 directly
   $ hg up --quiet --hidden 3 # but not implemented yet.
   $ hg up 5