253 if self.renamed(node): |
253 if self.renamed(node): |
254 t2 = super(kwfilelog, self).read(node) |
254 t2 = super(kwfilelog, self).read(node) |
255 return t2 != text |
255 return t2 != text |
256 return revlog.revlog.cmp(self, node, text) |
256 return revlog.revlog.cmp(self, node, text) |
257 |
257 |
258 def _status(ui, repo, kwt, *pats, **opts): |
258 def _status(ui, repo, kwt, unknown, *pats, **opts): |
259 '''Bails out if [keyword] configuration is not active. |
259 '''Bails out if [keyword] configuration is not active. |
260 Returns status of working directory.''' |
260 Returns status of working directory.''' |
261 if kwt: |
261 if kwt: |
262 matcher = cmdutil.match(repo, pats, opts) |
262 matcher = cmdutil.match(repo, pats, opts) |
263 return repo.status(match=matcher, clean=True) |
263 return repo.status(match=matcher, unknown=unknown, clean=True) |
264 if ui.configitems('keyword'): |
264 if ui.configitems('keyword'): |
265 raise util.Abort(_('[keyword] patterns cannot match')) |
265 raise util.Abort(_('[keyword] patterns cannot match')) |
266 raise util.Abort(_('no [keyword] patterns configured')) |
266 raise util.Abort(_('no [keyword] patterns configured')) |
267 |
267 |
268 def _kwfwrite(ui, repo, expand, *pats, **opts): |
268 def _kwfwrite(ui, repo, expand, *pats, **opts): |
269 '''Selects files and passes them to kwtemplater.overwrite.''' |
269 '''Selects files and passes them to kwtemplater.overwrite.''' |
270 if repo.dirstate.parents()[1] != nullid: |
270 if repo.dirstate.parents()[1] != nullid: |
271 raise util.Abort(_('outstanding uncommitted merge')) |
271 raise util.Abort(_('outstanding uncommitted merge')) |
272 kwt = kwtools['templater'] |
272 kwt = kwtools['templater'] |
273 status = _status(ui, repo, kwt, *pats, **opts) |
273 status = _status(ui, repo, kwt, False, *pats, **opts) |
274 modified, added, removed, deleted, unknown, ignored, clean = status |
274 modified, added, removed, deleted = status[:4] |
275 if modified or added or removed or deleted: |
275 if modified or added or removed or deleted: |
276 raise util.Abort(_('outstanding uncommitted changes')) |
276 raise util.Abort(_('outstanding uncommitted changes')) |
277 wlock = lock = None |
277 wlock = lock = None |
278 try: |
278 try: |
279 wlock = repo.wlock() |
279 wlock = repo.wlock() |
280 lock = repo.lock() |
280 lock = repo.lock() |
281 kwt.overwrite(None, expand, clean) |
281 kwt.overwrite(None, expand, status[6]) |
282 finally: |
282 finally: |
283 del wlock, lock |
283 del wlock, lock |
284 |
284 |
285 |
285 |
286 def demo(ui, repo, *args, **opts): |
286 def demo(ui, repo, *args, **opts): |
380 Crosscheck which files in working directory are potential targets for |
380 Crosscheck which files in working directory are potential targets for |
381 keyword expansion. |
381 keyword expansion. |
382 That is, files matched by [keyword] config patterns but not symlinks. |
382 That is, files matched by [keyword] config patterns but not symlinks. |
383 ''' |
383 ''' |
384 kwt = kwtools['templater'] |
384 kwt = kwtools['templater'] |
385 status = _status(ui, repo, kwt, *pats, **opts) |
385 status = _status(ui, repo, kwt, opts.get('untracked'), *pats, **opts) |
386 modified, added, removed, deleted, unknown, ignored, clean = status |
386 modified, added, removed, deleted, unknown, ignored, clean = status |
387 files = modified + added + clean |
387 files = modified + added + clean + unknown |
388 if opts.get('untracked'): |
|
389 files += unknown |
|
390 files.sort() |
388 files.sort() |
391 wctx = repo[None] |
389 wctx = repo[None] |
392 kwfiles = [f for f in files if kwt.iskwfile(f, wctx.flags)] |
390 kwfiles = [f for f in files if kwt.iskwfile(f, wctx.flags)] |
393 cwd = pats and repo.getcwd() or '' |
391 cwd = pats and repo.getcwd() or '' |
394 kwfstats = not opts.get('ignore') and (('K', kwfiles),) or () |
392 kwfstats = not opts.get('ignore') and (('K', kwfiles),) or () |