@@ -69,18 +69,17 @@ def qrefresh(origfn, ui, repo, *pats, **
if not opts['interactive']:
return origfn(ui, repo, *pats, **opts)
- mq = extensions.find('mq')
+ with extensions.get('mq') as mq:
+ def committomq(ui, repo, *pats, **opts):
+ # At this point the working copy contains only changes that
+ # were accepted. All other changes were reverted.
+ # We can't pass *pats here since qrefresh will undo all other
+ # changed files in the patch that aren't in pats.
+ mq.refresh(ui, repo, **opts)
- def committomq(ui, repo, *pats, **opts):
- # At this point the working copy contains only changes that
- # were accepted. All other changes were reverted.
- # We can't pass *pats here since qrefresh will undo all other
- # changed files in the patch that aren't in pats.
- mq.refresh(ui, repo, **opts)
-
- # backup all changed files
- cmdutil.dorecord(ui, repo, committomq, None, True,
- cmdutil.recordfilter, *pats, **opts)
+ # backup all changed files
+ cmdutil.dorecord(ui, repo, committomq, None, True,
+ cmdutil.recordfilter, *pats, **opts)
# This command registration is replaced during uisetup().
@command('qrecord',
@@ -122,21 +121,17 @@ def qnew(origfn, ui, repo, patch, *args,
def uisetup(ui):
- try:
- mq = extensions.find('mq')
- except KeyError:
- return
+ with extensions.get('mq') as mq:
+ cmdtable["qrecord"] = \
+ (qrecord,
+ # same options as qnew, but copy them so we don't get
+ # -i/--interactive for qrecord and add white space diff options
+ mq.cmdtable['^qnew'][1][:] + commands.diffwsopts,
+ _('hg qrecord [OPTION]... PATCH [FILE]...'))
- cmdtable["qrecord"] = \
- (qrecord,
- # same options as qnew, but copy them so we don't get
- # -i/--interactive for qrecord and add white space diff options
- mq.cmdtable['^qnew'][1][:] + commands.diffwsopts,
- _('hg qrecord [OPTION]... PATCH [FILE]...'))
-
- _wrapcmd('qnew', mq.cmdtable, qnew, _("interactively record a new patch"))
- _wrapcmd('qrefresh', mq.cmdtable, qrefresh,
- _("interactively select changes to refresh"))
+ _wrapcmd('qnew', mq.cmdtable, qnew, _("interactively record a new patch"))
+ _wrapcmd('qrefresh', mq.cmdtable, qrefresh,
+ _("interactively select changes to refresh"))
def _wrapcmd(cmd, table, wrapfn, msg):
entry = extensions.wrapcommand(table, cmd, wrapfn)
@@ -345,15 +345,12 @@ def help_(ui, name, unknowncmd=False, fu
# check if this command shadows a non-trivial (multi-line)
# extension help text
- try:
- mod = extensions.find(name)
+ with extensions.get(name) as mod:
doc = gettext(mod.__doc__) or ''
if '\n' in doc.strip():
msg = _('(use "hg help -e %s" to show help for '
'the %s extension)') % (name, name)
rst.append('\n%s\n' % msg)
- except KeyError:
- pass
# options
if not ui.quiet and entry[1]: