82 |
82 |
83 from mercurial import commands, cmdutil, context, dispatch, filelog, revlog |
83 from mercurial import commands, cmdutil, context, dispatch, filelog, revlog |
84 from mercurial import patch, localrepo, templater, templatefilters, util |
84 from mercurial import patch, localrepo, templater, templatefilters, util |
85 from mercurial.node import * |
85 from mercurial.node import * |
86 from mercurial.i18n import _ |
86 from mercurial.i18n import _ |
87 import re, shutil, tempfile, time |
87 import re, shutil, tempfile, time, os |
88 |
88 |
89 commands.optionalrepo += ' kwdemo' |
89 commands.optionalrepo += ' kwdemo' |
90 |
90 |
91 # hg commands that do not act on keywords |
91 # hg commands that do not act on keywords |
92 nokwcommands = ('add addremove bundle copy export grep identify incoming init' |
92 nokwcommands = ('add addremove bundle copy export grep identify incoming init' |
387 modified, added, removed, deleted, unknown, ignored, clean = status |
387 modified, added, removed, deleted, unknown, ignored, clean = status |
388 files = modified + added + clean |
388 files = modified + added + clean |
389 if opts.get('untracked'): |
389 if opts.get('untracked'): |
390 files += unknown |
390 files += unknown |
391 files.sort() |
391 files.sort() |
392 kwfiles = [f for f in files if _iskwfile(f, repo._link)] |
392 wctx = repo.workingctx() |
|
393 islink = lambda p: 'l' in wctx.fileflags(p) |
|
394 kwfiles = [f for f in files if _iskwfile(f, islink)] |
393 cwd = pats and repo.getcwd() or '' |
395 cwd = pats and repo.getcwd() or '' |
394 kwfstats = not opts.get('ignore') and (('K', kwfiles),) or () |
396 kwfstats = not opts.get('ignore') and (('K', kwfiles),) or () |
395 if opts.get('all') or opts.get('ignore'): |
397 if opts.get('all') or opts.get('ignore'): |
396 kwfstats += (('I', [f for f in files if f not in kwfiles]),) |
398 kwfstats += (('I', [f for f in files if f not in kwfiles]),) |
397 for char, filenames in kwfstats: |
399 for char, filenames in kwfstats: |
423 global _kwtemplater |
425 global _kwtemplater |
424 hgcmd, hgcmdopts = _cmd, _cmdoptions |
426 hgcmd, hgcmdopts = _cmd, _cmdoptions |
425 |
427 |
426 try: |
428 try: |
427 if (not repo.local() or hgcmd in nokwcommands.split() |
429 if (not repo.local() or hgcmd in nokwcommands.split() |
428 or '.hg' in repo.root.split('/') |
430 or '.hg' in repo.root.split(os.sep) |
429 or repo._url.startswith('bundle:')): |
431 or repo._url.startswith('bundle:')): |
430 return |
432 return |
431 except AttributeError: |
433 except AttributeError: |
432 pass |
434 pass |
433 |
435 |