[PATCH 2 of 3] transaction: support multiple, separate transactions

Henrik Stuart hg at hstuart.dk
Wed Apr 15 15:34:31 CDT 2009


# HG changeset patch
# User Henrik Stuart <henrik.stuart at edlund.dk>
# Date 1239818062 -7200
# Node ID d76d5b797392122cb3040a06177b262719d817cd
# Parent  0bf9ae909f466141fbf74c7e7c6650c45d48c039
transaction: support multiple, separate transactions

Solves that committed (closed) transactions may linger and be returned
on subsequent transaction calls, even though a new transaction should
be made, rather than a new nested transaction.

This also fixes a race condition with the use of weakref.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -593,8 +593,9 @@
         return self._filter("decode", filename, data)
 
     def transaction(self):
-        if self._transref and self._transref():
-            return self._transref().nest()
+        tr = self._transref and self._transref() or None
+        if tr and tr.running():
+            return tr.nest()
 
         # abort here if the journal already exists
         if os.path.exists(self.sjoin("journal")):


More information about the Mercurial-devel mailing list