--- a/mercurial/bookmarks.py Sun May 08 11:39:24 2011 -0500
+++ b/mercurial/bookmarks.py Sun May 08 16:16:41 2011 -0500
@@ -71,14 +71,6 @@
'''
refs = repo._bookmarks
- try:
- bms = repo.opener.read('bookmarks')
- except IOError, inst:
- if inst.errno != errno.ENOENT:
- raise
- bms = ''
- repo.opener.write('undo.bookmarks', bms)
-
if repo._bookmarkcurrent not in refs:
setcurrent(repo, None)
for mark in refs.keys():
--- a/mercurial/localrepo.py Sun May 08 11:39:24 2011 -0500
+++ b/mercurial/localrepo.py Sun May 08 16:16:41 2011 -0500
@@ -674,6 +674,17 @@
raise error.RepoError(
_("abandoned transaction found - run hg recover"))
+ journalfiles = self._writejournal(desc)
+ renames = [(x, undoname(x)) for x in journalfiles]
+
+ tr = transaction.transaction(self.ui.warn, self.sopener,
+ self.sjoin("journal"),
+ aftertrans(renames),
+ self.store.createmode)
+ self._transref = weakref.ref(tr)
+ return tr
+
+ def _writejournal(self, desc):
# save dirstate for rollback
try:
ds = self.opener.read("dirstate")
@@ -685,16 +696,15 @@
self.opener.write("journal.desc",
"%d\n%s\n" % (len(self), desc))
- renames = [(self.sjoin("journal"), self.sjoin("undo")),
- (self.join("journal.dirstate"), self.join("undo.dirstate")),
- (self.join("journal.branch"), self.join("undo.branch")),
- (self.join("journal.desc"), self.join("undo.desc"))]
- tr = transaction.transaction(self.ui.warn, self.sopener,
- self.sjoin("journal"),
- aftertrans(renames),
- self.store.createmode)
- self._transref = weakref.ref(tr)
- return tr
+ bkname = self.join('bookmarks')
+ if os.path.exists(bkname):
+ util.copyfile(bkname, self.join('journal.bookmarks'))
+ else:
+ self.opener('journal.bookmarks', 'w').write('')
+
+ return (self.sjoin('journal'), self.join('journal.dirstate'),
+ self.join('journal.branch'), self.join('journal.desc'),
+ self.join('journal.bookmarks'))
def recover(self):
lock = self.lock()
@@ -1950,6 +1960,11 @@
util.rename(src, dest)
return a
+def undoname(fn):
+ base, name = os.path.split(fn)
+ assert name.startswith('journal')
+ return os.path.join(base, name.replace('journal', 'undo', 1))
+
def instance(ui, path, create):
return localrepository(ui, util.localpath(path), create)
--- a/tests/test-bookmarks.t Sun May 08 11:39:24 2011 -0500
+++ b/tests/test-bookmarks.t Sun May 08 16:16:41 2011 -0500
@@ -235,6 +235,7 @@
Y 2:db815d6d32e6
* Z 2:db815d6d32e6
x y 2:db815d6d32e6
+
test summary
$ hg summary
@@ -249,6 +250,22 @@
$ hg id
db815d6d32e6 tip Y/Z/x y
+test rollback
+
+ $ echo foo > f1
+ $ hg ci -Amr
+ adding f1
+ $ hg bookmark -f Y -r 1
+ $ hg bookmark -f Z -r 1
+ $ hg rollback
+ repository tip rolled back to revision 2 (undo commit)
+ working directory now based on revision 2
+ $ hg bookmarks
+ X2 1:925d80f479bb
+ Y 2:db815d6d32e6
+ * Z 2:db815d6d32e6
+ x y 2:db815d6d32e6
+
test clone
$ hg bookmarks
--- a/tests/test-fncache.t Sun May 08 11:39:24 2011 -0500
+++ b/tests/test-fncache.t Sun May 08 16:16:41 2011 -0500
@@ -76,6 +76,7 @@
.hg/last-message.txt
.hg/requires
.hg/undo
+ .hg/undo.bookmarks
.hg/undo.branch
.hg/undo.desc
.hg/undo.dirstate
@@ -102,6 +103,7 @@
.hg/store/data/tst.d.hg
.hg/store/data/tst.d.hg/_foo.i
.hg/store/undo
+ .hg/undo.bookmarks
.hg/undo.branch
.hg/undo.desc
.hg/undo.dirstate
--- a/tests/test-hardlinks.t Sun May 08 11:39:24 2011 -0500
+++ b/tests/test-hardlinks.t Sun May 08 16:16:41 2011 -0500
@@ -194,6 +194,7 @@
2 r4/.hg/store/data/f1.i
2 r4/.hg/store/fncache
2 r4/.hg/store/undo
+ 2 r4/.hg/undo.bookmarks
2 r4/.hg/undo.branch
2 r4/.hg/undo.desc
2 r4/.hg/undo.dirstate
@@ -222,6 +223,7 @@
2 r4/.hg/store/data/f1.i
2 r4/.hg/store/fncache
2 r4/.hg/store/undo
+ 2 r4/.hg/undo.bookmarks
2 r4/.hg/undo.branch
2 r4/.hg/undo.desc
2 r4/.hg/undo.dirstate
--- a/tests/test-hup.t Sun May 08 11:39:24 2011 -0500
+++ b/tests/test-hup.t Sun May 08 16:16:41 2011 -0500
@@ -17,4 +17,4 @@
rollback completed
killed!
$ echo .hg/* .hg/store/*
- .hg/00changelog.i .hg/journal.branch .hg/journal.desc .hg/journal.dirstate .hg/requires .hg/store .hg/store/00changelog.i .hg/store/00changelog.i.a
+ .hg/00changelog.i .hg/journal.bookmarks .hg/journal.branch .hg/journal.desc .hg/journal.dirstate .hg/requires .hg/store .hg/store/00changelog.i .hg/store/00changelog.i.a
--- a/tests/test-inherit-mode.t Sun May 08 11:39:24 2011 -0500
+++ b/tests/test-inherit-mode.t Sun May 08 16:16:41 2011 -0500
@@ -77,6 +77,7 @@
00660 ./.hg/store/data/foo.i
00660 ./.hg/store/fncache
00660 ./.hg/store/undo
+ 00660 ./.hg/undo.bookmarks
00660 ./.hg/undo.branch
00660 ./.hg/undo.desc
00660 ./.hg/undo.dirstate
@@ -117,6 +118,7 @@
00660 ../push/.hg/store/data/foo.i
00660 ../push/.hg/store/fncache
00660 ../push/.hg/store/undo
+ 00660 ../push/.hg/undo.bookmarks
00660 ../push/.hg/undo.branch
00660 ../push/.hg/undo.desc
00660 ../push/.hg/undo.dirstate