diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -5633,7 +5633,7 @@ def update(ui, repo, node=None, rev=None Update the repository's working directory to the specified changeset. If no changeset is specified, update to the tip of the - current named branch. + current named branch and move the current bookmark. If the changeset is not a descendant of the working directory's parent, the update is aborted. With the -c/--check option, the @@ -5678,6 +5678,11 @@ def update(ui, repo, node=None, rev=None if rev is None or rev == '': rev = node + # with no argument, we also move the current bookmark, if any + movemarkfrom = None + if node is None or node == '': + movemarkfrom = repo['.'].node() + # if we defined a bookmark, we have to remember the original bookmark name brev = rev rev = scmutil.revsingle(repo, rev, rev).rev() @@ -5701,7 +5706,9 @@ def update(ui, repo, node=None, rev=None else: ret = hg.update(repo, rev) - if brev in repo._bookmarks: + if not ret and movemarkfrom: + bookmarks.update(repo, [movemarkfrom], repo['.'].node()) + elif brev in repo._bookmarks: bookmarks.setcurrent(repo, brev) return ret diff --git a/tests/test-bookmarks-pushpull.t b/tests/test-bookmarks-pushpull.t --- a/tests/test-bookmarks-pushpull.t +++ b/tests/test-bookmarks-pushpull.t @@ -109,7 +109,7 @@ divergent bookmarks * X 1:9b140be10808 Y 0:4e3505fd9583 foo -1:000000000000 - foobar -1:000000000000 + foobar 1:9b140be10808 $ hg pull --config paths.foo=../a foo pulling from $TESTTMP/a @@ -125,7 +125,7 @@ divergent bookmarks X@foo 2:0d2164f0ce0d Y 0:4e3505fd9583 foo -1:000000000000 - foobar -1:000000000000 + foobar 1:9b140be10808 $ hg push -f ../a pushing to ../a searching for changes @@ -158,7 +158,7 @@ hgweb Y 4e3505fd95835d721066b76e75dbb8cc554d7f77 X 9b140be1080824d768c5a4691a564088eede71f9 foo 0000000000000000000000000000000000000000 - foobar 0000000000000000000000000000000000000000 + foobar 9b140be1080824d768c5a4691a564088eede71f9 $ hg out -B http://localhost:$HGPORT/ comparing with http://localhost:$HGPORT/ searching for changed bookmarks @@ -174,7 +174,7 @@ hgweb searching for changed bookmarks Z 0d2164f0ce0d foo 000000000000 - foobar 000000000000 + foobar 9b140be10808 $ hg pull -B Z http://localhost:$HGPORT/ pulling from http://localhost:$HGPORT/ no changes found @@ -193,6 +193,6 @@ hgweb Y 0:4e3505fd9583 Z 2:0d2164f0ce0d foo -1:000000000000 - foobar -1:000000000000 + foobar 1:9b140be10808 $ kill `cat ../hg.pid`