Mercurial > hg
comparison mercurial/localrepo.py @ 12708:8a08b12ae88e
localrepo: use propertycaches to access encode/decode filters
author | Nicolas Dumazet <nicdumz.commits@gmail.com> |
---|---|
date | Sun, 10 Oct 2010 18:58:45 +0200 |
parents | 2216ab103ea8 |
children | 18b5b6392fcf |
comparison
equal
deleted
inserted
replaced
12707:2216ab103ea8 | 12708:8a08b12ae88e |
---|---|
595 data = fn(data, cmd, ui=self.ui, repo=self, filename=filename) | 595 data = fn(data, cmd, ui=self.ui, repo=self, filename=filename) |
596 break | 596 break |
597 | 597 |
598 return data | 598 return data |
599 | 599 |
600 @propertycache | |
601 def _encodefilterpats(self): | |
602 return self._loadfilter('encode') | |
603 | |
604 @propertycache | |
605 def _decodefilterpats(self): | |
606 return self._loadfilter('decode') | |
607 | |
600 def adddatafilter(self, name, filter): | 608 def adddatafilter(self, name, filter): |
601 self._datafilters[name] = filter | 609 self._datafilters[name] = filter |
602 | 610 |
603 def wread(self, filename): | 611 def wread(self, filename): |
604 if self._link(filename): | 612 if self._link(filename): |
605 data = os.readlink(self.wjoin(filename)) | 613 data = os.readlink(self.wjoin(filename)) |
606 else: | 614 else: |
607 data = self.wopener(filename, 'r').read() | 615 data = self.wopener(filename, 'r').read() |
608 return self._filter(self._loadfilter("encode"), filename, data) | 616 return self._filter(self._encodefilterpats, filename, data) |
609 | 617 |
610 def wwrite(self, filename, data, flags): | 618 def wwrite(self, filename, data, flags): |
611 data = self._filter(self._loadfilter("decode"), filename, data) | 619 data = self._filter(self._decodefilterpats, filename, data) |
612 try: | 620 try: |
613 os.unlink(self.wjoin(filename)) | 621 os.unlink(self.wjoin(filename)) |
614 except OSError: | 622 except OSError: |
615 pass | 623 pass |
616 if 'l' in flags: | 624 if 'l' in flags: |
619 self.wopener(filename, 'w').write(data) | 627 self.wopener(filename, 'w').write(data) |
620 if 'x' in flags: | 628 if 'x' in flags: |
621 util.set_flags(self.wjoin(filename), False, True) | 629 util.set_flags(self.wjoin(filename), False, True) |
622 | 630 |
623 def wwritedata(self, filename, data): | 631 def wwritedata(self, filename, data): |
624 return self._filter(self._loadfilter("decode"), filename, data) | 632 return self._filter(self._decodefilterpats, filename, data) |
625 | 633 |
626 def transaction(self, desc): | 634 def transaction(self, desc): |
627 tr = self._transref and self._transref() or None | 635 tr = self._transref and self._transref() or None |
628 if tr and tr.running(): | 636 if tr and tr.running(): |
629 return tr.nest() | 637 return tr.nest() |