# HG changeset patch # User Idan Kamara # Date 2011-05-06 13:07:35 # Node ID 68ade2a6b30a47020884d4446c561c08e518b6d2 # Parent 08d84bdce1a5a52397a6fd1dd33537acf734e128 mq: add a 'mq()' revset predicate that returns applied mq csets diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -45,7 +45,7 @@ create other, independent patch queues w from mercurial.i18n import _ from mercurial.node import bin, hex, short, nullid, nullrev from mercurial.lock import release -from mercurial import commands, cmdutil, hg, patch, scmutil, util +from mercurial import commands, cmdutil, hg, patch, scmutil, util, revset from mercurial import repair, extensions, url, error import os, sys, re, errno, shutil @@ -3096,6 +3096,20 @@ def summary(orig, ui, repo, *args, **kwa ui.note(_("mq: (empty queue)\n")) return r +def revsetmq(repo, subset, x): + """``mq()`` + Changesets managed by MQ. + """ + revset.getargs(x, 0, 0, _("mq takes no arguments")) + applied = set([repo[r.node].rev() for r in repo.mq.applied]) + return [r for r in subset if r in applied] + +def extsetup(ui): + revset.symbols['mq'] = revsetmq + +# tell hggettext to extract docstrings from these functions: +i18nfunctions = [revsetmq] + def uisetup(ui): mqopt = [('', 'mq', None, _("operate on patch repository"))] diff --git a/tests/test-mq.t b/tests/test-mq.t --- a/tests/test-mq.t +++ b/tests/test-mq.t @@ -843,6 +843,14 @@ mq tags 1 foo qbase 2 bar qtip tip +mq revset + + $ hg log -r 'mq()' --template '{rev}\n' + 1 + 2 + $ hg help revsets | grep -i mq + "mq()" + Changesets managed by MQ. bad node in status