[PATCH 6 of 6 V3] commands: use bookmarks.validdest instead of duplicating logic

Sean Farley sean.michael.farley at gmail.com
Wed Jan 15 18:34:21 CST 2014

# HG changeset patch
# User Sean Farley <sean.michael.farley at gmail.com>
# Date 1389830113 21600
#      Wed Jan 15 17:55:13 2014 -0600
# Node ID 2eb8f8974a88c824686fbf4ba9e1034b02cfbd65
# Parent  87fdc623c818bb7b7ed930d5e06f6ce122c6d1a3
commands: use bookmarks.validdest instead of duplicating logic

Now that bookmarks.py has grown a validdest method that even handles successor
changesets, we use that instead of duplicating the logic in commands.py

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -832,16 +832,14 @@ def bookmark(ui, repo, *names, **opts):
                 # that contains a divergent bookmark
                 if bmctx.rev() not in anc and target in divs:
                     bookmarks.deletedivergent(repo, [target], mark)
-                # 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 or target in foreground:
+                if bookmarks.validdest(repo, bmctx, repo[target]):
                     ui.status(_("moving bookmark '%s' forward from %s\n") %
                               (mark, short(bmctx.node())))
             raise util.Abort(_("bookmark '%s' already exists "
                                "(use -f to force)") % mark)

More information about the Mercurial-devel mailing list