debugignore: normalize the file before testing dirstate._ignore()

With an ignore pattern containing a '/' and a Windows style path containing '\',
status was properly ignoring the file, but debugignore was stating that it
wasn't ignored.
This commit is contained in:
Matt Harbison 2016-02-08 12:33:00 -05:00
parent 5e089ee084
commit 7d76fe4b73
2 changed files with 20 additions and 6 deletions

View File

@ -2457,20 +2457,21 @@ def debugignore(ui, repo, *files, **opts):
raise error.Abort(_("no ignore patterns found"))
else:
for f in files:
nf = util.normpath(f)
ignored = None
ignoredata = None
if f != '.':
if ignore(f):
ignored = f
ignoredata = repo.dirstate._ignorefileandline(f)
if nf != '.':
if ignore(nf):
ignored = nf
ignoredata = repo.dirstate._ignorefileandline(nf)
else:
for p in util.finddirs(f):
for p in util.finddirs(nf):
if ignore(p):
ignored = p
ignoredata = repo.dirstate._ignorefileandline(p)
break
if ignored:
if ignored == f:
if ignored == nf:
ui.write("%s is ignored\n" % f)
else:
ui.write("%s is ignored because of containing folder %s\n"

View File

@ -286,3 +286,16 @@ Check include subignore at the same level
$ hg debugignore dir1/file2
dir1/file2 is ignored
(ignore rule in dir2/.hgignore, line 1: 'file*2')
#if windows
Windows paths are accepted on input
$ rm dir1/.hgignore
$ echo "dir1/file*" >> .hgignore
$ hg debugignore "dir1\file2"
dir1\file2 is ignored
(ignore rule in $TESTTMP\ignorerepo\.hgignore, line 4: 'dir1/file*')
$ hg up -qC .
#endif