Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/dirstate.py @ 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 |
comparison
equal
deleted
inserted
replaced
2004:7dd6317ab4fd | 2005:bc47af2d3693 |
---|---|
63 line = line[:i].rstrip() | 63 line = line[:i].rstrip() |
64 if line: yield line | 64 if line: yield line |
65 repoignore = self.wjoin('.hgignore') | 65 repoignore = self.wjoin('.hgignore') |
66 files = [repoignore] | 66 files = [repoignore] |
67 files.extend(self.ui.hgignorefiles()) | 67 files.extend(self.ui.hgignorefiles()) |
68 pats = [] | 68 pats = {} |
69 for f in files: | 69 for f in files: |
70 try: | 70 try: |
71 pats[f] = [] | |
71 fp = open(f) | 72 fp = open(f) |
72 syntax = 'relre:' | 73 syntax = 'relre:' |
73 for line in parselines(fp): | 74 for line in parselines(fp): |
74 if line.startswith('syntax:'): | 75 if line.startswith('syntax:'): |
75 s = line[7:].strip() | 76 s = line[7:].strip() |
82 pat = syntax + line | 83 pat = syntax + line |
83 for s in syntaxes.values(): | 84 for s in syntaxes.values(): |
84 if line.startswith(s): | 85 if line.startswith(s): |
85 pat = line | 86 pat = line |
86 break | 87 break |
87 pats.append(pat) | 88 pats[f].append(pat) |
88 except IOError: | 89 except IOError: |
89 if f != repoignore: | 90 if f != repoignore: |
90 self.ui.warn(_("ignore file %s not found\n") % f) | 91 self.ui.warn(_("ignore file %s not found\n") % f) |
91 return pats | 92 return pats |
92 | 93 |
97 if self.blockignore: | 98 if self.blockignore: |
98 return False | 99 return False |
99 if not self.ignorefunc: | 100 if not self.ignorefunc: |
100 ignore = self.hgignore() | 101 ignore = self.hgignore() |
101 if ignore: | 102 if ignore: |
102 # FIXME: if there are errors in patterns, matcher will | 103 try: |
103 # print out an error containing src ('.hgignore'); | 104 allpats = [] |
104 # really, we want the original source file to be | 105 [allpats.extend(patlist) for patlist in ignore.values()] |
105 # printed instead. | 106 files, self.ignorefunc, anypats = ( |
106 files, self.ignorefunc, anypats = util.matcher(self.root, | 107 util.matcher(self.root, inc=allpats, src='.hgignore')) |
107 inc=ignore, | 108 except util.Abort: |
108 src='.hgignore') | 109 # Re-raise an exception where the src is the right file |
110 for f, patlist in ignore.items(): | |
111 files, self.ignorefunc, anypats = ( | |
112 util.matcher(self.root, inc=patlist, src=f)) | |
109 else: | 113 else: |
110 self.ignorefunc = util.never | 114 self.ignorefunc = util.never |
111 return self.ignorefunc(fn) | 115 return self.ignorefunc(fn) |
112 | 116 |
113 def __del__(self): | 117 def __del__(self): |