[PATCH 2 of 2] cat: do not instantiate subrepo if no potential match in it
Yuya Nishihara
yuya at tcha.org
Sat Nov 25 02:35:04 EST 2017
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1511593310 -32400
# Sat Nov 25 16:01:50 2017 +0900
# Node ID b6e526ee5d2662ca30a555ca51264b3e371fe44e
# Parent 38e952030f0c4746257280d47f0f94b6cb9ddb41
cat: do not instantiate subrepo if no potential match in it
This fixes the test failure in hg-git.
https://bitbucket.org/durin42/hg-git/issues/227/
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -3068,6 +3068,8 @@ def cat(ui, repo, ctx, matcher, basefm,
err = 0
for subpath in sorted(ctx.substate):
+ if not matcher.visitdir(subpath):
+ continue
sub = ctx.sub(subpath)
try:
submatch = matchmod.subdirmatcher(subpath, matcher)
diff --git a/tests/test-subrepo.t b/tests/test-subrepo.t
--- a/tests/test-subrepo.t
+++ b/tests/test-subrepo.t
@@ -1081,6 +1081,36 @@ Prepare a repo with subrepo
$ hg cat -T '{path}\n' 're:^sub'
sub/repo/foo (glob)
+ inaccessible subrepos:
+
+ $ mv sub sub_
+ $ touch sub
+ $ hg cat .hgsub .hgsubstate
+ sub/repo = sub/repo
+ f42d5c7504a811dda50f5cf3e5e16c3330b87172 sub/repo
+ $ hg cat sub/repo/foo
+ abort: *: '$TESTTMP/issue1852a/sub/repo' (glob)
+ [255]
+ $ rm sub
+ $ mv sub_ sub
+
+ symlink traversal:
+
+#if symlink
+
+ $ mv sub/repo sub/repo_
+ $ ln -s repo_ sub/repo
+ $ hg cat .hgsub .hgsubstate
+ sub/repo = sub/repo
+ f42d5c7504a811dda50f5cf3e5e16c3330b87172 sub/repo
+ $ hg cat sub/repo/foo
+ abort: subrepo 'sub/repo' traverses symbolic link
+ [255]
+ $ rm sub/repo
+ $ mv sub/repo_ sub/repo
+
+#endif
+
missing subrepos in working directory:
$ mkdir -p tmp/sub/repo
More information about the Mercurial-devel
mailing list