[PATCH 02 of 10] transaction: only generate file when we actually close the transaction

Pierre-Yves David pierre-yves.david at ens-lyon.org
Tue Oct 28 10:41:16 CDT 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1413606348 25200
#      Fri Oct 17 21:25:48 2014 -0700
# Branch stable
# Node ID 74f8131d57fbe539ed5fe16d84230b47ef328ddb
# Parent  5ccb5eb0a6dedf6910ed95434b6dde95b5e473c5
transaction: only generate file when we actually close the transaction

Before this change, the file were written for every call to `tr.close()`
exposing data to reader far too early.

diff --git a/mercurial/transaction.py b/mercurial/transaction.py
--- a/mercurial/transaction.py
+++ b/mercurial/transaction.py
@@ -264,12 +264,12 @@ class transaction(object):
         return self.count > 0
 
     @active
     def close(self):
         '''commit the transaction'''
-        self._generatefiles()
         if self.count == 1 and self.onclose is not None:
+            self._generatefiles()
             self.onclose()
 
         self.count -= 1
         if self.count != 0:
             return


More information about the Mercurial-devel mailing list