Show More
@@ -117,8 +117,7 b' class localrepository(repo.repository):' | |||||
117 | self.tagscache = None |
|
117 | self.tagscache = None | |
118 | self.branchcache = None |
|
118 | self.branchcache = None | |
119 | self.nodetagscache = None |
|
119 | self.nodetagscache = None | |
120 |
self. |
|
120 | self.filterpats = {} | |
121 | self.decodepats = None |
|
|||
122 | self.transhandle = None |
|
121 | self.transhandle = None | |
123 |
|
122 | |||
124 | self._link = lambda x: False |
|
123 | self._link = lambda x: False | |
@@ -483,20 +482,15 b' class localrepository(repo.repository):' | |||||
483 | def wfile(self, f, mode='r'): |
|
482 | def wfile(self, f, mode='r'): | |
484 | return self.wopener(f, mode) |
|
483 | return self.wopener(f, mode) | |
485 |
|
484 | |||
486 |
def |
|
485 | def _filter(self, filter, filename, data): | |
487 | if self.encodepats == None: |
|
486 | if filter not in self.filterpats: | |
488 | l = [] |
|
487 | l = [] | |
489 |
for pat, cmd in self.ui.configitems( |
|
488 | for pat, cmd in self.ui.configitems(filter): | |
490 | mf = util.matcher(self.root, "", [pat], [], [])[1] |
|
489 | mf = util.matcher(self.root, "", [pat], [], [])[1] | |
491 | l.append((mf, cmd)) |
|
490 | l.append((mf, cmd)) | |
492 |
self. |
|
491 | self.filterpats[filter] = l | |
493 |
|
492 | |||
494 | if self._link(filename): |
|
493 | for mf, cmd in self.filterpats[filter]: | |
495 | data = os.readlink(self.wjoin(filename)) |
|
|||
496 | else: |
|
|||
497 | data = self.wopener(filename, 'r').read() |
|
|||
498 |
|
||||
499 | for mf, cmd in self.encodepats: |
|
|||
500 | if mf(filename): |
|
494 | if mf(filename): | |
501 | self.ui.debug(_("filtering %s through %s\n") % (filename, cmd)) |
|
495 | self.ui.debug(_("filtering %s through %s\n") % (filename, cmd)) | |
502 | data = util.filter(data, cmd) |
|
496 | data = util.filter(data, cmd) | |
@@ -504,20 +498,15 b' class localrepository(repo.repository):' | |||||
504 |
|
498 | |||
505 | return data |
|
499 | return data | |
506 |
|
500 | |||
|
501 | def wread(self, filename): | |||
|
502 | if self._link(filename): | |||
|
503 | data = os.readlink(self.wjoin(filename)) | |||
|
504 | else: | |||
|
505 | data = self.wopener(filename, 'r').read() | |||
|
506 | return self._filter("encode", filename, data) | |||
|
507 | ||||
507 | def wwrite(self, filename, data, fd=None): |
|
508 | def wwrite(self, filename, data, fd=None): | |
508 | if self.decodepats == None: |
|
509 | data = self._filter("decode", filename, data) | |
509 | l = [] |
|
|||
510 | for pat, cmd in self.ui.configitems("decode"): |
|
|||
511 | mf = util.matcher(self.root, "", [pat], [], [])[1] |
|
|||
512 | l.append((mf, cmd)) |
|
|||
513 | self.decodepats = l |
|
|||
514 |
|
||||
515 | for mf, cmd in self.decodepats: |
|
|||
516 | if mf(filename): |
|
|||
517 | self.ui.debug(_("filtering %s through %s\n") % (filename, cmd)) |
|
|||
518 | data = util.filter(data, cmd) |
|
|||
519 | break |
|
|||
520 |
|
||||
521 | if fd: |
|
510 | if fd: | |
522 | return fd.write(data) |
|
511 | return fd.write(data) | |
523 | return self.wopener(filename, 'w').write(data) |
|
512 | return self.wopener(filename, 'w').write(data) |
General Comments 0
You need to be logged in to leave comments.
Login now