139 'Source': '{root}/{file},v', |
139 'Source': '{root}/{file},v', |
140 'Id': '{file|basename},v {node|short} {date|utcdate} {author|user}', |
140 'Id': '{file|basename},v {node|short} {date|utcdate} {author|user}', |
141 'Header': '{root}/{file},v {node|short} {date|utcdate} {author|user}', |
141 'Header': '{root}/{file},v {node|short} {date|utcdate} {author|user}', |
142 } |
142 } |
143 |
143 |
144 def __init__(self, ui, repo, inc, exc, restrict): |
144 def __init__(self, ui, repo, inc, exc, hgcmd): |
145 self.ui = ui |
145 self.ui = ui |
146 self.repo = repo |
146 self.repo = repo |
147 self.matcher = util.matcher(repo.root, inc=inc, exc=exc)[1] |
147 self.matcher = util.matcher(repo.root, inc=inc, exc=exc)[1] |
148 self.restrict = restrict |
148 self.restrict = hgcmd in restricted.split() |
149 self.commitnode = None |
149 self.commitnode = None |
150 self.path = '' |
150 self.path = '' |
151 |
151 |
152 kwmaps = self.ui.configitems('keywordmaps') |
152 kwmaps = self.ui.configitems('keywordmaps') |
153 if kwmaps: # override default templates |
153 if kwmaps: # override default templates |
449 return |
449 return |
450 # shrink if rev is not current node |
450 # shrink if rev is not current node |
451 if node1 is not None and node1 != repo.changectx().node(): |
451 if node1 is not None and node1 != repo.changectx().node(): |
452 hgcmd = 'diff1' |
452 hgcmd = 'diff1' |
453 |
453 |
454 restrict = hgcmd in restricted.split() |
454 _kwtemplater = kwtemplater(ui, repo, inc, exc, hgcmd) |
455 _kwtemplater = kwtemplater(ui, repo, inc, exc, restrict) |
|
456 |
455 |
457 class kwrepo(repo.__class__): |
456 class kwrepo(repo.__class__): |
458 def file(self, f, kwmatch=False): |
457 def file(self, f, kwmatch=False): |
459 if f[0] == '/': |
458 if f[0] == '/': |
460 f = f[1:] |
459 f = f[1:] |
462 return kwfilelog(self.sopener, f) |
461 return kwfilelog(self.sopener, f) |
463 return filelog.filelog(self.sopener, f) |
462 return filelog.filelog(self.sopener, f) |
464 |
463 |
465 def wread(self, filename): |
464 def wread(self, filename): |
466 data = super(kwrepo, self).wread(filename) |
465 data = super(kwrepo, self).wread(filename) |
467 if restrict and _kwtemplater.matcher(filename): |
466 if _kwtemplater.restrict and _kwtemplater.matcher(filename): |
468 return _kwtemplater.shrink(data) |
467 return _kwtemplater.shrink(data) |
469 return data |
468 return data |
470 |
469 |
471 def commit(self, files=None, text='', user=None, date=None, |
470 def commit(self, files=None, text='', user=None, date=None, |
472 match=util.always, force=False, force_editor=False, |
471 match=util.always, force=False, force_editor=False, |