changing-files: add a shorthand property to check for copy relevant info
We are going to reuse this change in more place, so we factor it out first.
Differential Revision: https://phab.mercurial-scm.org/D9197
--- a/mercurial/changelog.py Wed Oct 14 17:51:56 2020 +0200
+++ b/mercurial/changelog.py Tue Oct 13 03:23:17 2020 +0200
@@ -583,13 +583,7 @@
flags = 0
sidedata = None
if self._copiesstorage == b'changeset-sidedata':
- if (
- files.removed
- or files.merged
- or files.salvaged
- or files.copied_from_p1
- or files.copied_from_p2
- ):
+ if files.has_copies_info:
flags |= flagutil.REVIDX_HASCOPIESINFO
sidedata = metadata.encode_files_sidedata(files)
--- a/mercurial/metadata.py Wed Oct 14 17:51:56 2020 +0200
+++ b/mercurial/metadata.py Tue Oct 13 03:23:17 2020 +0200
@@ -75,6 +75,16 @@
and self.copied_from_p2 == other.copied_from_p2
)
+ @property
+ def has_copies_info(self):
+ return bool(
+ self.removed
+ or self.merged
+ or self.salvaged
+ or self.copied_from_p1
+ or self.copied_from_p2
+ )
+
@util.propertycache
def added(self):
"""files actively added in the changeset