116 'Source': '{root}/{file},v', |
116 'Source': '{root}/{file},v', |
117 'Id': '{file|basename},v {node|short} {date|utcdate} {author|user}', |
117 'Id': '{file|basename},v {node|short} {date|utcdate} {author|user}', |
118 'Header': '{root}/{file},v {node|short} {date|utcdate} {author|user}', |
118 'Header': '{root}/{file},v {node|short} {date|utcdate} {author|user}', |
119 } |
119 } |
120 |
120 |
121 def __init__(self, ui, repo, inc, exc, restricted): |
121 def __init__(self, ui, repo, inc, exc, restrict): |
122 self.ui = ui |
122 self.ui = ui |
123 self.repo = repo |
123 self.repo = repo |
124 self.matcher = util.matcher(repo.root, inc=inc, exc=exc)[1] |
124 self.matcher = util.matcher(repo.root, inc=inc, exc=exc)[1] |
125 self.restricted = restricted |
125 self.restrict = restrict |
126 self.commitnode = None |
126 self.commitnode = None |
127 self.path = '' |
127 self.path = '' |
128 |
128 |
129 kwmaps = self.ui.configitems('keywordmaps') |
129 kwmaps = self.ui.configitems('keywordmaps') |
130 if kwmaps: # override default templates |
130 if kwmaps: # override default templates |
159 |
159 |
160 return subfunc(kwsub, data) |
160 return subfunc(kwsub, data) |
161 |
161 |
162 def expand(self, node, data): |
162 def expand(self, node, data): |
163 '''Returns data with keywords expanded.''' |
163 '''Returns data with keywords expanded.''' |
164 if self.restricted or util.binary(data): |
164 if self.restrict or util.binary(data): |
165 return data |
165 return data |
166 return self.substitute(node, data, self.re_kw.sub) |
166 return self.substitute(node, data, self.re_kw.sub) |
167 |
167 |
168 def process(self, node, data, expand): |
168 def process(self, node, data, expand): |
169 '''Returns a tuple: data, count. |
169 '''Returns a tuple: data, count. |
436 exc.append(pat) |
436 exc.append(pat) |
437 if not inc: |
437 if not inc: |
438 return |
438 return |
439 |
439 |
440 global _kwtemplater |
440 global _kwtemplater |
441 _restricted = hgcmd in restricted.split() |
441 restrict = hgcmd in restricted.split() |
442 _kwtemplater = kwtemplater(ui, repo, inc, exc, _restricted) |
442 _kwtemplater = kwtemplater(ui, repo, inc, exc, restrict) |
443 |
443 |
444 class kwrepo(repo.__class__): |
444 class kwrepo(repo.__class__): |
445 def file(self, f, kwmatch=False): |
445 def file(self, f, kwmatch=False): |
446 if f[0] == '/': |
446 if f[0] == '/': |
447 f = f[1:] |
447 f = f[1:] |
449 return kwfilelog(self.sopener, f) |
449 return kwfilelog(self.sopener, f) |
450 return filelog.filelog(self.sopener, f) |
450 return filelog.filelog(self.sopener, f) |
451 |
451 |
452 def wread(self, filename): |
452 def wread(self, filename): |
453 data = super(kwrepo, self).wread(filename) |
453 data = super(kwrepo, self).wread(filename) |
454 if _restricted and _kwtemplater.matcher(filename): |
454 if restrict and _kwtemplater.matcher(filename): |
455 return _kwtemplater.shrink(data) |
455 return _kwtemplater.shrink(data) |
456 return data |
456 return data |
457 |
457 |
458 def commit(self, files=None, text='', user=None, date=None, |
458 def commit(self, files=None, text='', user=None, date=None, |
459 match=util.always, force=False, force_editor=False, |
459 match=util.always, force=False, force_editor=False, |