Fix status on files in included subdirs

Summary:
There was a bug where if you included 'dir1/dir2/' in your sparse checkout, then
status would not show newly added files in that directory. The problem is that
dir1 is considered ignored, so the status walker would not walk down dir1.

The fix is to explicitly match subdirectories of specified include patterns.

Test Plan: Added a test

Reviewers: pyd, rmcelroy, lcharignon, sid0

Reviewed By: sid0

Differential Revision: https://phabricator.fb.com/D2021037

Tasks: 6773875

Signature: t1:2021037:1429899282:3e305afa9ed395473dbe11d80abc43becb9eaa4a
This commit is contained in:
Durham Goode 2015-04-24 09:52:00 -07:00
parent 3bc673a16b
commit 5cd2a69ed5
2 changed files with 22 additions and 2 deletions

View File

@ -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

View File

@ -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