Patchwork [STABLE] bookmarks: consider successor changesets when moving bookmark (issue4015)

login
register
mail settings
Submitter Sean Farley
Date Nov. 23, 2013, 6:44 p.m.
Message ID <2611478335d169fc7fef.1385232287@laptop.local>
Download mbox | patch
Permalink /patch/3101/
State Accepted
Commit 2ca325ea57fa13909e28cc2caeae3c73e60693f8
Headers show

Comments

Sean Farley - Nov. 23, 2013, 6:44 p.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1383786074 21600
#      Wed Nov 06 19:01:14 2013 -0600
# Branch stable
# Node ID 2611478335d169fc7fefa593195ea76ba957ef93
# Parent  06ef32c3b4bb2974749eefa171434903fe887e46
bookmarks: consider successor changesets when moving bookmark (issue4015)

Previously, this required -f because we didn't consider obsolete changesets
(and their children ... or successors of those children, etc.). We now use
obsolete.foreground to calculate acceptable changesets when advancing the
bookmark.

Test coverage has been added.
Matt Mackall - Nov. 25, 2013, 10:02 p.m.
On Sat, 2013-11-23 at 13:44 -0500, Sean Farley wrote:
> # HG changeset patch
> # User Sean Farley <sean.michael.farley@gmail.com>
> # Date 1383786074 21600
> #      Wed Nov 06 19:01:14 2013 -0600
> # Branch stable
> # Node ID 2611478335d169fc7fefa593195ea76ba957ef93
> # Parent  06ef32c3b4bb2974749eefa171434903fe887e46
> bookmarks: consider successor changesets when moving bookmark (issue4015)

This is queued for stable, thanks.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -834,14 +834,16 @@ 
                 # that contains a divergent bookmark
                 if bmctx.rev() not in anc and target in divs:
                     bookmarks.deletedivergent(repo, [target], mark)
                     return
 
+                # consider successor changesets as well
+                foreground = obsolete.foreground(repo, [marks[mark]])
                 deletefrom = [b for b in divs
                               if repo[b].rev() in anc or b == target]
                 bookmarks.deletedivergent(repo, deletefrom, mark)
-                if bmctx.rev() in anc:
+                if bmctx.rev() in anc or target in foreground:
                     ui.status(_("moving bookmark '%s' forward from %s\n") %
                               (mark, short(bmctx.node())))
                     return
             raise util.Abort(_("bookmark '%s' already exists "
                                "(use -f to force)") % mark)
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
@@ -204,10 +204,11 @@ 
   | |/
   | @  1:0786582aa4b1 1
   |/
   o  0:60829823a42a 0
   
+  $ hg book bm -r 3
   $ hg status
   M foo
 
 We add simple obsolescence marker between 3 and 4 (indirect successors)
 
@@ -216,14 +217,20 @@ 
   $ hg id --debug -i -r 4
   d047485b3896813b2a624e86201983520f003206
   $ hg debugobsolete 6efa171f091b00a3c35edc15d48c52a498929953 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
   $ hg debugobsolete aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa d047485b3896813b2a624e86201983520f003206
 
-Test that 5 is detected as a valid destination from 3
+Test that 5 is detected as a valid destination from 3 and also accepts moving
+the bookmark (issue4015)
+
   $ hg up --quiet --hidden 3
   $ hg up 5
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg book bm
+  moving bookmark 'bm' forward from 6efa171f091b
+  $ hg bookmarks
+   * bm                        5:ff252e8273df
 
 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