# HG changeset patch # User Pierre-Yves David # Date 2020-10-13 01:23:17 # Node ID 232c88dd89e3a42613c5fe13030bcdf83750a520 # Parent d4c4391aa7f26c8a5c329330f14ab339a34b9130 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 diff --git a/mercurial/changelog.py b/mercurial/changelog.py --- a/mercurial/changelog.py +++ b/mercurial/changelog.py @@ -583,13 +583,7 @@ class changelog(revlog.revlog): 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) diff --git a/mercurial/metadata.py b/mercurial/metadata.py --- a/mercurial/metadata.py +++ b/mercurial/metadata.py @@ -75,6 +75,16 @@ class ChangingFiles(object): 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