Patchwork [2,of,5,main-line-of-work] locarepo: add a currenttransaction method

login
register
mail settings
Submitter Pierre-Yves David
Date Nov. 20, 2014, 3:30 a.m.
Message ID <bb387f9638d0ee5321f2.1416454228@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/6800/
State Accepted
Headers show

Comments

Pierre-Yves David - Nov. 20, 2014, 3:30 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1415877167 0
#      Thu Nov 13 11:12:47 2014 +0000
# Node ID bb387f9638d0ee5321f2ea85f8cd2bd745ac5243
# Parent  134e2fe35179f0ff82d63a3a9ed7c55d9d5f4098
locarepo: add a currenttransaction method

This method return the current transaction or None: it will allow cache writer
to hook in an existing transaction.
Matt Mackall - Nov. 22, 2014, 1:18 a.m.
On Wed, 2014-11-19 at 19:30 -0800, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1415877167 0
> #      Thu Nov 13 11:12:47 2014 +0000
> # Node ID bb387f9638d0ee5321f2ea85f8cd2bd745ac5243
> # Parent  134e2fe35179f0ff82d63a3a9ed7c55d9d5f4098
> locarepo: add a currenttransaction method

The first two are queued, thanks.

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -863,13 +863,22 @@  class localrepository(object):
                 self.wvfs.setflags(filename, False, True)
 
     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
         if self.svfs.exists("journal"):
             raise error.RepoError(