changeset 2005:bc47af2d3693

On error parsing hgignore file, print the correct filename.
author mcmillen@cs.cmu.edu
date Sat, 25 Mar 2006 10:12:23 +0100
parents 7dd6317ab4fd
children ff8b39daa930
files mercurial/dirstate.py
diffstat 1 files changed, 13 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dirstate.py	Sat Mar 25 10:02:39 2006 +0100
+++ b/mercurial/dirstate.py	Sat Mar 25 10:12:23 2006 +0100
@@ -65,9 +65,10 @@
         repoignore = self.wjoin('.hgignore')
         files = [repoignore]
         files.extend(self.ui.hgignorefiles())
-        pats = []
+        pats = {}
         for f in files:
             try:
+                pats[f] = []
                 fp = open(f)
                 syntax = 'relre:'
                 for line in parselines(fp):
@@ -84,7 +85,7 @@
                         if line.startswith(s):
                             pat = line
                             break
-                    pats.append(pat)
+                    pats[f].append(pat)
             except IOError:
                 if f != repoignore:
                     self.ui.warn(_("ignore file %s not found\n") % f)
@@ -99,13 +100,16 @@
         if not self.ignorefunc:
             ignore = self.hgignore()
             if ignore:
-                # FIXME: if there are errors in patterns, matcher will
-                # print out an error containing src ('.hgignore');
-                # really, we want the original source file to be
-                # printed instead.
-                files, self.ignorefunc, anypats = util.matcher(self.root,
-                                                               inc=ignore,
-                                                               src='.hgignore')
+                try:
+                    allpats = []
+                    [allpats.extend(patlist) for patlist in ignore.values()]
+                    files, self.ignorefunc, anypats = (
+                        util.matcher(self.root, inc=allpats, src='.hgignore'))
+                except util.Abort:
+                    # Re-raise an exception where the src is the right file
+                    for f, patlist in ignore.items():
+                        files, self.ignorefunc, anypats = (
+                            util.matcher(self.root, inc=patlist, src=f))
             else:
                 self.ignorefunc = util.never
         return self.ignorefunc(fn)