D8708: commitctx: move a tiny else clause above the very long one

marmoute (Pierre-Yves David) phabricator at mercurial-scm.org
Wed Jul 8 08:38:46 UTC 2020


marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This is simple to have all the simple case unfold before the 100+ line one. Otherwise it is hard to relate the `else` to the initial conditionnal.
  
  This is part of a larger refactoring/cleanup of the commitctx code to clarify
  and augment the logic gathering metadata useful for copy tracing. The current
  code is a tad too long and entangled to make such update easy. We start with
  easy and small cleanup.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D8708

AFFECTED FILES
  mercurial/localrepo.py

CHANGE DETAILS

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -3122,7 +3122,11 @@
                 if writechangesetcopy:
                     filesadded = ctx.filesadded()
                     filesremoved = ctx.filesremoved()
-            elif ctx.files():
+            elif not ctx.files():
+                self.ui.debug(b'reusing manifest from p1 (no file change)\n')
+                mn = p1.manifestnode()
+                files = []
+            else:
                 m1ctx = p1.manifestctx()
                 m2ctx = p2.manifestctx()
                 mctx = m1ctx.copy()
@@ -3218,10 +3222,6 @@
                         b'actually unchanged)\n'
                     )
                     mn = p1.manifestnode()
-            else:
-                self.ui.debug(b'reusing manifest from p1 (no file change)\n')
-                mn = p1.manifestnode()
-                files = []
 
             if writecopiesto == b'changeset-only':
                 # If writing only to changeset extras, use None to indicate that



To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel


More information about the Mercurial-devel mailing list