changeset 44434:f6798c1a80fa

transaction: clarify the logic around pre-finalize/post-finalize I am taking a bit more verbose route, but I find it easier to follow for people who (re)discover the code. (This is a gratuitous cleanup I did while looking at something else.) Differential Revision: https://phab.mercurial-scm.org/D8176
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 28 Feb 2020 00:17:26 +0100
parents baf8c3f944eb
children 6cf92d6c0ad5
files mercurial/transaction.py
diffstat 1 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/transaction.py	Fri Feb 28 00:02:03 2020 +0100
+++ b/mercurial/transaction.py	Fri Feb 28 00:17:26 2020 +0100
@@ -355,16 +355,22 @@
     def _generatefiles(self, suffix=b'', group=GEN_GROUP_ALL):
         # write files registered for generation
         any = False
+
+        if group == GEN_GROUP_ALL:
+            skip_post = skip_pre = False
+        else:
+            skip_pre = group == GEN_GROUP_POST_FINALIZE
+            skip_post = group == GEN_GROUP_PRE_FINALIZE
+
         for id, entry in sorted(pycompat.iteritems(self._filegenerators)):
             any = True
             order, filenames, genfunc, location = entry
 
             # for generation at closing, check if it's before or after finalize
-            postfinalize = group == GEN_GROUP_POST_FINALIZE
-            if (
-                group != GEN_GROUP_ALL
-                and (id in postfinalizegenerators) != postfinalize
-            ):
+            is_post = id in postfinalizegenerators
+            if skip_post and is_post:
+                continue
+            elif skip_pre and not is_post:
                 continue
 
             vfs = self._vfsmap[location]