本文整理汇总了Python中mercurial.cmdutil.findcmd函数的典型用法代码示例。如果您正苦于以下问题:Python findcmd函数的具体用法?Python findcmd怎么用?Python findcmd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了findcmd函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: nointerruptcmd
def nointerruptcmd(orig, ui, options, cmd, cmdfunc):
# bail if not in interactive terminal
if ui.configbool('nointerrupt', 'interactiveonly', True):
if not ui.fout.isatty() or ui.plain():
return orig(ui, options, cmd, cmdfunc)
cmds, _cmdtableentry = cmdutil.findcmd(cmd, commands.table)
if isinstance(_cmdtableentry[0], dispatch.cmdalias):
cmds.append(_cmdtableentry[0].cmdname)
shouldpreventinterrupt = ui.configbool(
'nointerrupt', 'default-attend', False)
for cmd in cmds:
var = 'attend-%s' % cmd
if ui.config('nointerrupt', var):
shouldpreventinterrupt = ui.configbool('nointerrupt', var)
break
if shouldpreventinterrupt:
oldsiginthandler = signal.getsignal(signal.SIGINT)
try:
msg = ui.config('nointerrupt', 'message',
"==========================\n"
"Interrupting Mercurial may leave your repo in a bad state.\n"
"If you really want to interrupt your current command, press\n"
"CTRL-C again.\n"
"==========================\n"
)
signal.signal(signal.SIGINT, sigintprintwarninghandlerfactory(
oldsiginthandler, msg))
except AttributeError:
pass
return orig(ui, options, cmd, cmdfunc)
示例2: _resolve
def _resolve(self):
if self._cmd is not None:
return
try:
self._cmd = findcmd(self._ui, self._target, commands.table)[1]
if self._cmd == self:
raise RecursiveCommand()
if self._target in commands.norepo.split(' '):
commands.norepo += ' %s' % self._name
return
except UnknownCommand:
msg = '*** [alias] %s: command %s is unknown' % \
(self._name, self._target)
except AmbiguousCommand:
msg = '*** [alias] %s: command %s is ambiguous' % \
(self._name, self._target)
except RecursiveCommand:
msg = '*** [alias] %s: circular dependency on %s' % \
(self._name, self._target)
def nocmd(*args, **opts):
self._ui.warn(msg + '\n')
return 1
nocmd.__doc__ = msg
self._cmd = (nocmd, [], '')
commands.norepo += ' %s' % self._name
示例3: _setuppagercmd
def _setuppagercmd(ui, options, cmd):
if not ui.formatted():
return
p = ui.config("pager", "pager", os.environ.get("PAGER"))
usepager = False
always = util.parsebool(options['pager'])
auto = options['pager'] == 'auto'
if not p:
pass
elif always:
usepager = True
elif not auto:
usepager = False
else:
attended = ['annotate', 'cat', 'diff', 'export', 'glog', 'log', 'qdiff']
attend = ui.configlist('pager', 'attend', attended)
ignore = ui.configlist('pager', 'ignore')
cmds, _ = cmdutil.findcmd(cmd, commands.table)
for cmd in cmds:
var = 'attend-%s' % cmd
if ui.config('pager', var):
usepager = ui.configbool('pager', var)
break
if (cmd in attend or
(cmd not in ignore and not attend)):
usepager = True
break
if usepager:
ui.setconfig('ui', 'formatted', ui.formatted(), 'pager')
ui.setconfig('ui', 'interactive', False, 'pager')
return p
示例4: pagecmd
def pagecmd(orig, ui, options, cmd, cmdfunc):
p = ui.config("pager", "pager", os.environ.get("PAGER"))
usepager = False
always = util.parsebool(options['pager'])
auto = options['pager'] == 'auto'
if not p:
pass
elif always:
usepager = True
elif not auto:
usepager = False
else:
attend = ui.configlist('pager', 'attend', attended)
ignore = ui.configlist('pager', 'ignore')
cmds, _ = cmdutil.findcmd(cmd, commands.table)
for cmd in cmds:
var = 'attend-%s' % cmd
if ui.config('pager', var):
usepager = ui.configbool('pager', var)
break
if (cmd in attend or
(cmd not in ignore and not attend)):
usepager = True
break
if usepager:
ui.setconfig('ui', 'formatted', ui.formatted(), 'pager')
ui.setconfig('ui', 'interactive', False, 'pager')
if util.safehasattr(signal, "SIGPIPE"):
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
_runpager(ui, p)
return orig(ui, options, cmd, cmdfunc)
示例5: uisetup
def uisetup(ui):
try:
mq = extensions.find('mq')
if mq is None:
ui.warn("mqext extension is mostly disabled when mq is disabled")
return
except KeyError:
ui.warn("mqext extension is mostly disabled when mq is not installed")
return # mq not loaded at all
# check whether mq is loaded before mqext. If not, do a nasty hack to set
# it up first so that mqext can modify what it does and not have the
# modifications get clobbered. Mercurial really needs to implement
# inter-extension dependencies.
aliases, entry = cmdutil.findcmd('init', commands.table)
try:
if not [ e for e in entry[1] if e[1] == 'mq' ]:
orig = mq.uisetup
mq.uisetup = lambda ui: deferred_uisetup(orig, ui, mq)
return
except AttributeError:
# argh! Latest mq does not use uisetup anymore. Now it does its stuff
# in extsetup (phase 2). Fortunately, it now installs its commands
# early enough that the order no longer matters.
pass
uisetup_post_mq(ui, mq)
示例6: decorator
def decorator(fn):
for entry in cmdutil.findcmd("clone", commands.table)[1][1]:
if entry[1] == option:
return fn
# no match found, so skip
if SkipTest:
return _makeskip(fn.__name__, "test requires clone to accept %s" % option)
# no skipping support, so erase decorated method
return
示例7: _newcte
def _newcte(origcmd, newfunc, extraopts = [], synopsis = None):
'''generate a cmdtable entry based on that for origcmd'''
cte = cmdutil.findcmd(origcmd, commands.table)[1]
# Filter out --exclude and --include, since those do not work across
# repositories (mercurial converts them to abs paths).
opts = [o for o in cte[1] if o[1] not in ('exclude', 'include')]
if len(cte) > 2:
return (newfunc, opts + extraopts, synopsis or cte[2])
return (newfunc, opts + extraopts, synopsis)
示例8: uisetup
def uisetup(ui):
try:
extensions.find('mq')
cmdtable.update(_mqcmdtable)
except KeyError:
pass
# ignore --no-commit on hg<3.7 (ce76c4d2b85c)
_aliases, entry = cmdutil.findcmd('backout', commands.table)
if not any(op for op in entry[1] if op[1] == 'no-commit'):
entry[1].append(('', 'no-commit', None, '(EXPERIMENTAL)'))
示例9: _extend_histedit
def _extend_histedit(ui):
histedit = extensions.find('histedit')
_aliases, entry = cmdutil.findcmd('histedit', histedit.cmdtable)
options = entry[1]
options.append(('x', 'retry', False,
_('retry exec command that failed and try to continue')))
options.append(('', 'show-plan', False, _('show remaining actions list')))
extensions.wrapfunction(histedit, '_histedit', _histedit)
extensions.wrapfunction(histedit, 'parserules', parserules)
示例10: autopushwrapper
def autopushwrapper(orig, ui, repo, *args, **opts):
"""if in bound mode this will attempt a push after calling the wrapped
method
"""
orig(ui, repo, *args, **opts)
b = boundrc(ui, repo)
if b.isbound():
ui.note(_('commit succeeded; attempting push\n'))
pushfunc = cmdutil.findcmd('push', commands.table)[1][0]
dest = b.pushloc()
pushfunc(ui, repo, dest, **opts)
示例11: extsetup
def extsetup(ui):
extensions.wrapfunction(exchange, 'push', wrappedpush)
# Mercurial 3.2 introduces a decorator for registering functions to
# be called during discovery. Switch to this once we drop support for
# 3.1.
extensions.wrapfunction(exchange, '_pushdiscovery', wrappedpushdiscovery)
# _pushbookmark gets called near the end of push. Sadly, there isn't
# a better place to hook that has access to the pushop.
extensions.wrapfunction(exchange, '_pushbookmark', wrappedpushbookmark)
if os.name == 'posix':
extensions.wrapfunction(sshpeer.sshpeer, 'readerr', wrappedreaderr)
# Define some extra arguments on the push command.
entry = extensions.wrapcommand(commands.table, 'push', pushcommand)
entry[1].append(('', 'noreview', False,
_('Do not perform a review on push.')))
entry[1].append(('', 'reviewid', '', _('Review identifier')))
entry[1].append(('c', 'changeset', '',
_('Review this specific changeset only')))
# Value may be empty. So check config source to see if key is present.
if (ui.configsource('extensions', 'rebase') != 'none' and
ui.config('extensions', 'rebase') != '!'):
# The extensions.afterloaded mechanism is busted. So we can't
# reliably wrap the rebase command in case it hasn't loaded yet. So
# just load the rebase extension and wrap the function directly
# from its commands table.
try:
cmdutil.findcmd('rebase', commands.table, strict=True)
except error.UnknownCommand:
extensions.load(ui, 'rebase', '')
# Extensions' cmdtable entries aren't merged with commands.table.
# Instead, dispatch just looks at each module. So it is safe to wrap
# the command on the extension module.
rebase = extensions.find('rebase')
extensions.wrapcommand(rebase.cmdtable, 'rebase', rebasecommand)
templatekw.keywords['reviews'] = template_reviews
示例12: bookmarkcmd
def bookmarkcmd(orig, ui, repo, *names, **opts):
strip = opts.pop('strip')
if not strip:
return orig(ui, repo, *names, **opts)
# check conflicted opts
for name in ['force', 'rev', 'rename', 'inactive', 'track', 'untrack',
'all', 'remote']:
if opts.get(name):
raise error.Abort(_('--strip cannot be used together with %s')
% ('--%s' % name))
# call strip -B, may raise UnknownCommand
stripfunc = cmdutil.findcmd('strip', commands.table)[1][0]
return stripfunc(ui, repo, bookmark=names, rev=[])
示例13: extsetup
def extsetup(ui):
extensions.wrapfunction(exchange, "push", wrappedpush)
# Mercurial 3.2 introduces a decorator for registering functions to
# be called during discovery. Switch to this once we drop support for
# 3.1.
extensions.wrapfunction(exchange, "_pushdiscovery", wrappedpushdiscovery)
# _pushbookmark gets called near the end of push. Sadly, there isn't
# a better place to hook that has access to the pushop.
extensions.wrapfunction(exchange, "_pushbookmark", wrappedpushbookmark)
if os.name == "posix":
extensions.wrapfunction(sshpeer.sshpeer, "readerr", wrappedreaderr)
# Define some extra arguments on the push command.
entry = extensions.wrapcommand(commands.table, "push", pushcommand)
entry[1].append(("", "noreview", False, _("Do not perform a review on push.")))
entry[1].append(("", "reviewid", "", _("Review identifier")))
entry[1].append(("c", "changeset", "", _("Review this specific changeset only")))
# Value may be empty. So check config source to see if key is present.
if ui.configsource("extensions", "rebase") != "none" and ui.config("extensions", "rebase") != "!":
# The extensions.afterloaded mechanism is busted. So we can't
# reliably wrap the rebase command in case it hasn't loaded yet. So
# just load the rebase extension and wrap the function directly
# from its commands table.
try:
cmdutil.findcmd("rebase", commands.table, strict=True)
except error.UnknownCommand:
extensions.load(ui, "rebase", "")
# Extensions' cmdtable entries aren't merged with commands.table.
# Instead, dispatch just looks at each module. So it is safe to wrap
# the command on the extension module.
rebase = extensions.find("rebase")
extensions.wrapcommand(rebase.cmdtable, "rebase", rebasecommand)
templatekw.keywords["reviews"] = template_reviews
示例14: wrapcommand
def wrapcommand(table, command, wrapper):
aliases, entry = cmdutil.findcmd(command, table)
for alias, e in table.iteritems():
if e is entry:
key = alias
break
origfn = entry[0]
def wrap(*args, **kwargs):
return wrapper(origfn, *args, **kwargs)
wrap.__doc__ = getattr(origfn, '__doc__')
wrap.__module__ = getattr(origfn, '__module__')
newentry = list(entry)
newentry[0] = wrap
table[key] = tuple(newentry)
return newentry
示例15: uisetup
def uisetup(ui):
permitted_opts = [
('g', 'git', None, _('use git extended diff format')),
('', 'stat', None, _('output diffstat-style summary of changes')),
] + commands.templateopts + commands.walkopts
local_opts = [
('U', 'unified', int, _('number of lines of diff context to show')),
]
aliases, entry = cmdutil.findcmd('log', commands.table)
allowed_opts = [opt for opt in entry[1]
if opt in permitted_opts] + local_opts
# manual call of the decorator
command('^show',
allowed_opts,
_('[OPTION]... [REV [FILE]...]'),
inferrepo=True)(show)