Mercurial > hg-stable
changeset 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 | 1e701ffd9df4 |
children | 1107888a1ad1 |
files | hgext/mq.py mercurial/localrepo.py mercurial/transaction.py |
diffstat | 3 files changed, 14 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/mq.py Sat May 29 20:32:39 2010 +0200 +++ b/hgext/mq.py Thu May 27 17:47:40 2010 +0200 @@ -613,8 +613,7 @@ repo.dirstate.invalidate() raise finally: - del tr - release(lock, wlock) + release(tr, lock, wlock) self.removeundo(repo) def _apply(self, repo, series, list=False, update_status=True,
--- a/mercurial/localrepo.py Sat May 29 20:32:39 2010 +0200 +++ b/mercurial/localrepo.py Thu May 27 17:47:40 2010 +0200 @@ -971,7 +971,8 @@ self.branchtags() return n finally: - del tr + if tr: + tr.release() lock.release() def destroyed(self): @@ -2194,7 +2195,7 @@ tr.close() finally: - del tr + tr.release() if changesets > 0: # forcefully update the on-disk branch cache
--- 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: