Patchwork [2,of,2,STABLE] ignore: fix include: rules depending on current directory (issue4759)

login
register
mail settings
Submitter Durham Goode
Date July 24, 2015, 11:59 p.m.
Message ID <ccbdde0d19701d7ed96c.1437782363@dev2000.prn2.facebook.com>
Download mbox | patch
Permalink /patch/10059/
State Accepted
Headers show

Comments

Durham Goode - July 24, 2015, 11:59 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1437781492 25200
#      Fri Jul 24 16:44:52 2015 -0700
# Branch stable
# Node ID ccbdde0d19701d7ed96c8de24c5c181b23ab64f0
# Parent  952b733d64bf8cbb5c0d1e83b3bd6ffb5b811699
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.
Matt Mackall - July 25, 2015, 12:14 a.m.
On Fri, 2015-07-24 at 16:59 -0700, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1437781492 25200
> #      Fri Jul 24 16:44:52 2015 -0700
> # Branch stable
> # Node ID ccbdde0d19701d7ed96c8de24c5c181b23ab64f0
> # Parent  952b733d64bf8cbb5c0d1e83b3bd6ffb5b811699
> ignore: fix include: rules depending on current directory (issue4759)

These are queued for stable, thanks.

Patch

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -289,7 +289,8 @@  class match(object):
                 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 --git a/tests/test-hgignore.t b/tests/test-hgignore.t
--- a/tests/test-hgignore.t
+++ b/tests/test-hgignore.t
@@ -186,8 +186,9 @@  Check using 'include:' in ignore file
 
 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 @@  Check recursive uses of 'include:'
 
   $ 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