D6367: context: add ctx.files{modified,added,removed}() methods

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Tue May 14 18:58:40 EDT 2019


martinvonz updated this revision to Diff 15079.
martinvonz retitled this revision from "context: add modified(), added(), removed() to changectx too" to "context: add ctx.files{modified,added,removed}() methods".
martinvonz edited the summary of this revision.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6367?vs=15061&id=15079

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
@@ -463,6 +463,24 @@
         return self._changeset.date
     def files(self):
         return self._changeset.files
+    def filesmodified(self):
+        modified = set(self.files())
+        modified.difference_update(self.added())
+        modified.difference_update(self.removed())
+        return sorted(modified)
+    def filesadded(self):
+        added = []
+        for f in self.files():
+            if not any(f in p for p in self.parents()):
+                added.append(f)
+        return added
+    def filesremoved(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')
@@ -1176,6 +1194,10 @@
         return self._status.removed
     def deleted(self):
         return self._status.deleted
+    filesmodified = modified
+    filesadded = added
+    filesremoved = removed
+
     def branch(self):
         return encoding.tolocal(self._extra['branch'])
     def closesbranch(self):



To: martinvonz, #hg-reviewers
Cc: yuja, mercurial-devel


More information about the Mercurial-devel mailing list