From patchwork Sun Mar 6 21:32:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [STABLE] files: don't recurse into subrepos without a path or -S (issue5127) From: Matt Harbison X-Patchwork-Id: 13634 Message-Id: To: mercurial-devel@mercurial-scm.org Date: Sun, 06 Mar 2016 16:32:21 -0500 # HG changeset patch # User Matt Harbison # Date 1457292634 18000 # Sun Mar 06 14:30:34 2016 -0500 # Branch stable # Node ID d13a8df63c98ab816da2ecc24fc5b67a86832113 # Parent 8949d73b2e1f5c0b9c4c6c195bef2fe284349c6e 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 --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -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 --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 @@ -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)