diff --git a/mercurial/context.py b/mercurial/context.py
index 3fe500d15e7c68d110f222d4771d549238dbce46_bWVyY3VyaWFsL2NvbnRleHQucHk=..20d0149b8a0a06f2e7a89e13fbba9dfbde7385ec_bWVyY3VyaWFsL2NvbnRleHQucHk= 100644
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -2017,7 +2017,7 @@
     def matches(self, match):
         match = self._repo.narrowmatch(match)
         ds = self._repo.dirstate
-        return sorted(f for f in ds.matches(match) if ds[f] != b'r')
+        return sorted(f for f in ds.matches(match) if ds.get_entry(f).tracked)
 
     def markcommitted(self, node):
         with self._repo.dirstate.parentchange():