diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -6483,6 +6483,11 @@ def update(ui, repo, node=None, rev=None if not ret and movemarkfrom: if bookmarks.update(repo, [movemarkfrom], repo['.'].node()): ui.status(_("updating bookmark %s\n") % repo._activebookmark) + else: + # this can happen with a non-linear update + ui.status(_("(leaving bookmark %s)\n") % + repo._activebookmark) + bookmarks.deactivate(repo) elif brev in repo._bookmarks: bookmarks.activate(repo, brev) ui.status(_("(activating bookmark %s)\n") % brev) diff --git a/tests/test-bookmarks.t b/tests/test-bookmarks.t --- a/tests/test-bookmarks.t +++ b/tests/test-bookmarks.t @@ -673,6 +673,31 @@ tipmost surviving ancestor of the stripp date: Thu Jan 01 00:00:00 1970 +0000 summary: 0 +test non-linear update not clearing active bookmark + + $ hg up 1 + 1 files updated, 0 files merged, 2 files removed, 0 files unresolved + (leaving bookmark four) + $ hg book drop + $ hg up -C + 1 files updated, 0 files merged, 1 files removed, 0 files unresolved + (leaving bookmark drop) + $ hg sum + parent: 2:db815d6d32e6 + 2 + branch: default + bookmarks: should-end-on-two + commit: 2 unknown (clean) + update: 1 new changesets, 2 branch heads (merge) + phases: 4 draft + $ hg book + drop 1:925d80f479bb + four 3:9ba5f110a0b3 + should-end-on-two 2:db815d6d32e6 + $ hg book -d drop + $ hg up four + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + (activating bookmark four) test clearing divergent bookmarks of linear ancestors