[PATCH STABLE] update: delete bookmarks.current when explicitly updating to a rev (issue3276)
Idan Kamara
idankk86 at gmail.com
Tue Feb 28 21:51:37 UTC 2012
# HG changeset patch
# User Idan Kamara <idankk86 at gmail.com>
# Date 1330465666 -7200
# Branch stable
# Node ID c97830a12ab4deb63b664479ccc0755aba3042e5
# Parent 1997b68c98805548c2ed9e1756d4b32fc61ec45d
update: delete bookmarks.current when explicitly updating to a rev (issue3276)
diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- 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
--- 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
--- 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
--- 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
More information about the Mercurial-devel
mailing list