--- a/mercurial/transaction.py Thu May 26 08:53:04 2005 -0800
+++ b/mercurial/transaction.py Thu May 26 09:04:54 2005 -0800
@@ -15,16 +15,18 @@
class transaction:
def __init__(self, opener, journal, after = None):
+ self.journal = None
+
+ # abort here if the journal already exists
+ if os.path.exists(journal):
+ raise "journal already exists - run hg recover"
+
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):
- raise "journal already exists!"
-
self.file = open(self.journal, "w")
def __del__(self):
@@ -63,9 +65,9 @@
print "rollback completed"
- def recover(self):
- for l in open(self.journal).readlines():
- f, o = l.split('\0')
- self.opener(f, "a").truncate(int(o))
- os.unlink(self.journal)
+def rollback(opener, file):
+ for l in open(file).readlines():
+ f, o = l.split('\0')
+ opener(f, "a").truncate(int(o))
+ os.unlink(file)