Patchwork [09,of,15] commitctx: directly gather p1 and p2 copies in `files`

login
register
mail settings
Submitter Pierre-Yves David
Date July 29, 2020, 4:57 p.m.
Message ID <520fbac6d2d2ac49604b.1596041859@nodosa.octobus.net>
Download mbox | patch
Permalink /patch/46931/
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 1595686058 -7200
#      Sat Jul 25 16:07:38 2020 +0200
# Node ID 520fbac6d2d2ac49604bd408c0e64c13355ff6dd
# Parent  72d5e455f4d09cf58d1094120a6528a8591e614b
# EXP-Topic files-change
# Available At https://foss.heptapod.net/octobus/mercurial-devel/
#              hg pull https://foss.heptapod.net/octobus/mercurial-devel/ -r 520fbac6d2d2
commitctx: directly gather p1 and p2 copies in `files`

The only thing we do with the p1copies and p2copies is to pass them around, we
we can gather them later and directly stored them in the `ChangingFiles` object.

Patch

diff --git a/mercurial/commit.py b/mercurial/commit.py
--- a/mercurial/commit.py
+++ b/mercurial/commit.py
@@ -115,10 +115,6 @@  def _prepare_files(tr, ctx, error=False,
 
     writechangesetcopy, writefilecopymeta = _write_copy_meta(repo)
 
-    p1copies, p2copies = None, None
-    if writechangesetcopy:
-        p1copies = ctx.p1copies()
-        p2copies = ctx.p2copies()
     filesadded, filesremoved = None, None
     if ctx.manifestnode():
         # reuse an existing manifest revision
@@ -144,10 +140,9 @@  def _prepare_files(tr, ctx, error=False,
     files = metadata.ChangingFiles()
     if touched:
         files.update_touched(touched)
-    if p1copies:
-        files.update_copies_from_p1(p1copies)
-    if p2copies:
-        files.update_copies_from_p2(p2copies)
+    if writechangesetcopy:
+        files.update_copies_from_p1(ctx.p1copies())
+        files.update_copies_from_p2(ctx.p2copies())
     if filesadded:
         files.update_added(filesadded)
     if filesremoved: