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

login
register
mail settings
Submitter phabricator
Date July 8, 2020, 8:38 a.m.
Message ID <differential-rev-PHID-DREV-cj5oeav3cbfb6sltsk5p-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/46665/
State Superseded
Headers show

Comments

phabricator - July 8, 2020, 8:38 a.m.
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




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

Patch

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