Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/transaction.py @ 12:8b64243ee17b
Delete journal on destruction even if there are no entries to replay.
author | mpm@selenic.com |
---|---|
date | Wed, 04 May 2005 09:30:56 -0800 |
parents | 9117c6561b0b |
children | eb87b7dc4236 |
comparison
equal
deleted
inserted
replaced
11:7f16aaeed62f | 12:8b64243ee17b |
---|---|
24 raise "Journal already exists!" | 24 raise "Journal already exists!" |
25 self.file = open(self.journal, "w") | 25 self.file = open(self.journal, "w") |
26 | 26 |
27 def __del__(self): | 27 def __del__(self): |
28 if self.entries: self.abort() | 28 if self.entries: self.abort() |
29 self.close() | |
29 | 30 |
30 def add(self, file, offset): | 31 def add(self, file, offset): |
31 self.entries.append((file, offset)) | 32 self.entries.append((file, offset)) |
32 # add enough data to the journal to do the truncate | 33 # add enough data to the journal to do the truncate |
33 self.file.write("%s\0%d\n" % (file, offset)) | 34 self.file.write("%s\0%d\n" % (file, offset)) |
46 for f, o in self.entries: | 47 for f, o in self.entries: |
47 self.opener(f, "a").truncate(o) | 48 self.opener(f, "a").truncate(o) |
48 | 49 |
49 self.entries = [] | 50 self.entries = [] |
50 | 51 |
51 try: | |
52 os.unlink(self.journal) | |
53 self.file.close() | |
54 except: pass | |
55 | |
56 print "rollback completed" | 52 print "rollback completed" |
57 | 53 |
58 def recover(self): | 54 def recover(self): |
59 for l in open(self.journal).readlines(): | 55 for l in open(self.journal).readlines(): |
60 f, o = l.split('\0') | 56 f, o = l.split('\0') |