[PATCH 1 of 3 main-line-of-work] transaction: always generate file on close

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Nov 13 17:04:59 UTC 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1415874167 0
#      Thu Nov 13 10:22:47 2014 +0000
# Node ID d6bae78a0cd5293b9f666909ebac799fc84e43fd
# Parent  a196f9b8f58cf4a129c649fc2b498cb6c32904b0
transaction: always generate file on close

The conditionnal was buggy and file were only generated if "onclose" was
defined. By luck, "onclose" was always defined.

diff --git a/mercurial/transaction.py b/mercurial/transaction.py
--- a/mercurial/transaction.py
+++ b/mercurial/transaction.py
@@ -327,16 +327,17 @@ class transaction(object):
         self._postclosecallback[category] = callback
 
     @active
     def close(self):
         '''commit the transaction'''
-        if self.count == 1 and self.onclose is not None:
+        if self.count == 1:
             self._generatefiles()
             categories = sorted(self._finalizecallback)
             for cat in categories:
                 self._finalizecallback[cat](self)
-            self.onclose()
+            if self.onclose is not None:
+                self.onclose()
 
         self.count -= 1
         if self.count != 0:
             return
         self.file.close()


More information about the Mercurial-devel mailing list