diff --git a/mercurial/sparse.py b/mercurial/sparse.py --- a/mercurial/sparse.py +++ b/mercurial/sparse.py @@ -294,24 +294,9 @@ def matcher(repo, revs=None, includetemp includes, excludes, profiles = patternsforrev(repo, rev) if includes or excludes: - # Explicitly include subdirectories of includes so - # status will walk them down to the actual include. - subdirs = set() - for include in includes: - # TODO consider using posix path functions here so Windows - # \ directory separators don't come into play. - dirname = os.path.dirname(include) - # basename is used to avoid issues with absolute - # paths (which on Windows can include the drive). - while os.path.basename(dirname): - subdirs.add(dirname) - dirname = os.path.dirname(dirname) - matcher = matchmod.match(repo.root, '', [], include=includes, exclude=excludes, 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 --- a/tests/test-sparse.t +++ b/tests/test-sparse.t @@ -284,6 +284,27 @@ Test status on a file in a subdir $ hg status ? dir1/dir2/file +Mix files and subdirectories, both "glob:" and unprefixed + + $ hg debugsparse --reset + $ touch dir1/notshown + $ hg commit -A dir1/notshown -m "notshown" + $ hg debugsparse --include 'dir1/dir2' + $ $PYTHON $TESTDIR/list-tree.py . | grep -v ./.hg + ./ + ./dir1/ + ./dir1/dir2/ + ./dir1/dir2/file + ./hide.orig + $ hg debugsparse --delete 'dir1/dir2' + $ hg debugsparse --include 'glob:dir1/dir2' + $ $PYTHON $TESTDIR/list-tree.py . | grep -v ./.hg + ./ + ./dir1/ + ./dir1/dir2/ + ./dir1/dir2/file + ./hide.orig + Test that add -s adds dirs to sparse profile $ hg debugsparse --reset