Patchwork [32,of,35] keyword: define inferrepo in command decorator

mail settings
Submitter Gregory Szorc
Date May 5, 2014, 5:51 a.m.
Message ID <>
Download mbox | patch
Permalink /patch/4623/
State Accepted
Commit 44efd5b9ce458cdf91666e3584d791b4adb7da12
Headers show


Gregory Szorc - May 5, 2014, 5:51 a.m.
# HG changeset patch
# User Gregory Szorc <>
# 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/ b/hgext/
--- a/hgext/
+++ b/hgext/
@@ -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))
     ui.status(_('\n\tkeywords expanded\n'))
     shutil.rmtree(tmpdir, ignore_errors=True)
-@command('kwexpand', commands.walkopts, _('hg kwexpand [OPTION]... [FILE]...'))
+    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)
          [('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.write('kwstatus path', fmt, char,
                      repo.pathto(f, cwd), label=label)
-@command('kwshrink', commands.walkopts, _('hg kwshrink [OPTION]... [FILE]...'))
+    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