changeset 43023:8af909893188

context: clarify the various mode in the _copies property cache The previous code was compact but a bit dense. The new proposed code deal with each mode separately, there are some duplicated lines, but the meaning of each mode stand out. One of the benefit it to make it simpler to add further mode in the future. Differential Revision: https://phab.mercurial-scm.org/D6933
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 27 Sep 2019 00:11:03 +0200
parents 15badd621825
children 188476e48f51
files mercurial/context.py
diffstat 1 files changed, 16 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/context.py	Fri Sep 27 00:09:43 2019 +0200
+++ b/mercurial/context.py	Fri Sep 27 00:11:03 2019 +0200
@@ -490,14 +490,22 @@
         # In compatibility mode, we return copy data from the changeset if
         # it was recorded there, and otherwise we fall back to getting it from
         # the filelogs (below).
-        if (source == 'changeset-only' or
-            (source == 'compatibility' and p1copies is not None)):
-            return p1copies or {}, p2copies or {}
-
-        # Otherwise (config said to read only from filelog, or we are in
-        # compatiblity mode and there is not data in the changeset), we get
-        # the copy metadata from the filelogs.
-        return super(changectx, self)._copies
+        if source == 'changeset-only':
+            if p1copies is None:
+                p1copies = {}
+            if p2copies is None:
+                p2copies = {}
+        elif source == 'compatibility':
+            if p1copies is None:
+                # we are in compatiblity mode and there is not data in the
+                # changeset), we get the copy metadata from the filelogs.
+                p1copies, p2copies = super(changectx, self)._copies
+        else:
+            # config said to read only from filelog, we get the copy metadata
+            # from the filelogs.
+            p1copies, p2copies = super(changectx, self)._copies
+        return p1copies, p2copies
+
     def description(self):
         return self._changeset.description
     def branch(self):