diff mercurial/context.py @ 42142:5382d8f8530b

changelog: parse copy metadata if available in extras This lets read back the copy metadata we just started writing. There are still many places left to teach about getting the copy information from the changeset, but we have enough ({file_copies}, specifically) that we can add it now and have some test coverage of it. Differential Revision: https://phab.mercurial-scm.org/D6186
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 27 Dec 2017 22:05:20 -0800
parents 976f069e0ad6
children 14589f1989e9
line wrap: on
line diff
--- a/mercurial/context.py	Wed Dec 27 19:49:36 2017 -0800
+++ b/mercurial/context.py	Wed Dec 27 22:05:20 2017 -0800
@@ -441,6 +441,21 @@
         return self._changeset.files
     @propertycache
     def _copies(self):
+        source = self._repo.ui.config('experimental', 'copies.read-from')
+        p1copies = self._changeset.p1copies
+        p2copies = self._changeset.p2copies
+        # If config says to get copy metadata only from changeset, then return
+        # that, defaulting to {} if there was no copy metadata.
+        # 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.
         p1copies = {}
         p2copies = {}
         p1 = self.p1()