[PATCH RESEND] update: delete bookmarks.current when updating out of it
Idan Kamara
idankk86 at gmail.com
Wed Apr 20 17:32:18 CDT 2011
# HG changeset patch
# User Idan Kamara <idankk86 at gmail.com>
# Date 1303214506 -10800
# Node ID 0532a3ed01cdc0dd31a74dc81739da13ad7002fa
# Parent 0b37fcad00032da47cdf97c655a22c6370549ca1
update: delete bookmarks.current when updating out of it
Previously, when currently updated to a bookmark and then updating
to a different rev which isn't a bookmark, the .hg/bookmarks.current
file would stay there.
This might be a problem because:
1. Tools might be looking at that file to figure out if we're
currently updated to a bookmark (the only other way atm is
to look for a '*' in the output of 'hg bookmarks').
This doesn't fully solve it since pull/unbundle may also advance
the current bookmark.
2. It could cause this misleasding behaviour:
$ hg id -n
1
$ hg bookmark bar
$ hg bookmarks
* bar 1:XXX
$ hg upd 0
$ hg upd 1
...commit...
$ hg bookmarks
* bar 2:XXX
Causing the bookmark to move even though we didn't update to it.
diff -r 0b37fcad0003 -r 0532a3ed01cd mercurial/bookmarks.py
--- a/mercurial/bookmarks.py Tue Apr 19 14:56:46 2011 +0300
+++ b/mercurial/bookmarks.py Tue Apr 19 15:01:46 2011 +0300
@@ -116,6 +116,10 @@
wlock.release()
repo._bookmarkcurrent = mark
+def unsetcurrent(repo):
+ if os.path.exists(repo.join('bookmarks.current')):
+ util.unlink(repo.join('bookmarks.current'))
+
def updatecurrentbookmark(repo, oldnode, curbranch):
try:
update(repo, oldnode, repo.branchtags()[curbranch])
diff -r 0b37fcad0003 -r 0532a3ed01cd mercurial/commands.py
--- a/mercurial/commands.py Tue Apr 19 14:56:46 2011 +0300
+++ b/mercurial/commands.py Tue Apr 19 15:01:46 2011 +0300
@@ -4207,8 +4207,12 @@
else:
ret = hg.update(repo, rev)
+ # 'hg update X' where X is a bookmark
if brev in repo._bookmarks:
bookmarks.setcurrent(repo, brev)
+ # 'hg update X' where X isn't a bookmark
+ elif rev or rev == 0:
+ bookmarks.unsetcurrent(repo)
return ret
diff -r 0b37fcad0003 -r 0532a3ed01cd tests/test-bookmarks-strip.t
--- a/tests/test-bookmarks-strip.t Tue Apr 19 14:56:46 2011 +0300
+++ b/tests/test-bookmarks-strip.t Tue Apr 19 15:01:46 2011 +0300
@@ -61,7 +61,7 @@
$ hg book
test 1:8cf31af87a2b
- * test2 1:8cf31af87a2b
+ test2 1:8cf31af87a2b
immediate rollback and reentrancy issue
diff -r 0b37fcad0003 -r 0532a3ed01cd tests/test-bookmarks.t
--- a/tests/test-bookmarks.t Tue Apr 19 14:56:46 2011 +0300
+++ b/tests/test-bookmarks.t Tue Apr 19 15:01:46 2011 +0300
@@ -117,6 +117,21 @@
Y -1:000000000000
Z 0:f7b1eb17ad24
+lose current bookmark when updating to a previous current bookmark
+without explicitly asking for it
+
+ $ hg update 0
+ 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+ $ hg update 2
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ $ hg bookmarks
+ X 2:db815d6d32e6
+ X2 1:925d80f479bb
+ Y -1:000000000000
+ Z 0:f7b1eb17ad24
+ $ hg update X
+ 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
rename nonexistent bookmark
$ hg bookmark -m A B
More information about the Mercurial-devel
mailing list