# HG changeset patch # User Matt Harbison # Date 1457292634 18000 # Node ID 97175d9bf7cf14db3747ff3f2b093ea2ed34db95 # Parent b7e192240c41db8d02419b7bcd2be9a2b6194023 files: don't recurse into subrepos without a path or -S (issue5127) The 'm.always()' check was needed for when a path to 'sub1' is given, and 'sub1' contains a subrepo itself. But that also caused the automatic recursion when no path was given. Instead, force -S when printing a subrepo if the subpath is an exact match (which will unconditionally recurse once in the nested subrepo). diff -r b7e192240c41 -r 97175d9bf7cf mercurial/cmdutil.py --- a/mercurial/cmdutil.py Tue Jan 26 22:44:29 2016 +0900 +++ b/mercurial/cmdutil.py Sun Mar 06 14:30:34 2016 -0500 @@ -2340,14 +2340,15 @@ for subpath in sorted(ctx.substate): def matchessubrepo(subpath): - return (m.always() or m.exact(subpath) + return (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, subrepos) == 0: + recurse = m.exact(subpath) or subrepos + if sub.printfiles(ui, submatch, fm, fmt, recurse) == 0: ret = 0 except error.LookupError: ui.status(_("skipping missing subrepository: %s\n") diff -r b7e192240c41 -r 97175d9bf7cf tests/test-subrepo-deep-nested-change.t --- a/tests/test-subrepo-deep-nested-change.t Tue Jan 26 22:44:29 2016 +0900 +++ b/tests/test-subrepo-deep-nested-change.t Sun Mar 06 14:30:34 2016 -0500 @@ -297,6 +297,12 @@ sub1/sub2/folder/bar (glob) sub1/sub2/x.txt (glob) + $ hg files + .hgsub + .hgsubstate + foo/bar/abc (glob) + main + $ hg files -S -r '.^' sub1/sub2/folder sub1/sub2/folder/test.txt (glob)