[PATCH] make transactions work on non-refcounted python implementations
Ronny Pfannschmidt
Ronny.Pfannschmidt at gmx.de
Sun May 9 12:17:16 CDT 2010
# HG changeset patch
# User Ronny Pfannschmidt <Ronny.Pfannschmidt at gmx.de>
# Date 1272525135 -7200
# Node ID 58f7889368d403d7efae23e0f16e3126108b92f9
# Parent 0179840ab0d35dae4bcf47b54ae54fef8cc65617
make transactions work on non-refcounted python implementations
diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -625,7 +625,8 @@ class queue(object):
repo.dirstate.invalidate()
raise
finally:
- del tr
+ if tr:
+ tr.unnest()
release(lock, wlock)
self.removeundo(repo)
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -962,7 +962,8 @@ class localrepository(repo.repository):
self.branchtags()
return n
finally:
- del tr
+ if tr:
+ tr.unnest()
lock.release()
def destroyed(self):
@@ -2153,7 +2154,7 @@ class localrepository(repo.repository):
tr.close()
finally:
- del tr
+ tr.unnest()
if changesets > 0:
# forcefully update the on-disk branch cache
diff --git a/mercurial/transaction.py b/mercurial/transaction.py
--- a/mercurial/transaction.py
+++ b/mercurial/transaction.py
@@ -43,6 +43,7 @@ def _playback(journal, report, opener, e
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 @@ class transaction(object):
@active
def nest(self):
self.count += 1
+ self.usages += 1
return self
+ def unnest(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 @@ class transaction(object):
def _abort(self):
self.count = 0
+ self.usages = 0
self.file.close()
try:
More information about the Mercurial-devel
mailing list