310 self._eolmatch = self.loadeol([None, 'tip']) |
310 self._eolmatch = self.loadeol([None, 'tip']) |
311 if not self._eolmatch: |
311 if not self._eolmatch: |
312 self._eolmatch = util.never |
312 self._eolmatch = util.never |
313 return |
313 return |
314 |
314 |
|
315 oldeol = None |
315 try: |
316 try: |
316 cachemtime = os.path.getmtime(self.join("eol.cache")) |
317 cachemtime = os.path.getmtime(self.join("eol.cache")) |
317 except OSError: |
318 except OSError: |
318 cachemtime = 0 |
319 cachemtime = 0 |
|
320 else: |
|
321 olddata = self.vfs.read("eol.cache") |
|
322 if olddata: |
|
323 oldeol = eolfile(self.ui, self.root, olddata) |
319 |
324 |
320 try: |
325 try: |
321 eolmtime = os.path.getmtime(self.wjoin(".hgeol")) |
326 eolmtime = os.path.getmtime(self.wjoin(".hgeol")) |
322 except OSError: |
327 except OSError: |
323 eolmtime = 0 |
328 eolmtime = 0 |
324 |
329 |
325 if eolmtime > cachemtime: |
330 if eolmtime > cachemtime: |
326 self.ui.debug("eol: detected change in .hgeol\n") |
331 self.ui.debug("eol: detected change in .hgeol\n") |
|
332 |
|
333 hgeoldata = self.wvfs.read('.hgeol') |
|
334 neweol = eolfile(self.ui, self.root, hgeoldata) |
|
335 |
327 wlock = None |
336 wlock = None |
328 try: |
337 try: |
329 wlock = self.wlock() |
338 wlock = self.wlock() |
330 for f in self.dirstate: |
339 for f in self.dirstate: |
331 if self.dirstate[f] == 'n': |
340 if self.dirstate[f] != 'n': |
332 # all normal files need to be looked at |
341 continue |
333 # again since the new .hgeol file might no |
342 if oldeol is not None: |
334 # longer match a file it matched before |
343 if not oldeol.match(f) and not neweol.match(f): |
335 self.dirstate.normallookup(f) |
344 continue |
336 # Create or touch the cache to update mtime |
345 oldkey = None |
337 self.vfs("eol.cache", "w").close() |
346 for pattern, key, m in oldeol.patterns: |
|
347 if m(f): |
|
348 oldkey = key |
|
349 break |
|
350 newkey = None |
|
351 for pattern, key, m in neweol.patterns: |
|
352 if m(f): |
|
353 newkey = key |
|
354 break |
|
355 if oldkey == newkey: |
|
356 continue |
|
357 # all normal files need to be looked at again since |
|
358 # the new .hgeol file specify a different filter |
|
359 self.dirstate.normallookup(f) |
|
360 # Write the cache to update mtime and cache .hgeol |
|
361 with self.vfs("eol.cache", "w") as f: |
|
362 f.write(hgeoldata) |
338 wlock.release() |
363 wlock.release() |
339 except error.LockUnavailable: |
364 except error.LockUnavailable: |
340 # If we cannot lock the repository and clear the |
365 # If we cannot lock the repository and clear the |
341 # dirstate, then a commit might not see all files |
366 # dirstate, then a commit might not see all files |
342 # as modified. But if we cannot lock the |
367 # as modified. But if we cannot lock the |