Patchwork [4,of,5] copies: do not initialize the dictionary with root in changeset copies

login
register
mail settings
Submitter Pierre-Yves David
Date Dec. 2, 2019, 11:28 a.m.
Message ID <3348c01c4f299189d5f3.1575286099@nodosa.octobus.net>
Download mbox | patch
Permalink /patch/43558/
State Accepted
Headers show

Comments

Pierre-Yves David - Dec. 2, 2019, 11:28 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1573634384 -3600
#      Wed Nov 13 09:39:44 2019 +0100
# Node ID 3348c01c4f299189d5f3ad208cea1bc635a57766
# Parent  aecdfe3c798f29670f341d88c7a4b7e2289500e9
# EXP-Topic patch-copies-rust-prep
# Available At https://dev.heptapod.net/octobus/mercurial-devel/
#              hg pull https://dev.heptapod.net/octobus/mercurial-devel/ -r 3348c01c4f29
copies: do not initialize the dictionary with root in changeset copies

We don't strictly need the dict to be prefiled with `{}`. Not doing so will make
the next changeset simpler. This part of a preparation to use native code for
this part of copy tracing.

Patch

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -281,10 +281,13 @@  def _changesetforwardcopies(a, b, match)
     iterrevs &= mrset
     iterrevs.update(roots)
     iterrevs.remove(b.rev())
-    all_copies = {r: {} for r in roots}
+    all_copies = {}
     alwaysmatch = match.always()
     for r in sorted(iterrevs):
-        copies = all_copies.pop(r)
+        copies = all_copies.pop(r, None)
+        if copies is None:
+            # this is a root
+            copies = {}
         for i, c in enumerate(children[r]):
             p1, p2, p1copies, p2copies, removed = revinfo(c)
             if r == p1: