diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py index 9479c28a22bf3a04c5f487858f3be06d238d3dee_bWVyY3VyaWFsL2Jvb2ttYXJrcy5weQ==..7c75924a69266d58fcbe8a912c877daa440f7dc2_bWVyY3VyaWFsL2Jvb2ttYXJrcy5weQ== 100644 --- a/mercurial/bookmarks.py +++ b/mercurial/bookmarks.py @@ -126,6 +126,17 @@ wlock.release() repo._bookmarkcurrent = mark +def unsetcurrent(repo): + wlock = repo.wlock() + try: + util.unlink(repo.join('bookmarks.current')) + repo._bookmarkcurrent = None + except OSError, inst: + if inst.errno != errno.ENOENT: + raise + finally: + wlock.release() + def updatecurrentbookmark(repo, oldnode, curbranch): try: return update(repo, oldnode, repo.branchtags()[curbranch]) diff --git a/mercurial/commands.py b/mercurial/commands.py index 9479c28a22bf3a04c5f487858f3be06d238d3dee_bWVyY3VyaWFsL2NvbW1hbmRzLnB5..7c75924a69266d58fcbe8a912c877daa440f7dc2_bWVyY3VyaWFsL2NvbW1hbmRzLnB5 100644 --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -5732,6 +5732,8 @@ ui.status(_("updating bookmark %s\n") % repo._bookmarkcurrent) elif brev in repo._bookmarks: bookmarks.setcurrent(repo, brev) + elif brev: + bookmarks.unsetcurrent(repo) return ret diff --git a/tests/test-bookmarks-current.t b/tests/test-bookmarks-current.t index 9479c28a22bf3a04c5f487858f3be06d238d3dee_dGVzdHMvdGVzdC1ib29rbWFya3MtY3VycmVudC50..7c75924a69266d58fcbe8a912c877daa440f7dc2_dGVzdHMvdGVzdC1ib29rbWFya3MtY3VycmVudC50 100644 --- a/tests/test-bookmarks-current.t +++ b/tests/test-bookmarks-current.t @@ -125,3 +125,29 @@ $ hg bookmarks X 0:719295282060 Z 0:719295282060 + +test deleting .hg/bookmarks.current when explicitly updating +to a revision + + $ echo a >> b + $ hg ci -m. + $ hg up -q X + $ test -f .hg/bookmarks.current + +try to update to it again to make sure we don't +set and then unset it + + $ hg up -q X + $ test -f .hg/bookmarks.current + + $ hg up -q 1 + $ test -f .hg/bookmarks.current + [1] + +when a bookmark is active, hg up -r . is +analogus to hg book -i <active bookmark> + + $ hg up -q X + $ hg up -q . + $ test -f .hg/bookmarks.current + [1] diff --git a/tests/test-bookmarks-strip.t b/tests/test-bookmarks-strip.t index 9479c28a22bf3a04c5f487858f3be06d238d3dee_dGVzdHMvdGVzdC1ib29rbWFya3Mtc3RyaXAudA==..7c75924a69266d58fcbe8a912c877daa440f7dc2_dGVzdHMvdGVzdC1ib29rbWFya3Mtc3RyaXAudA== 100644 --- a/tests/test-bookmarks-strip.t +++ b/tests/test-bookmarks-strip.t @@ -34,7 +34,7 @@ $ hg book test2 -update to -2 +update to -2 (inactives the active bookmark) $ hg update -r -2 1 files updated, 0 files merged, 0 files removed, 0 files unresolved @@ -61,7 +61,7 @@ $ hg book test 1:8cf31af87a2b - * test2 1:8cf31af87a2b + test2 1:8cf31af87a2b immediate rollback and reentrancy issue