[PATCH RFC] mq: add --fill option to qqueue command

Takumi IINO trot.thunder at gmail.com
Wed May 2 09:01:07 CDT 2012


# HG changeset patch
# User Takumi IINO <trot.thunder at gmail.com>
# Date 1335848882 -32400
# Node ID aa0abd1cc4e15c4832fa441d5ea171d3420779b1
# Parent  55982f62651f1974fcd91197f1c4801cc98a48f2
mq: add --fill option to qqueue command

Useful information is filled patch queues rather than available patch queues.

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -3021,6 +3021,7 @@
 @command("qqueue",
          [('l', 'list', False, _('list all available queues')),
           ('', 'active', False, _('print name of active queue')),
+          ('', 'fill', False, _('print name of filled queue')),
           ('c', 'create', False, _('create new queue')),
           ('', 'rename', False, _('rename active queue')),
           ('', 'delete', False, _('delete reference to queue')),
@@ -3127,11 +3128,20 @@
         fh.close()
         util.rename(repo.join('patches.queues.new'), repo.join(_allqueues))
 
-    if not name or opts.get('list') or opts.get('active'):
+    if not name or opts.get('list') or opts.get('active') or opts.get('fill'):
         current = _getcurrent()
         if opts.get('active'):
             ui.write('%s\n' % (current,))
             return
+        if opts.get('fill'):
+            for queue in _getqueues():
+                if len(repo.othermq(_queuedir(queue)).fullseries) > 0:
+                    ui.write('%s' % (queue,))
+                    if queue == current and not ui.quiet:
+                        ui.write(_(' (active)\n'))
+                    else:
+                        ui.write('\n')
+            return
         for queue in _getqueues():
             ui.write('%s' % (queue,))
             if queue == current and not ui.quiet:
@@ -3208,6 +3218,9 @@
         def mq(self):
             return queue(self.ui, self.path)
 
+        def othermq(self, patchdir=None):
+            return queue(self.ui, self.path, patchdir)
+
         def abortifwdirpatched(self, errmsg, force=False):
             if self.mq.applied and not force:
                 parents = self.dirstate.parents()
diff --git a/tests/test-mq-qqueue.t b/tests/test-mq-qqueue.t
--- a/tests/test-mq-qqueue.t
+++ b/tests/test-mq-qqueue.t
@@ -186,3 +186,69 @@
 
   $ cd ..
 
+Fill Option:
+
+  $ hg init fill
+  $ cd fill
+  $ echo a > a
+  $ hg ci -qAm a
+
+Default queue:
+
+  $ hg qqueue
+  patches (active)
+
+  $ hg qqueue --fill
+
+  $ echo b > a
+  $ hg qnew -fgDU somestuff
+
+  $ hg qqueue --fill
+  patches (active)
+
+  $ hg qqueue --fill --quiet
+  patches
+
+Empty default queue:
+
+  $ hg qpop
+  popping somestuff
+  patch queue now empty
+
+  $ hg qqueue --fill
+  patches (active)
+
+Other queue:
+
+  $ hg qqueue --create other
+
+  $ hg qqueue
+  other (active)
+  patches
+
+  $ hg qqueue --fill
+  patches
+
+  $ echo b > a
+  $ hg qnew -fgDU otherstuff
+
+  $ hg qqueue --fill
+  other (active)
+  patches
+
+Empty other queue:
+
+  $ hg qpop
+  popping otherstuff
+  patch queue now empty
+
+  $ hg qqueue --fill
+  other (active)
+  patches
+
+  $ hg qrm otherstuff
+
+  $ hg qqueue --fill
+  patches
+
+  $ cd ..


More information about the Mercurial-devel mailing list