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

login
register
mail settings
Submitter phabricator
Date May 14, 2019, 10:58 p.m.
Message ID <94e97a329401eed0e2b7e26eb9d07dc4@localhost.localdomain>
Download mbox | patch
Permalink /patch/40027/
State Not Applicable
Headers show

Comments

phabricator - May 14, 2019, 10:58 p.m.
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




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

Patch

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):