localrepo: add a currenttransaction method
authorPierre-Yves David <pierre-yves.david@fb.com>
Thu, 13 Nov 2014 11:12:47 +0000
changeset 23379 86c6f06feb04
parent 23378 47091002ae62
child 23380 90cc552ceed5
localrepo: add a currenttransaction method This method returnx the current transaction or None: it will allow a cache writer to hook in an existing transaction.
mercurial/localrepo.py
--- a/mercurial/localrepo.py	Thu Nov 13 11:11:17 2014 +0000
+++ b/mercurial/localrepo.py	Thu Nov 13 11:12:47 2014 +0000
@@ -865,9 +865,16 @@
     def wwritedata(self, filename, data):
         return self._filter(self._decodefilterpats, filename, data)
 
-    def transaction(self, desc, report=None):
+    def currenttransaction(self):
+        """return the current transaction or None if non exists"""
         tr = self._transref and self._transref() or None
         if tr and tr.running():
+            return tr
+        return None
+
+    def transaction(self, desc, report=None):
+        tr = self.currenttransaction()
+        if tr is not None:
             return tr.nest()
 
         # abort here if the journal already exists