Mercurial > hg
diff mercurial/localrepo.py @ 14268:a55a0045704c
merge with stable
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 08 May 2011 16:16:41 -0500 |
parents | df2399663392 89e7d35e0ef0 |
children | 01472f8f5429 |
line wrap: on
line diff
--- 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)