[PATCH] files: recurse into subrepos automatically with an explicit path
Augie Fackler
raf at durin42.com
Wed May 20 11:02:37 CDT 2015
This patch looks good to me.
> On May 19, 2015, at 22:13, Matt Harbison <mharbison72 at gmail.com> wrote:
>
> # HG changeset patch
> # User Matt Harbison <matt_harbison at yahoo.com>
> # Date 1431916967 14400
> # Sun May 17 22:42:47 2015 -0400
> # Node ID a956025619e7af9f1dff763430f07dac6b84fd13
> # Parent a39c35e8e559e238f311c647679e8de3b91748c6
> files: recurse into subrepos automatically with an explicit path
>
> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py
> +++ b/mercurial/cmdutil.py
> @@ -2297,12 +2297,16 @@
> fm.write('path', fmt, m.rel(f))
> ret = 0
>
> - if subrepos:
> - for subpath in sorted(ctx.substate):
> + for subpath in sorted(ctx.substate):
> + def matchessubrepo(subpath):
> + return (m.always() or m.exact(subpath)
> + or any(f.startswith(subpath + '/') for f in m.files()))
> +
> + if subrepos or matchessubrepo(subpath):
> sub = ctx.sub(subpath)
> try:
> submatch = matchmod.narrowmatcher(subpath, m)
> - if sub.printfiles(ui, submatch, fm, fmt) == 0:
> + if sub.printfiles(ui, submatch, fm, fmt, subrepos) == 0:
> ret = 0
> except error.LookupError:
> ui.status(_("skipping missing subrepository: %s\n")
> diff --git a/mercurial/help/subrepos.txt b/mercurial/help/subrepos.txt
> --- a/mercurial/help/subrepos.txt
> +++ b/mercurial/help/subrepos.txt
> @@ -109,8 +109,10 @@
> elements. Subversion subrepositories are currently silently ignored.
>
> :files: files does not recurse into subrepos unless -S/--subrepos is
> - specified. Git and Subversion subrepositories are currently
> - silently ignored.
> + specified. However, if you specify the full path of a file or
> + directory in a subrepo, it will be displayed even without
> + -S/--subrepos being specified. Git and Subversion subrepositories
> + are currently silently ignored.
>
> :forget: forget currently only handles exact file matches in subrepos.
> Git and Subversion subrepositories are currently silently ignored.
> diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
> --- a/mercurial/subrepo.py
> +++ b/mercurial/subrepo.py
> @@ -504,7 +504,7 @@
> """Resolve the fileset expression for this repo"""
> return set()
>
> - def printfiles(self, ui, m, fm, fmt):
> + def printfiles(self, ui, m, fm, fmt, subrepos):
> """handle the files command for this subrepo"""
> return 1
>
> @@ -904,7 +904,7 @@
> return ctx.flags(name)
>
> @annotatesubrepoerror
> - def printfiles(self, ui, m, fm, fmt):
> + def printfiles(self, ui, m, fm, fmt, subrepos):
> # If the parent context is a workingctx, use the workingctx here for
> # consistency.
> if self._ctx.rev() is None:
> @@ -912,7 +912,7 @@
> else:
> rev = self._state[1]
> ctx = self._repo[rev]
> - return cmdutil.files(ui, ctx, m, fm, fmt, True)
> + return cmdutil.files(ui, ctx, m, fm, fmt, subrepos)
>
> @annotatesubrepoerror
> def getfileset(self, expr):
> diff --git a/tests/test-subrepo-deep-nested-change.t b/tests/test-subrepo-deep-nested-change.t
> --- a/tests/test-subrepo-deep-nested-change.t
> +++ b/tests/test-subrepo-deep-nested-change.t
> @@ -232,6 +232,18 @@
> sub1/sub2/sub2 (glob)
> sub1/sub2/test.txt (glob)
>
> + $ hg files sub1
> + sub1/.hgsub (glob)
> + sub1/.hgsubstate (glob)
> + sub1/foo (glob)
> + sub1/sub1 (glob)
> + sub1/sub2/folder/bar (glob)
> + sub1/sub2/x.txt (glob)
> +
> + $ hg files sub1/sub2
> + sub1/sub2/folder/bar (glob)
> + sub1/sub2/x.txt (glob)
> +
> $ hg files -S -r '.^' sub1/sub2/folder
> sub1/sub2/folder/test.txt (glob)
>
> @@ -239,7 +251,7 @@
> sub1/sub2/missing: no such file in rev 78026e779ea6 (glob)
> [1]
>
> - $ hg files -S -r '.^' sub1/
> + $ hg files -r '.^' sub1/
> sub1/.hgsub (glob)
> sub1/.hgsubstate (glob)
> sub1/sub1 (glob)
> @@ -247,7 +259,7 @@
> sub1/sub2/sub2 (glob)
> sub1/sub2/test.txt (glob)
>
> - $ hg files -S -r '.^' sub1/sub2
> + $ hg files -r '.^' sub1/sub2
> sub1/sub2/folder/test.txt (glob)
> sub1/sub2/sub2 (glob)
> sub1/sub2/test.txt (glob)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list