本文整理汇总了Python中mercurial.cmdutil.findcmd函数的典型用法代码示例。如果您正苦于以下问题:Python findcmd函数的具体用法?Python findcmd怎么用?Python findcmd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了findcmd函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:33,代码来源:nointerrupt.py
示例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
开发者ID:c0ns0le,项目名称:cygwin,代码行数:26,代码来源:alias.py
示例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
开发者ID:motlin,项目名称:cyg,代码行数:35,代码来源:chgserver.py
示例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)
开发者ID:ZanderZhang,项目名称:Andriod-Learning,代码行数:34,代码来源:pager.py
示例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)
开发者ID:Nephyrin,项目名称:bzexport,代码行数:28,代码来源:__init__.py
示例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
开发者ID:pnkfelix,项目名称:ConfigFiles,代码行数:9,代码来源:test_util.py
示例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)
开发者ID:thomasvandoren,项目名称:dotfiles,代码行数:9,代码来源:trees.py
示例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)'))
开发者ID:seewindcn,项目名称:tortoisehg,代码行数:11,代码来源:hgcommands.py
示例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)
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:11,代码来源:fbhistedit.py
示例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)
开发者ID:TerminalSpirit,项目名称:dotfiles,代码行数:11,代码来源:boundmode.py
示例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
开发者ID:frostytear,项目名称:version-control-tools,代码行数:40,代码来源:client.py
示例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=[])
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:14,代码来源:tweakdefaults.py
示例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
开发者ID:MikeLing,项目名称:version-control-tools,代码行数:37,代码来源:client.py
示例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
开发者ID:TerminalSpirit,项目名称:dotfiles,代码行数:18,代码来源:rdiff.py
示例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)
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:19,代码来源:fbshow.py
示例16: extsetup
def extsetup(ui):
try:
extensions.find('histedit')
except KeyError:
raise error.Abort(
_('fbhistedit: please enable histedit extension as well'))
defineactions()
_extend_histedit(ui)
rebase = extensions.find('rebase')
extensions.wrapcommand(rebase.cmdtable, 'rebase', _rebase, synopsis='[-i]')
aliases, entry = cmdutil.findcmd('rebase', rebase.cmdtable)
newentry = list(entry)
options = newentry[1]
# dirty hack because we need to change an existing switch
for idx, opt in enumerate(options):
if opt[0] == 'i':
del options[idx]
options.append(('i', 'interactive', False, 'interactive rebase'))
rebase.cmdtable['rebase'] = tuple(newentry)
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:21,代码来源:fbhistedit.py
示例17: pagecmd
def pagecmd(orig, ui, options, cmd, cmdfunc):
p = ui.config("pager", "pager", os.environ.get("PAGER"))
if p:
attend = ui.configlist('pager', 'attend', attended)
auto = options['pager'] == 'auto'
always = util.parsebool(options['pager'])
cmds, _ = cmdutil.findcmd(cmd, commands.table)
ignore = ui.configlist('pager', 'ignore')
for cmd in cmds:
if (always or auto and
(cmd in attend or
(cmd not in ignore and not attend))):
ui.setconfig('ui', 'formatted', ui.formatted())
ui.setconfig('ui', 'interactive', False)
if util.safehasattr(signal, "SIGPIPE"):
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
_runpager(ui, p)
break
return orig(ui, options, cmd, cmdfunc)
开发者ID:spraints,项目名称:for-example,代码行数:22,代码来源:pager.py
示例18: qimporthook
def qimporthook(orig, ui, repo, *files, **opts):
q = repo.mq
# checks for an unused patch name. prompts if the patch already exists and
# returns the corrected name.
def checkpatchname(patch):
name = patch.name
# Hg v1.4+: "ui.prompt is now a simple prompt and does not accept a list of choices. Use ui.promptchoice instead.".
hasPromptchoice = hasattr(ui, 'promptchoice')
while os.path.exists(q.join(name)):
prompt = "A patch file named '%s' already exists in your patch directory. Rename %s '%s' (%d) (r)/overwrite (o)?" % \
(name,
'patch' if isinstance(patch, bz.Patch) else 'attachment',
patch.desc,
int(patch.id))
if hasPromptchoice:
choice = ui.promptchoice(prompt,
("&readonly", "&overwrite"),
0)
choice = ["r", "o"][choice]
else:
choice = ui.prompt(prompt,
("&readonly", "&overwrite"),
"r")
if choice == 'r':
name = ui.prompt("Enter the new patch name (old one was '%s'):" % name)
else: # overwrite
break;
if name in q.series and q.isapplied(name):
ui.warn("Patch was already applied. Changes will not take effect until the patch is reapplied.")
return name
# hook for url.open which lets the user edit the returned
def previewopen(orig, ui, path):
fp = orig(ui, path)
class PreviewReader(object):
def read(self):
return ui.edit(fp.read(), ui.username())
return PreviewReader()
# Install the preview hook if necessary. This will preview non-bz:// bugs
# and that's OK.
if opts['preview']:
extensions.wrapfunction(url, "open", previewopen)
# mercurial's url.search_re includes the // and that doesn't match what we
# want which is bz:dddddd(/ddddd)?
files = map(fixuppath, files)
# Remember where the next patch will be inserted into the series
try:
# hg 1.9+
insert = q.fullseriesend()
except:
insert = q.full_series_end()
# Do the import as normal. The first patch of any bug is actually imported
# and the rest are stored in the global delayed_imports. The imported
# patches have dumb filenames because there's no way to tell mq to pick the
# patch name *after* download.
orig(ui, repo, *files, **opts)
# If the user passed a name, then mq used that so we don't need to rename
if not opts['name']:
# cache the lookup of the name. findcmd is not fast.
qrename = cmdutil.findcmd("qrename", commands.table)[1][0]
# For all the already imported patches, rename them. Except there will
# only be one, since if the url resolves to multiple patches then
# everything but the first will go into bzhandler.delayed_imports.
for (patch, path) in list(bzhandler.imported_patches):
# Find where qimport will have inserted the initial patch
try:
# hg 1.9+
oldpatchname = q.fullseries[insert]
except:
oldpatchname = q.full_series[insert]
insert += 1
newpatchname = checkpatchname(patch)
if newpatchname != oldpatchname:
qrename(ui, repo, oldpatchname, newpatchname)
# mq always reports the original name, which is confusing so we'll
# report the rename. But if ui.verbose is on, qrename will have
# already reported it.
if not ui.verbose:
ui.write("renamed %s -> %s\n" % (oldpatchname, newpatchname))
# now process the delayed imports
# these opts are invariant for all patches
newopts = {}
newopts.update(opts)
newopts['force'] = True
# loop through the Patches and import them by calculating their url. The
# bz:// handler will have cached the lookup so we don't hit the network here
for patch in bzhandler.delayed_imports:
newopts['name'] = checkpatchname(patch)
#.........这里部分代码省略.........
开发者ID:pnkfelix,项目名称:qimportbz,代码行数:101,代码来源:__init__.py
示例19: _cmdtableitem
def _cmdtableitem(ui, cmd, table):
'''Return key, value from table for cmd, or None if not found.'''
aliases, entry = cmdutil.findcmd(ui, cmd, table)
for candidatekey, candidateentry in table.iteritems():
if candidateentry is entry:
return candidatekey, entry
开发者ID:carlgao,项目名称:lenga,代码行数:6,代码来源:color.py
示例20: findcmd
def findcmd(cmd):
return cmdutil.findcmd(self._getUI(), cmd)
开发者ID:lelit,项目名称:tailor,代码行数:2,代码来源:hg.py
注:本文中的mercurial.cmdutil.findcmd函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论