diff --git a/sparse.py b/sparse.py index f94a79a55c..95853feeb3 100644 --- a/sparse.py +++ b/sparse.py @@ -368,9 +368,21 @@ def _wraprepo(ui, repo): includes, excludes, profiles = self.getsparsepatterns(rev) if includes or excludes: - matchers.append(matchmod.match(self.root, '', [], + # Explicitly include subdirectories of includes so + # status will walk them down to the actual include. + subdirs = set() + for include in includes: + dirname = os.path.dirname(include) + while dirname: + subdirs.add(dirname) + dirname = os.path.dirname(dirname) + + matcher = matchmod.match(self.root, '', [], include=includes, exclude=excludes, - default='relpath')) + default='relpath') + if subdirs: + matcher = forceincludematcher(matcher, subdirs) + matchers.append(matcher) except IOError: pass diff --git a/tests/test-sparse.t b/tests/test-sparse.t index e2f2a96add..1bd2f5b9a1 100644 --- a/tests/test-sparse.t +++ b/tests/test-sparse.t @@ -233,3 +233,11 @@ Verify log --sparse only shows commits that affect the sparse checkout 2 1 0 (no-eol) $ hg log --sparse -T '{rev} ' 2 0 (no-eol) + +Test status on a file in a subdir + + $ mkdir -p dir1/dir2 + $ touch dir1/dir2/file + $ hg sparse -I dir1/dir2 + $ hg status + ? dir1/dir2/file