commitctx: treat `filesadded` more like `filesremoved`
authorPierre-Yves David <pierre-yves.david@octobus.net>
Thu, 23 Jul 2020 23:08:00 +0200
changeset 45235 b65b4b09859c
parent 45234 595307e14140
child 45236 0c468fef09b3
commitctx: treat `filesadded` more like `filesremoved` Accumulating the filename in a list will have a negligible cost and deal with the list of added files like the other ones will make is code cleaning simpler. The two variable with very close name is not great, but my plan is to split most of the code in a separated function which will make the "problem" go away by itself.
mercurial/commit.py
--- a/mercurial/commit.py	Thu Jul 23 22:58:29 2020 +0200
+++ b/mercurial/commit.py	Thu Jul 23 23:08:00 2020 +0200
@@ -94,7 +94,7 @@
 
             # check in files
             added = []
-            filesadded = []
+            files_added = []
             removed = list(ctx.removed())
             touched = []
             linkrev = len(repo)
@@ -113,8 +113,8 @@
                         )
                         if is_touched:
                             touched.append(f)
-                            if writechangesetcopy and is_touched == 'added':
-                                filesadded.append(f)
+                            if is_touched == 'added':
+                                files_added.append(f)
                         m.setflag(f, fctx.flags())
                 except OSError:
                     repo.ui.warn(_(b"trouble committing %s!\n") % uipathfn(f))
@@ -143,6 +143,7 @@
 
             if writechangesetcopy:
                 filesremoved = removed
+                filesadded = files_added
 
         if not writefilecopymeta:
             # If writing only to changeset extras, use None to indicate that