bookmark: do not crash when active bookmark is forward and --date is used
authorPierre-Yves David <pierre-yves.david@fb.com>
Thu, 17 Sep 2015 16:08:10 -0700
changeset 26286 4b685712fa45
parent 26285 91cad8eb7951
child 26287 5c217bcc4597
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.
mercurial/commands.py
tests/test-bookmarks.t
--- 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