Mercurial > hg
comparison mercurial/localrepo.py @ 11698:9df481f8036d
localrepo: refactor filter computation
Separate loading part from access part to be able to tell with:
repo._loadfilter(name)
bool(name in repo.filterpats)
if there is a 'name' filter available.
author | Nicolas Dumazet <nicdumz.commits@gmail.com> |
---|---|
date | Sat, 24 Jul 2010 00:28:20 +0900 |
parents | c47cb3193c53 |
children | eb07fbc21e9c |
comparison
equal
deleted
inserted
replaced
11686:fc360de66217 | 11698:9df481f8036d |
---|---|
508 return self.wopener(f, mode) | 508 return self.wopener(f, mode) |
509 | 509 |
510 def _link(self, f): | 510 def _link(self, f): |
511 return os.path.islink(self.wjoin(f)) | 511 return os.path.islink(self.wjoin(f)) |
512 | 512 |
513 def _filter(self, filter, filename, data): | 513 def _loadfilter(self, filter): |
514 if filter not in self.filterpats: | 514 if filter not in self.filterpats: |
515 l = [] | 515 l = [] |
516 for pat, cmd in self.ui.configitems(filter): | 516 for pat, cmd in self.ui.configitems(filter): |
517 if cmd == '!': | 517 if cmd == '!': |
518 continue | 518 continue |
530 if not inspect.getargspec(fn)[2]: | 530 if not inspect.getargspec(fn)[2]: |
531 oldfn = fn | 531 oldfn = fn |
532 fn = lambda s, c, **kwargs: oldfn(s, c) | 532 fn = lambda s, c, **kwargs: oldfn(s, c) |
533 l.append((mf, fn, params)) | 533 l.append((mf, fn, params)) |
534 self.filterpats[filter] = l | 534 self.filterpats[filter] = l |
535 | |
536 def _filter(self, filter, filename, data): | |
537 self._loadfilter(filter) | |
535 | 538 |
536 for mf, fn, cmd in self.filterpats[filter]: | 539 for mf, fn, cmd in self.filterpats[filter]: |
537 if mf(filename): | 540 if mf(filename): |
538 self.ui.debug("filtering %s through %s\n" % (filename, cmd)) | 541 self.ui.debug("filtering %s through %s\n" % (filename, cmd)) |
539 data = fn(data, cmd, ui=self.ui, repo=self, filename=filename) | 542 data = fn(data, cmd, ui=self.ui, repo=self, filename=filename) |