Mercurial > hg-stable
changeset 45626:d31483377673
changing-files: cache the various property
We are going to start using them more having some basic caching would be good.
The focus is not about performance yet, however avoid some easy N² trap seems
reasonable.
Differential Revision: https://phab.mercurial-scm.org/D9112
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 28 Sep 2020 12:26:09 +0200 |
parents | 42bb6c4f8106 |
children | fb000408bca5 |
files | mercurial/metadata.py |
diffstat | 1 files changed, 18 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/metadata.py Fri Sep 25 14:16:35 2020 +0200 +++ b/mercurial/metadata.py Mon Sep 28 12:26:09 2020 +0200 @@ -69,7 +69,7 @@ and self.copied_from_p2 == other.copied_from_p2 ) - @property + @util.propertycache def added(self): """files actively added in the changeset @@ -83,6 +83,8 @@ return frozenset(self._added) def mark_added(self, filename): + if 'added' in vars(self): + del self.added self._added.add(filename) self.mark_touched(filename) @@ -90,7 +92,7 @@ for f in filenames: self.mark_added(f) - @property + @util.propertycache def merged(self): """files actively merged during a merge @@ -101,6 +103,8 @@ return frozenset(self._merged) def mark_merged(self, filename): + if 'merged' in vars(self): + del self.merged self._merged.add(filename) self.mark_touched(filename) @@ -108,7 +112,7 @@ for f in filenames: self.mark_merged(f) - @property + @util.propertycache def removed(self): """files actively removed by the changeset @@ -145,6 +149,8 @@ return frozenset(self._removed) def mark_removed(self, filename): + if 'removed' in vars(self): + del self.removed self._removed.add(filename) self.mark_touched(filename) @@ -152,34 +158,40 @@ for f in filenames: self.mark_removed(f) - @property + @util.propertycache def touched(self): """files either actively modified, added or removed""" return frozenset(self._touched) def mark_touched(self, filename): + if 'touched' in vars(self): + del self.touched self._touched.add(filename) def update_touched(self, filenames): for f in filenames: self.mark_touched(f) - @property + @util.propertycache def copied_from_p1(self): return self._p1_copies.copy() def mark_copied_from_p1(self, source, dest): + if 'copied_from_p1' in vars(self): + del self.copied_from_p1 self._p1_copies[dest] = source def update_copies_from_p1(self, copies): for dest, source in copies.items(): self.mark_copied_from_p1(source, dest) - @property + @util.propertycache def copied_from_p2(self): return self._p2_copies.copy() def mark_copied_from_p2(self, source, dest): + if 'copied_from_p2' in vars(self): + del self.copied_from_p2 self._p2_copies[dest] = source def update_copies_from_p2(self, copies):