changeset 26286:4b685712fa45

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.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 17 Sep 2015 16:08:10 -0700
parents 91cad8eb7951
children 5c217bcc4597
files mercurial/commands.py tests/test-bookmarks.t
diffstat 2 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Thu Sep 17 17:17:54 2015 -0700
+++ b/mercurial/commands.py	Thu Sep 17 16:08:10 2015 -0700
@@ -6480,6 +6480,11 @@
     try:
         cmdutil.clearunfinished(repo)
 
+        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)
 
@@ -6490,11 +6495,6 @@
         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)
-
         if check:
             cmdutil.bailifchanged(repo, merge=False)
             if rev is None:
--- a/tests/test-bookmarks.t	Thu Sep 17 17:17:54 2015 -0700
+++ b/tests/test-bookmarks.t	Thu Sep 17 16:08:10 2015 -0700
@@ -586,6 +586,12 @@
   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