Mercurial > public > mercurial-scm > hg-stable
diff mercurial/transaction.py @ 11230:5116a077c3da
make transactions work on non-refcounted python implementations
author | Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de> |
---|---|
date | Thu, 27 May 2010 17:47:40 +0200 |
parents | 08a0f04b56bd |
children | aade8f133d11 |
line wrap: on
line diff
--- a/mercurial/transaction.py Sat May 29 20:32:39 2010 +0200 +++ b/mercurial/transaction.py Thu May 27 17:47:40 2010 +0200 @@ -43,6 +43,7 @@ class transaction(object): def __init__(self, report, opener, journal, after=None, createmode=None): self.count = 1 + self.usages = 1 self.report = report self.opener = opener self.after = after @@ -108,8 +109,16 @@ @active def nest(self): self.count += 1 + self.usages += 1 return self + def release(self): + if self.count > 0: + self.usages -= 1 + # of the transaction scopes are left without being closed, fail + if self.count > 0 and self.usages == 0: + self._abort() + def running(self): return self.count > 0 @@ -136,6 +145,7 @@ def _abort(self): self.count = 0 + self.usages = 0 self.file.close() try: