[PATCH 2 of 2] bookmark: do not crash when active bookmark is forward and --date is used
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Fri Sep 18 01:01:57 UTC 2015
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1442531290 25200
# Thu Sep 17 16:08:10 2015 -0700
# Node ID 446b2c6820e76b5c06b23f859036708a7ddf3a07
# Parent 08879306381b931326ff16055419006ebfc894b9
bookmark: do not crash when active bookmark is forward and --date is used
The logic that decides where to update according to the active bookmark
location (when not on ".") was setting the rev to update to before we process
--date. This lead to --date processing aborting because of duplicated
specification.
We reorder the two pieces of code and add a test for this.
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6478,25 +6478,25 @@ def update(ui, repo, node=None, rev=None
wlock = repo.wlock()
try:
cmdutil.clearunfinished(repo)
- # with no argument, we also move the active bookmark, if any
- rev, movemarkfrom = bookmarks.calculateupdate(ui, repo, rev)
-
- # if we defined a bookmark, we have to remember the original name
- brev = rev
- rev = scmutil.revsingle(repo, rev, rev).rev()
-
- if check and clean:
- raise util.Abort(_("cannot specify both -c/--check and -C/--clean"))
-
if date:
if rev is not None:
raise util.Abort(_("you can't specify a revision and a date"))
rev = cmdutil.finddate(ui, repo, date)
+ # with no argument, we also move the active bookmark, if any
+ rev, movemarkfrom = bookmarks.calculateupdate(ui, repo, rev)
+
+ # if we defined a bookmark, we have to remember the original name
+ brev = rev
+ rev = scmutil.revsingle(repo, rev, rev).rev()
+
+ if check and clean:
+ raise util.Abort(_("cannot specify both -c/--check and -C/--clean"))
+
if check:
cmdutil.bailifchanged(repo, merge=False)
if rev is None:
rev = repo[repo[None].branch()].rev()
diff --git a/tests/test-bookmarks.t b/tests/test-bookmarks.t
--- a/tests/test-bookmarks.t
+++ b/tests/test-bookmarks.t
@@ -584,10 +584,16 @@ pull --update works the same as pull &&
adding file changes
added 2 changesets with 2 changes to 2 files (+1 heads)
updating bookmark Y
updating bookmark Z
(run 'hg heads' to see heads, 'hg merge' to merge)
+
+(# tests strange but with --date crashing when bookmark have to move)
+
+ $ hg -R ../cloned-bookmarks-manual-update update -d 1986
+ abort: revision matching date not found
+ [255]
$ hg -R ../cloned-bookmarks-manual-update update
updating to active bookmark Y
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(activating bookmark Y)
More information about the Mercurial-devel
mailing list