Mercurial > public > mercurial-scm > hg
diff 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 |
line wrap: on
line diff
--- a/mercurial/transaction.py Tue Feb 28 11:49:35 2006 -0600 +++ b/mercurial/transaction.py Tue Feb 28 12:24:54 2006 -0600 @@ -22,6 +22,7 @@ if os.path.exists(journal): raise AssertionError(_("journal already exists - run hg recover")) + self.count = 1 self.report = report self.opener = opener self.after = after @@ -46,7 +47,17 @@ self.file.write("%s\0%d\n" % (file, offset)) self.file.flush() + def nest(self): + self.count += 1 + return self + + def running(self): + return self.count > 0 + def close(self): + self.count -= 1 + if self.count != 0: + return self.file.close() self.entries = [] if self.after: