# HG changeset patch # User Pierre-Yves David # Date 1442531290 25200 # Node ID 4b685712fa454919c121d8d1c967da35b0522dd5 # Parent 91cad8eb79511111c706a794cf5a658d762236b0 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 -r 91cad8eb7951 -r 4b685712fa45 mercurial/commands.py --- 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: diff -r 91cad8eb7951 -r 4b685712fa45 tests/test-bookmarks.t --- 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