# HG changeset patch # User Durham Goode # Date 1437781492 25200 # Node ID 3de48ff627338a8abab1efc85e2a52add7f90abc # Parent a72e304df528c1ff1196399899e29d948d520dc7 ignore: fix include: rules depending on current directory (issue4759) When reading pattern files, we just call open(path), which is relative to the current directory. Let's fix this by resolving the paths before attempting to read the file. diff -r a72e304df528 -r 3de48ff62733 mercurial/match.py --- a/mercurial/match.py Fri Jul 24 16:43:21 2015 -0700 +++ b/mercurial/match.py Fri Jul 24 16:44:52 2015 -0700 @@ -289,7 +289,8 @@ continue elif kind == 'include': try: - includepats = readpatternfile(pat, self._warn) + fullpath = pathutil.join(root, pat) + includepats = readpatternfile(fullpath, self._warn) for k, p, source in self._normalize(includepats, default, root, cwd, auditor): kindpats.append((k, p, source or pat)) diff -r a72e304df528 -r 3de48ff62733 tests/test-hgignore.t --- a/tests/test-hgignore.t Fri Jul 24 16:43:21 2015 -0700 +++ b/tests/test-hgignore.t Fri Jul 24 16:44:52 2015 -0700 @@ -186,8 +186,9 @@ Check recursive uses of 'include:' - $ echo "include:nestedignore" >> otherignore - $ echo "glob:*ignore" > nestedignore + $ echo "include:nested/ignore" >> otherignore + $ mkdir nested + $ echo "glob:*ignore" > nested/ignore $ hg status A dir/b.o @@ -199,6 +200,13 @@ $ mv goodignore otherignore +Check using 'include:' while in a non-root directory + + $ cd .. + $ hg -R ignorerepo status + A dir/b.o + $ cd ignorerepo + Check including subincludes $ hg revert -q --all