mq: add a line to hg summary
authorMatt Mackall <mpm@selenic.com>
Wed, 05 May 2010 20:53:45 -0500
changeset 11107 9c72c5c094aa
parent 11106 213ca9ffcddb
child 11108 8d0cdeaa12f3
mq: add a line to hg summary
hgext/mq.py
tests/test-mq
tests/test-mq.out
--- a/hgext/mq.py	Fri May 07 14:07:30 2010 -0500
+++ b/hgext/mq.py	Wed May 05 20:53:45 2010 -0500
@@ -2662,10 +2662,26 @@
         raise util.Abort('no queue repository')
     return orig(r.ui, r, *args, **kwargs)
 
+def summary(orig, ui, repo, *args, **kwargs):
+    r = orig(ui, repo, *args, **kwargs)
+    q = repo.mq
+    m = []
+    a, u = len(q.applied), len(q.unapplied(repo))
+    if a:
+        m.append(_("%d applied") % a)
+    if u:
+        m.append(_("%d unapplied") % u)
+    if m:
+        ui.write("mq:     %s\n" % ', '.join(m))
+    else:
+        ui.note("mq:     (empty queue)\n")
+    return r
+
 def uisetup(ui):
     mqopt = [('', 'mq', None, _("operate on patch repository"))]
 
     extensions.wrapcommand(commands.table, 'import', mqimport)
+    extensions.wrapcommand(commands.table, 'summary', summary)
 
     entry = extensions.wrapcommand(commands.table, 'init', mqinit)
     entry[1].extend(mqopt)
--- a/tests/test-mq	Fri May 07 14:07:30 2010 -0500
+++ b/tests/test-mq	Wed May 05 20:53:45 2010 -0500
@@ -170,7 +170,9 @@
 COLUMNS=20 hg qseries --config ui.interactive=true -vs
 hg qpop
 hg qseries -vs
+hg sum
 hg qpush
+hg sum
 
 echo % qapplied
 hg qapplied
--- a/tests/test-mq.out	Fri May 07 14:07:30 2010 -0500
+++ b/tests/test-mq.out	Wed May 05 20:53:45 2010 -0500
@@ -151,8 +151,20 @@
 now at: test.patch
 0 A test.patch: foo bar
 1 U test2.patch: 
+parent: 2:1d611e5a7244 qbase qtip test.patch tip
+ foo bar
+branch: default
+commit: (clean)
+update: (current)
+mq:     1 applied, 1 unapplied
 applying test2.patch
 now at: test2.patch
+parent: 3:333b5cb98635 qtip test2.patch tip
+ imported patch test2.patch
+branch: default
+commit: (clean)
+update: (current)
+mq:     2 applied
 % qapplied
 test.patch
 test2.patch