changeset 38277:aaed058a0390

context: make workingctx.matches() filter our removed files (API) It seems surprising that workingctx.matches() includes files that had been removed in the working copy. The callers don't want that either (besides the `hg locate` that was changed in the previous patch). The only observable difference that I'm aware of is that `hg log -T 'wdir()' -r '{files(...)}'` will no longer include removed files (an improvement, IMO). That matches `hg files` (but does not match the deprecated `hg locate`). Differential Revision: https://phab.mercurial-scm.org/D3711
author Martin von Zweigbergk <martinvonz@google.com>
date Mon, 11 Jun 2018 10:05:23 -0700
parents fa4a286410a5
children 0c7970d4e6b4
files mercurial/context.py tests/test-command-template.t
diffstat 2 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/context.py	Mon Jun 11 09:47:07 2018 -0700
+++ b/mercurial/context.py	Mon Jun 11 10:05:23 2018 -0700
@@ -1227,7 +1227,8 @@
                                                unknown=True, ignored=False))
 
     def matches(self, match):
-        return sorted(self._repo.dirstate.matches(match))
+        ds = self._repo.dirstate
+        return sorted(f for f in ds.matches(match) if ds[f] != 'r')
 
     def ancestors(self):
         for p in self._parents:
--- a/tests/test-command-template.t	Mon Jun 11 09:47:07 2018 -0700
+++ b/tests/test-command-template.t	Mon Jun 11 10:05:23 2018 -0700
@@ -4344,6 +4344,12 @@
   
   0
   
+  $ hg rm a
+  $ hg log -r "wdir()" -T "{rev}\n{join(files('*'), '\n')}\n"
+  2147483647
+  aa
+  b
+  $ hg revert a
 
 Test relpath function