227 # substitute keywords |
227 # substitute keywords |
228 for f in kwfmatches(ui, self, changed): |
228 for f in kwfmatches(ui, self, changed): |
229 data = self.wfile(f).read() |
229 data = self.wfile(f).read() |
230 if not util.binary(data): |
230 if not util.binary(data): |
231 data, kwct = re_kw.subn(lambda m: |
231 data, kwct = re_kw.subn(lambda m: |
232 kwexpand(m, self, f, changeid=hex(n)), |
232 kwexpand(m, self, f, changeid=hex(n)), data) |
233 data) |
|
234 if kwct: |
233 if kwct: |
235 ui.debug(_('overwriting %s expanding keywords\n' % f)) |
234 ui.debug(_('overwriting %s expanding keywords\n' % f)) |
236 self.wfile(f, 'w').write(data) |
235 self.wfile(f, 'w').write(data) |
237 |
236 |
238 tr.close() |
237 tr.close() |
255 |
254 |
256 def read(self, node): |
255 def read(self, node): |
257 data = super(kwfilelog, self).read(node) |
256 data = super(kwfilelog, self).read(node) |
258 if not util.binary(data) and \ |
257 if not util.binary(data) and \ |
259 kwfmatches(ui, self._repo, [self._path]): |
258 kwfmatches(ui, self._repo, [self._path]): |
260 ui.debug(_('expanding keywords in %s\n' % self._path)) |
|
261 return re_kw.sub(lambda m: |
259 return re_kw.sub(lambda m: |
262 kwexpand(m, self._repo, self._path, |
260 kwexpand(m, self._repo, self._path, |
263 fileid=node, filelog=self), data) |
261 fileid=node, filelog=self), data) |
264 return data |
262 return data |
265 |
263 |
266 def cmp(self, node, text): |
264 def cmp(self, node, text): |
267 '''Removes keyword substitution for comparison.''' |
265 '''Removes keyword substitution for comparison.''' |
268 if not util.binary(text): |
266 if not util.binary(text) and \ |
|
267 kwfmatches(ui, self._repo, [self._path]): |
269 text = re_kw.sub(r'$\1$', text) |
268 text = re_kw.sub(r'$\1$', text) |
270 return super(kwfilelog, self).cmp(node, text) |
269 return super(kwfilelog, self).cmp(node, text) |
271 |
270 |
272 filelog.filelog = kwfilelog |
271 filelog.filelog = kwfilelog |
273 repo.__class__ = kwrepo |
272 repo.__class__ = kwrepo |