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