# HG changeset patch # User Matt Harbison # Date 1431839170 14400 # Node ID ccb1623266ebb941aa3cb93477d0644476748369 # Parent 36111f98f23da6dff4a734de83675f27e876105c context: don't complain about a matcher's subrepo paths in changectx.walk() Previously, the first added test printed the following: $ hg files -S -r '.^' sub1/sub2/folder sub1/sub2/folder: no such file in rev 9bb10eebee29 sub1/sub2/folder: no such file in rev 9bb10eebee29 sub1/sub2/folder/test.txt One warning occured each time a subrepo was crossed into. The second test ensures that the matcher copy stays in place. Without the copy, the bad() function becomes an increasingly longer chain, and no message would be printed out for a file missing in the subrepo because the predicate would match in one of the replaced methods. Manifest doesn't know anything about subrepos, so it needs help ignoring subrepos when complaining about bad files. diff -r 36111f98f23d -r ccb1623266eb mercurial/context.py --- a/mercurial/context.py Mon May 18 22:35:27 2015 -0500 +++ b/mercurial/context.py Sun May 17 01:06:10 2015 -0400 @@ -9,7 +9,7 @@ from i18n import _ import mdiff, error, util, scmutil, subrepo, patch, encoding, phases import match as matchmod -import os, errno, stat +import copy, os, errno, stat import obsolete as obsmod import repoview import fileset @@ -590,8 +590,14 @@ '''Generates matching file names.''' # Override match.bad method to have message with nodeid + match = copy.copy(match) oldbad = match.bad def bad(fn, msg): + # The manifest doesn't know about subrepos, so don't complain about + # paths into valid subrepos. + if util.any(fn == s or fn.startswith(s + '/') + for s in self.substate): + return oldbad(fn, _('no such file in rev %s') % self) match.bad = bad diff -r 36111f98f23d -r ccb1623266eb tests/test-subrepo-deep-nested-change.t --- a/tests/test-subrepo-deep-nested-change.t Mon May 18 22:35:27 2015 -0500 +++ b/tests/test-subrepo-deep-nested-change.t Sun May 17 01:06:10 2015 -0400 @@ -209,6 +209,13 @@ sub1/sub2/folder/bar (glob) sub1/sub2/x.txt (glob) + $ hg files -S -r '.^' sub1/sub2/folder + sub1/sub2/folder/test.txt (glob) + + $ hg files -S -r '.^' sub1/sub2/missing + sub1/sub2/missing: no such file in rev 78026e779ea6 (glob) + [1] + $ hg rollback -q $ hg up -Cq