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

login
register
mail settings
Submitter Sean Farley
Date Jan. 16, 2014, 12:34 a.m.
Message ID <2eb8f8974a88c824686f.1389832461@laptop.local>
Download mbox | patch
Permalink /patch/3337/
State Superseded
Commit 2cfb720592feb329eb5597100c3fc5dd48bafb15
Headers show

Comments

Sean Farley - Jan. 16, 2014, 12:34 a.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@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

Patch

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)
                     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 or target in foreground:
+                if bookmarks.validdest(repo, bmctx, repo[target]):
                     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)