context: don't complain about a matcher's subrepo paths in changectx.walk() stable
authorMatt Harbison <matt_harbison@yahoo.com>
Sun, 17 May 2015 01:06:10 -0400
branchstable
changeset 25193 ccb1623266eb
parent 25192 36111f98f23d
child 25194 ef4538ba67ef
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.
mercurial/context.py
tests/test-subrepo-deep-nested-change.t
--- 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
 
--- 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