##// END OF EJS Templates
eol: store and reuse pattern matchers instead of creating in tight loop...
Mads Kiilerich -
r30114:ad43458d default
parent child Browse files
Show More
@@ -175,25 +175,27 b' class eolfile(object):'
175 175
176 176 include = []
177 177 exclude = []
178 self.patterns = []
178 179 for pattern, style in self.cfg.items('patterns'):
179 180 key = style.upper()
180 181 if key == 'BIN':
181 182 exclude.append(pattern)
182 183 else:
183 184 include.append(pattern)
185 m = match.match(root, '', [pattern])
186 self.patterns.append((pattern, key, m))
184 187 # This will match the files for which we need to care
185 188 # about inconsistent newlines.
186 189 self.match = match.match(root, '', [], include, exclude)
187 190
188 191 def copytoui(self, ui):
189 for pattern, style in self.cfg.items('patterns'):
190 key = style.upper()
192 for pattern, key, m in self.patterns:
191 193 try:
192 194 ui.setconfig('decode', pattern, self._decode[key], 'eol')
193 195 ui.setconfig('encode', pattern, self._encode[key], 'eol')
194 196 except KeyError:
195 197 ui.warn(_("ignoring unknown EOL style '%s' from %s\n")
196 % (style, self.cfg.source('patterns', pattern)))
198 % (key, self.cfg.source('patterns', pattern)))
197 199 # eol.only-consistent can be specified in ~/.hgrc or .hgeol
198 200 for k, v in self.cfg.items('eol'):
199 201 ui.setconfig('eol', k, v, 'eol')
@@ -203,10 +205,10 b' class eolfile(object):'
203 205 for f in (files or ctx.files()):
204 206 if f not in ctx:
205 207 continue
206 for pattern, style in self.cfg.items('patterns'):
207 if not match.match(repo.root, '', [pattern])(f):
208 for pattern, key, m in self.patterns:
209 if not m(f):
208 210 continue
209 target = self._encode[style.upper()]
211 target = self._encode[key]
210 212 data = ctx[f].data()
211 213 if (target == "to-lf" and "\r\n" in data
212 214 or target == "to-crlf" and singlelf.search(data)):
General Comments 0
You need to be logged in to leave comments. Login now