Mercurial > hg
changeset 95:589f507bb259
Beginnings of transaction undo support
author | mpm@selenic.com |
---|---|
date | Wed, 18 May 2005 16:31:51 -0800 |
parents | 7daef883134f |
children | fce47326677c |
files | mercurial/hg.py mercurial/transaction.py |
diffstat | 2 files changed, 9 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/hg.py Wed May 18 16:29:39 2005 -0800 +++ b/mercurial/hg.py Wed May 18 16:31:51 2005 -0800 @@ -294,7 +294,8 @@ return filelog(self.opener, f) def transaction(self): - return transaction(self.opener, self.join("journal")) + return transaction(self.opener, self.join("journal"), + self.join("undo")) def commit(self, parent, update = None, text = ""): tr = self.transaction()
--- a/mercurial/transaction.py Wed May 18 16:29:39 2005 -0800 +++ b/mercurial/transaction.py Wed May 18 16:31:51 2005 -0800 @@ -14,16 +14,16 @@ import os class transaction: - def __init__(self, opener, journal): + def __init__(self, opener, journal, after = None): self.opener = opener + self.after = after self.entries = [] self.map = {} self.journal = journal # abort here if the journal already exists if os.path.exists(self.journal): - print "journal already exists, recovering" - self.recover() + raise "journal already exists!" self.file = open(self.journal, "w") @@ -43,7 +43,10 @@ def close(self): self.file.close() self.entries = [] - os.unlink(self.journal) + if self.after: + os.rename(self.journal, self.after) + else: + os.unlink(self.journal) def abort(self): if not self.entries: return