# HG changeset patch # User Pierre-Yves David # Date 2015-09-17 23:08:10 # 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 --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -6480,6 +6480,11 @@ def update(ui, repo, node=None, rev=None 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 @@ def update(ui, repo, node=None, rev=None 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 --git a/tests/test-bookmarks.t b/tests/test-bookmarks.t --- a/tests/test-bookmarks.t +++ b/tests/test-bookmarks.t @@ -586,6 +586,12 @@ pull --update works the same as pull && 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