Patchwork D3711: context: make workingctx.matches() filter our removed files (API)

login
register
mail settings
Submitter phabricator
Date June 11, 2018, 5:39 p.m.
Message ID <differential-rev-PHID-DREV-67qzmpcjswwtq2mpwttn-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/32061/
State Superseded
Headers show

Comments

phabricator - June 11, 2018, 5:39 p.m.
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  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`).

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/context.py
  tests/test-command-template.t

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel
Yuya Nishihara - June 12, 2018, 12:05 p.m.
>   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`).

Queued the series, thanks.

FWIW, `ctx.matches()` vs `ctx.walk()` is one of the most obscure API I can't
say what is the right behavior. :-)
phabricator - June 12, 2018, 12:06 p.m.
yuja added a comment.


  >   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`).
  
  Queued the series, thanks.
  
  FWIW, `ctx.matches()` vs `ctx.walk()` is one of the most obscure API I can't
  say what is the right behavior. :-)

REPOSITORY
  rHG Mercurial

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

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

Patch

diff --git a/tests/test-command-template.t b/tests/test-command-template.t
--- a/tests/test-command-template.t
+++ b/tests/test-command-template.t
@@ -4289,6 +4289,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
 
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -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: