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

login
register
mail settings
Submitter phabricator
Date May 25, 2019, 10:54 p.m.
Message ID <0c5e7dd3ceb568588f08398bf91079da@localhost.localdomain>
Download mbox | patch
Permalink /patch/40240/
State Not Applicable
Headers show

Comments

phabricator - May 25, 2019, 10:54 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG65fa61ca20af: context: add ctx.files{modified,added,removed}() methods (authored by martinvonz, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D6367?vs=15151&id=15264#toc

REPOSITORY
  rHG Mercurial

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

REVISION DETAIL
  https://phab.mercurial-scm.org/D6367

AFFECTED FILES
  mercurial/context.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers, pulkit
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.filesadded())
+        modified.difference_update(self.filesremoved())
+        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')
@@ -1170,6 +1188,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):