[PATCH V2] fileset: add "subrepo" fileset symbol

Matt Mackall mpm at selenic.com
Thu Apr 5 16:55:49 CDT 2012


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.

>  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?

> +    """
> +    # 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...

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list