[PATCH 32 of 35] keyword: define inferrepo in command decorator
Gregory Szorc
gregory.szorc at gmail.com
Mon May 5 00:51:37 CDT 2014
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1399267935 25200
# Sun May 04 22:32:15 2014 -0700
# Branch stable
# Node ID 2f18b849913ac3f5fc317f7cac30e2e3bf101d0c
# Parent 1147aa709176463125d21847f023445db55c20ba
keyword: define inferrepo in command decorator
diff --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -84,18 +84,16 @@ like CVS' $Log$, are not supported. A ke
from mercurial import commands, context, cmdutil, dispatch, filelog, extensions
from mercurial import localrepo, match, patch, templatefilters, templater, util
from mercurial import scmutil, pathutil
from mercurial.hgweb import webcommands
from mercurial.i18n import _
import os, re, shutil, tempfile
-commands.inferrepo += ' kwexpand kwfiles kwshrink'
-
cmdtable = {}
command = cmdutil.command(cmdtable)
testedwith = 'internal'
# hg commands that do not act on keywords
nokwcommands = ('add addremove annotate bundle export grep incoming init log'
' outgoing push tip verify convert email glog')
@@ -448,33 +446,37 @@ def demo(ui, repo, *args, **opts):
repo.ui.setconfig('hooks', name, '', 'keyword')
msg = _('hg keyword configuration and expansion example')
ui.note(("hg ci -m '%s'\n" % msg))
repo.commit(text=msg)
ui.status(_('\n\tkeywords expanded\n'))
ui.write(repo.wread(fn))
shutil.rmtree(tmpdir, ignore_errors=True)
- at command('kwexpand', commands.walkopts, _('hg kwexpand [OPTION]... [FILE]...'))
+ at command('kwexpand',
+ commands.walkopts,
+ _('hg kwexpand [OPTION]... [FILE]...'),
+ inferrepo=True)
def expand(ui, repo, *pats, **opts):
'''expand keywords in the working directory
Run after (re)enabling keyword expansion.
kwexpand refuses to run if given files contain local changes.
'''
# 3rd argument sets expansion to True
_kwfwrite(ui, repo, True, *pats, **opts)
@command('kwfiles',
[('A', 'all', None, _('show keyword status flags of all files')),
('i', 'ignore', None, _('show files excluded from expansion')),
('u', 'unknown', None, _('only show unknown (not tracked) files')),
] + commands.walkopts,
- _('hg kwfiles [OPTION]... [FILE]...'))
+ _('hg kwfiles [OPTION]... [FILE]...'),
+ inferrepo=True)
def files(ui, repo, *pats, **opts):
'''show files configured for keyword expansion
List which files in the working directory are matched by the
[keyword] configuration patterns.
Useful to prevent inadvertent keyword expansion and to speed up
execution by including only files that are actual candidates for
@@ -518,17 +520,20 @@ def files(ui, repo, *pats, **opts):
for kwstate, char, filenames in kwstates:
label = 'kwfiles.' + kwstate
for f in filenames:
fm.startitem()
fm.write('kwstatus path', fmt, char,
repo.pathto(f, cwd), label=label)
fm.end()
- at command('kwshrink', commands.walkopts, _('hg kwshrink [OPTION]... [FILE]...'))
+ at command('kwshrink',
+ commands.walkopts,
+ _('hg kwshrink [OPTION]... [FILE]...'),
+ inferrepo=True)
def shrink(ui, repo, *pats, **opts):
'''revert expanded keywords in the working directory
Must be run before changing/disabling active keywords.
kwshrink refuses to run if given files contain local changes.
'''
# 3rd argument sets expansion to False
More information about the Mercurial-devel
mailing list