comparison mercurial/transaction.py @ 1806:a2c69737e65e

Automatic nesting into running transactions in the same repository. This associates a transaction handle with a given repository object, and any additional calls to start new transactions reuse that transaction. For the 2700 patch import run, this brings the system time down from 1m20s to 50s, mostly by skipping backups of the dirstate file. (note, this patch does not change hg import to use the nested transaction, mq is the only user right now)
author mason@suse.com
date Tue, 28 Feb 2006 12:24:54 -0600
parents 59b3639df0a9
children d66278012853
comparison
equal deleted inserted replaced
1805:2af98c4b2587 1806:a2c69737e65e
20 20
21 # abort here if the journal already exists 21 # abort here if the journal already exists
22 if os.path.exists(journal): 22 if os.path.exists(journal):
23 raise AssertionError(_("journal already exists - run hg recover")) 23 raise AssertionError(_("journal already exists - run hg recover"))
24 24
25 self.count = 1
25 self.report = report 26 self.report = report
26 self.opener = opener 27 self.opener = opener
27 self.after = after 28 self.after = after
28 self.entries = [] 29 self.entries = []
29 self.map = {} 30 self.map = {}
44 self.map[file] = 1 45 self.map[file] = 1
45 # add enough data to the journal to do the truncate 46 # add enough data to the journal to do the truncate
46 self.file.write("%s\0%d\n" % (file, offset)) 47 self.file.write("%s\0%d\n" % (file, offset))
47 self.file.flush() 48 self.file.flush()
48 49
50 def nest(self):
51 self.count += 1
52 return self
53
54 def running(self):
55 return self.count > 0
56
49 def close(self): 57 def close(self):
58 self.count -= 1
59 if self.count != 0:
60 return
50 self.file.close() 61 self.file.close()
51 self.entries = [] 62 self.entries = []
52 if self.after: 63 if self.after:
53 self.after() 64 self.after()
54 else: 65 else: