Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/transaction.py @ 42:91f1fa847158
Fix multiple changes to file per transaction
author | mpm@selenic.com |
---|---|
date | Tue, 10 May 2005 00:31:00 -0800 |
parents | eb87b7dc4236 |
children | 42177b56b949 |
comparison
equal
deleted
inserted
replaced
41:df3f46253878 | 42:91f1fa847158 |
---|---|
15 | 15 |
16 class transaction: | 16 class transaction: |
17 def __init__(self, opener, journal): | 17 def __init__(self, opener, journal): |
18 self.opener = opener | 18 self.opener = opener |
19 self.entries = [] | 19 self.entries = [] |
20 self.map = {} | |
20 self.journal = journal | 21 self.journal = journal |
21 | 22 |
22 # abort here if the journal already exists | 23 # abort here if the journal already exists |
23 if os.path.exists(self.journal): | 24 if os.path.exists(self.journal): |
24 raise "Journal already exists!" | 25 raise "Journal already exists!" |
28 if self.entries: self.abort() | 29 if self.entries: self.abort() |
29 try: os.unlink(self.journal) | 30 try: os.unlink(self.journal) |
30 except: pass | 31 except: pass |
31 | 32 |
32 def add(self, file, offset): | 33 def add(self, file, offset): |
34 if file in self.map: return | |
33 self.entries.append((file, offset)) | 35 self.entries.append((file, offset)) |
36 self.map[file] = 1 | |
34 # add enough data to the journal to do the truncate | 37 # add enough data to the journal to do the truncate |
35 self.file.write("%s\0%d\n" % (file, offset)) | 38 self.file.write("%s\0%d\n" % (file, offset)) |
36 self.file.flush() | 39 self.file.flush() |
37 | 40 |
38 def close(self): | 41 def close(self): |