fileset: matchctx.existing() must consider unknown files stable
authorPatrick Mezard <patrick@mezard.eu>
Wed, 15 Aug 2012 22:29:09 +0200
branchstable
changeset 17366 04c65cb59467
parent 17365 8a0513bf030a
child 17367 ce625185cfd9
fileset: matchctx.existing() must consider unknown files By default, unknown files are ignored. If the 'unknown()' predicate appears in the syntax tree, then they are taken in account. Unfortunately, matchctx.existing() was filtering against non-deleted context files, which does not include unknown files. So: $ hg debugfileset 'binary() and unknown()' would not return existing binary unknown files.
mercurial/fileset.py
tests/test-fileset.t
--- a/mercurial/fileset.py	Wed Aug 15 21:44:00 2012 +0200
+++ b/mercurial/fileset.py	Wed Aug 15 22:29:09 2012 +0200
@@ -432,10 +432,12 @@
     def existing(self):
         if self._status is not None:
             removed = set(self._status[3])
+            unknown = set(self._status[4])
         else:
             removed = set()
+            unknown = set()
         return (f for f in self.subset
-                if f in self.ctx and f not in removed)
+                if (f in self.ctx and f not in removed) or f in unknown)
     def narrow(self, files):
         return matchctx(self.ctx, self.filter(files), self._status)
 
--- a/tests/test-fileset.t	Wed Aug 15 21:44:00 2012 +0200
+++ b/tests/test-fileset.t	Wed Aug 15 22:29:09 2012 +0200
@@ -80,4 +80,9 @@
 
   >>> file('bin', 'wb').write('\0a')
   $ fileset 'binary()'
+  $ fileset 'binary() and unknown()'
+  bin
+  $ hg add bin
+  $ fileset 'binary()'
+  bin