changeset 23379:86c6f06feb04

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.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 13 Nov 2014 11:12:47 +0000
parents 47091002ae62
children 90cc552ceed5
files mercurial/localrepo.py
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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