[PATCH V2] fileset: add "subrepo" fileset symbol
Angel Ezquerra
angel.ezquerra at gmail.com
Mon Apr 9 17:01:13 CDT 2012
On Thu, Apr 5, 2012 at 11:55 PM, Matt Mackall <mpm at selenic.com> wrote:
> On Thu, 2012-03-29 at 00:15 +0200, Angel Ezquerra wrote:
>> # HG changeset patch
>> # User Angel Ezquerra <angel.ezquerra at gmail.com>
>> # Date 1332447135 -3600
>> # Node ID 77bd9f83cea1533f355b590f4d4fcec2cb09c641
>> # Parent ac4a19fe5d9a583639fde43fe9183553f946bc4c
>> fileset: add "subrepo" fileset symbol
>>
>> This new fileset symbol returns a list of subrepos whose path
>> matches a given pattern. If the argument has no pattern type set, an exact
>> match is performed.
>>
>> If no argument is passed, return a list of all subrepos.
>>
>> diff --git a/mercurial/fileset.py b/mercurial/fileset.py
>> --- a/mercurial/fileset.py
>> +++ b/mercurial/fileset.py
>> @@ -6,6 +6,7 @@
>> # GNU General Public License version 2 or any later version.
>>
>> import parser, error, util, merge, re
>> +import match as matchmod
>
> This probably introduces a dreaded recursive import.
>
> http://www.selenic.com/blog/?p=626
>
> See the hacks in revset for dealing with this.
Sorry for the late reply. I just came back from Easter vacation.
I don't really see what you mean here. I looked at revset.py and I
don't see anything that is being done differently there compared to
what I did on this patch. The only thing I see is that there is an
"import match as matchmod" and several calls to "matchmod.patkind" and
"matchmod.match". As far as I can tell this is exactly the same that I
am doing on my patch (which was inspired by the revset.py code in the
first place).
Did I miss something obvious?
>> from i18n import _
>>
>> elements = {
>> @@ -175,6 +176,27 @@
>> s = mctx.status()[6]
>> return [f for f in mctx.subset if f in s]
>>
>> +def subrepo(mctx, x):
>> + """``subrepo([pattern])``
>> + Subrepository that is modified and matches the selected pattern.
>
> modified?
Sorry about that. I'll fix it on the next version of the patch.
>> + """
>> + # i18n: "subrepo" is a keyword
>> + getargs(x, 0, 1, _("subrepo takes at most one argument"))
>> + ctx = mctx.ctx
>> + sstate = ctx.substate
>> + if x:
>> + pat = getstring(x, _("subrepo requires a glob pattern or no arguments"))
>
> Patterns needn't be globs, of course. They can also be regexes, lists
> read from files, filesets...
Right. I'll remove 'glob' and just leave 'pattern' in there.
Cheers,
Angel
More information about the Mercurial-devel
mailing list