D6367: context: add modified(), added(), removed() to changectx too
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Sat May 11 07:18:44 UTC 2019
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
committablectx already has these, so it seems reasonable for changectx
to also have them. I have considered storing these sets in the
changeset extras in order to speed up copy tracing (to unmark a copy
when it's been removed). If we do that, then these functions would be
changed to get the information from the changeset extras. But I think
this patch makes sense whether or not we eventually do that.
Note that these are different from than {file_mods}, {file_adds}, and
{file_dels} on merge commits. I think those template keywords always
compare to p1. See https://bz.mercurial-scm.org/show_bug.cgi?id=4292
for some discussion.
Not optimized because they're not meant to be used generally used.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D6367
AFFECTED FILES
mercurial/context.py
CHANGE DETAILS
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -439,6 +439,24 @@
return self._changeset.date
def files(self):
return self._changeset.files
+ def modified(self):
+ modified = set(self.files())
+ modified.difference_update(self.added())
+ modified.difference_update(self.removed())
+ return sorted(modified)
+ def added(self):
+ added = []
+ for f in self.files():
+ if not any(f in p for p in self.parents()):
+ added.append(f)
+ return added
+ def removed(self):
+ removed = []
+ for f in self.files():
+ if f not in self:
+ removed.append(f)
+ return removed
+
@propertycache
def _copies(self):
source = self._repo.ui.config('experimental', 'copies.read-from')
To: martinvonz, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list