92 for pat, opt in self._repo.ui.configitems('keyword'): |
92 for pat, opt in self._repo.ui.configitems('keyword'): |
93 if opt == 'expand': |
93 if opt == 'expand': |
94 mf = util.matcher(self._repo.root, |
94 mf = util.matcher(self._repo.root, |
95 '', [pat], [], [])[1] |
95 '', [pat], [], [])[1] |
96 if mf(self._path): |
96 if mf(self._path): |
97 def kwexpander(matchobj): |
|
98 return kwexpand(matchobj, self._repo, |
|
99 self._path, fileid=node, filelog=self) |
|
100 re_kw = re.compile(r'\$(%s)\$' % hgkeywords) |
97 re_kw = re.compile(r'\$(%s)\$' % hgkeywords) |
101 return re_kw.sub(kwexpander, data) |
98 return re_kw.sub(lambda m: |
|
99 kwexpand(m, self._repo, self._path, |
|
100 fileid=node, filelog=self), |
|
101 data) |
102 return data |
102 return data |
103 |
103 |
104 def add(self, text, meta, tr, link, p1=None, p2=None): |
104 def add(self, text, meta, tr, link, p1=None, p2=None): |
105 if not util.binary(text): |
105 if not util.binary(text): |
106 re_kw = re.compile(r'\$(%s): [^$]+? \$' % hgkeywords) |
106 re_kw = re.compile(r'\$(%s): [^$]+? \$' % hgkeywords) |
159 re_kw = re.compile(r'\$(%s)(: [^$]+? )?\$' % hgkeywords) |
159 re_kw = re.compile(r'\$(%s)(: [^$]+? )?\$' % hgkeywords) |
160 |
160 |
161 for f in files: |
161 for f in files: |
162 data = repo.wfile(f).read() |
162 data = repo.wfile(f).read() |
163 if not util.binary(data): |
163 if not util.binary(data): |
164 def kwexpander(matchobj): |
164 data, kwct = re_kw.subn(lambda m: |
165 return kwexpand(matchobj, repo, f, changeid=args['node']) |
165 kwexpand(m, repo, f, changeid=args['node']), |
166 data, kwct = re_kw.subn(kwexpander, data) |
166 data) |
167 if kwct: |
167 if kwct: |
168 ui.note(_('expanding keywords in %s\n' % f)) |
168 ui.note(_('expanding keywords in %s\n' % f)) |
169 repo.wfile(f, 'w').write(data) |
169 repo.wfile(f, 'w').write(data) |