# HG changeset patch # User Idan Kamara # Date 1304687255 -10800 # Node ID 68ade2a6b30a47020884d4446c561c08e518b6d2 # Parent 08d84bdce1a5a52397a6fd1dd33537acf734e128 mq: add a 'mq()' revset predicate that returns applied mq csets diff -r 08d84bdce1a5 -r 68ade2a6b30a hgext/mq.py --- a/hgext/mq.py Fri May 06 10:17:07 2011 -0500 +++ b/hgext/mq.py Fri May 06 16:07:35 2011 +0300 @@ -45,7 +45,7 @@ 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 @@ 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 -r 08d84bdce1a5 -r 68ade2a6b30a tests/test-mq.t --- a/tests/test-mq.t Fri May 06 10:17:07 2011 -0500 +++ b/tests/test-mq.t Fri May 06 16:07:35 2011 +0300 @@ -843,6 +843,14 @@ 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