sparse: --include 'dir1/dir2' should not include 'dir1/*'
In 2015 there was a workaround added (
f39bace2d6cad32907c0d7961b3c0dbd64a1b7ad)
to sparse in the hg-experimental repo. That workaround:
a) no longer seems to be needed, since its testcase passes even with the code
removed, and
b) caused a new problem: --include 'dir1/dir2' ended up including dir1/*
too. (--include 'glob:dir1/dir2' is a user-level workaround.)
Remove the offending code, and add a testcase for situation B.
--- a/mercurial/sparse.py Sun Jan 14 13:29:15 2018 +0900
+++ b/mercurial/sparse.py Thu Jan 18 13:33:21 2018 -0800
@@ -294,24 +294,9 @@
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
--- a/tests/test-sparse.t Sun Jan 14 13:29:15 2018 +0900
+++ b/tests/test-sparse.t Thu Jan 18 13:33:21 2018 -0800
@@ -284,6 +284,27 @@
$ 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