[Request] [+ ] D9194: commit: pass ChangingFiles object as argument to _process_files

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Sat Oct 10 08:41:23 UTC 2020


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

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(



To: pulkit, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20201010/7d25376f/attachment.html>


More information about the Mercurial-patches mailing list