Patchwork D9194: commit: pass ChangingFiles object as argument to _process_files

login
register
mail settings
Submitter phabricator
Date Oct. 10, 2020, 8:41 a.m.
Message ID <differential-rev-PHID-DREV-5jtw4xanppd2ut5g5wa6-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47432/
State Superseded
Headers show

Comments

phabricator - Oct. 10, 2020, 8:41 a.m.
pulkit created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Instead of returning it, we pass it as an argument. This makes the whole if-else
  in `_prepare_files` a bit simpler. Else each if-else branch was creating the
  object.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/commit.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/commit.py b/mercurial/commit.py
--- a/mercurial/commit.py
+++ b/mercurial/commit.py
@@ -114,14 +114,16 @@ 
     p1 = ctx.p1()
 
     writechangesetcopy, writefilecopymeta = _write_copy_meta(repo)
+    files = metadata.ChangingFiles()
     ms = mergestate.mergestate.read(repo)
     salvaged = _get_salvaged(repo, ms, ctx)
+    for s in salvaged:
+        files.mark_salvaged(s)
 
     if ctx.manifestnode():
         # reuse an existing manifest revision
         repo.ui.debug(b'reusing known manifest\n')
         mn = ctx.manifestnode()
-        files = metadata.ChangingFiles()
         files.update_touched(ctx.files())
         if writechangesetcopy:
             files.update_added(ctx.filesadded())
@@ -129,9 +131,8 @@ 
     elif not ctx.files():
         repo.ui.debug(b'reusing manifest from p1 (no file change)\n')
         mn = p1.manifestnode()
-        files = metadata.ChangingFiles()
     else:
-        mn, files = _process_files(tr, ctx, ms, error=error)
+        mn = _process_files(tr, ctx, ms, files, error=error)
 
     if origctx and origctx.manifestnode() == mn:
         origfiles = origctx.files()
@@ -142,9 +143,6 @@ 
         files.update_copies_from_p1(ctx.p1copies())
         files.update_copies_from_p2(ctx.p2copies())
 
-    for s in salvaged:
-        files.mark_salvaged(s)
-
     return mn, files
 
 
@@ -165,7 +163,7 @@ 
     return salvaged
 
 
-def _process_files(tr, ctx, ms, error=False):
+def _process_files(tr, ctx, ms, files, error=False):
     repo = ctx.repo()
     p1 = ctx.p1()
     p2 = ctx.p2()
@@ -180,8 +178,6 @@ 
     m1 = m1ctx.read()
     m2 = m2ctx.read()
 
-    files = metadata.ChangingFiles()
-
     # check in files
     added = []
     removed = list(ctx.removed())
@@ -231,7 +227,7 @@ 
 
     mn = _commit_manifest(tr, linkrev, ctx, mctx, m, files.touched, added, drop)
 
-    return mn, files
+    return mn
 
 
 def _filecommit(