commitctx: directly update the touched and added set of files
authorPierre-Yves David <pierre-yves.david@octobus.net>
Tue, 28 Jul 2020 20:21:06 +0200
changeset 45332 54eeb1a0e325
parent 45331 027f3dd76302
child 45333 f569ca3eb430
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.
mercurial/commit.py
--- a/mercurial/commit.py	Tue Jul 28 20:19:09 2020 +0200
+++ b/mercurial/commit.py	Tue Jul 28 20:21:06 2020 +0200
@@ -158,11 +158,11 @@
     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 @@
                     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 @@
                 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])