comparison hgext/mq.py @ 19212:d0ba7022c13b

mq: switch to new summary hook mechanism
author Bryan O'Sullivan <bryano@fb.com>
date Tue, 14 May 2013 11:23:16 -0700
parents 743daa601445
children 19622224559b
comparison
equal deleted inserted replaced
19211:3bfd7f1e7485 19212:d0ba7022c13b
3531 r = q.qrepo() 3531 r = q.qrepo()
3532 if not r: 3532 if not r:
3533 raise util.Abort(_('no queue repository')) 3533 raise util.Abort(_('no queue repository'))
3534 return orig(r.ui, r, *args, **kwargs) 3534 return orig(r.ui, r, *args, **kwargs)
3535 3535
3536 def summary(orig, ui, repo, *args, **kwargs): 3536 def summaryhook(ui, repo):
3537 r = orig(ui, repo, *args, **kwargs)
3538 q = repo.mq 3537 q = repo.mq
3539 m = [] 3538 m = []
3540 a, u = len(q.applied), len(q.unapplied(repo)) 3539 a, u = len(q.applied), len(q.unapplied(repo))
3541 if a: 3540 if a:
3542 m.append(ui.label(_("%d applied"), 'qseries.applied') % a) 3541 m.append(ui.label(_("%d applied"), 'qseries.applied') % a)
3546 # i18n: column positioning for "hg summary" 3545 # i18n: column positioning for "hg summary"
3547 ui.write(_("mq: %s\n") % ', '.join(m)) 3546 ui.write(_("mq: %s\n") % ', '.join(m))
3548 else: 3547 else:
3549 # i18n: column positioning for "hg summary" 3548 # i18n: column positioning for "hg summary"
3550 ui.note(_("mq: (empty queue)\n")) 3549 ui.note(_("mq: (empty queue)\n"))
3551 return r
3552 3550
3553 def revsetmq(repo, subset, x): 3551 def revsetmq(repo, subset, x):
3554 """``mq()`` 3552 """``mq()``
3555 Changesets managed by MQ. 3553 Changesets managed by MQ.
3556 """ 3554 """
3565 # Ensure mq wrappers are called first, regardless of extension load order by 3563 # Ensure mq wrappers are called first, regardless of extension load order by
3566 # NOT wrapping in uisetup() and instead deferring to init stage two here. 3564 # NOT wrapping in uisetup() and instead deferring to init stage two here.
3567 mqopt = [('', 'mq', None, _("operate on patch repository"))] 3565 mqopt = [('', 'mq', None, _("operate on patch repository"))]
3568 3566
3569 extensions.wrapcommand(commands.table, 'import', mqimport) 3567 extensions.wrapcommand(commands.table, 'import', mqimport)
3570 extensions.wrapcommand(commands.table, 'summary', summary) 3568 cmdutil.summaryhooks.add('mq', summaryhook)
3571 3569
3572 entry = extensions.wrapcommand(commands.table, 'init', mqinit) 3570 entry = extensions.wrapcommand(commands.table, 'init', mqinit)
3573 entry[1].extend(mqopt) 3571 entry[1].extend(mqopt)
3574 3572
3575 nowrap = set(commands.norepo.split(" ")) 3573 nowrap = set(commands.norepo.split(" "))