Patchwork [15,of,15] commitctx: directly update the touched and added set of files

login
register
mail settings
Submitter Pierre-Yves David
Date July 29, 2020, 4:57 p.m.
Message ID <2261f89274125f99c474.1596041865@nodosa.octobus.net>
Download mbox | patch
Permalink /patch/46926/
State Accepted
Headers show

Comments

Pierre-Yves David - July 29, 2020, 4:57 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1595960466 -7200
#      Tue Jul 28 20:21:06 2020 +0200
# Node ID 2261f89274125f99c47463b7b485c3ecfb7becbd
# Parent  8a38230c8e7b189066e0d58d8134228917368fd7
# EXP-Topic files-change
# Available At https://foss.heptapod.net/octobus/mercurial-devel/
#              hg pull https://foss.heptapod.net/octobus/mercurial-devel/ -r 2261f8927412
commitctx: directly update the touched and added set of files

Instead of going through intermediate variable, we can simply use the
ChangingFiles object. The object will take care of the consistency.

Patch

diff --git a/mercurial/commit.py b/mercurial/commit.py
--- a/mercurial/commit.py
+++ b/mercurial/commit.py
@@ -158,11 +158,11 @@  def _process_files(tr, ctx, error=False)
     m1 = m1ctx.read()
     m2 = m2ctx.read()
 
+    files = metadata.ChangingFiles()
+
     # check in files
     added = []
-    filesadded = []
     removed = list(ctx.removed())
-    touched = []
     linkrev = len(repo)
     repo.ui.note(_(b"committing files:\n"))
     uipathfn = scmutil.getuipathfn(repo)
@@ -178,9 +178,10 @@  def _process_files(tr, ctx, error=False)
                     repo, fctx, m1, m2, linkrev, tr, writefilecopymeta,
                 )
                 if is_touched:
-                    touched.append(f)
                     if is_touched == 'added':
-                        filesadded.append(f)
+                        files.mark_added(f)
+                    else:
+                        files.mark_touched(f)
                 m.setflag(f, fctx.flags())
         except OSError:
             repo.ui.warn(_(b"trouble committing %s!\n") % uipathfn(f))
@@ -191,7 +192,6 @@  def _process_files(tr, ctx, error=False)
                 repo.ui.warn(_(b"trouble committing %s!\n") % uipathfn(f))
             raise
 
-    files = metadata.ChangingFiles(touched=touched, added=filesadded)
     # update manifest
     removed = [f for f in removed if f in m1 or f in m2]
     drop = sorted([f for f in removed if f in m])