tests/test-match.py
changeset 43964 8f67735344ae
parent 43949 8b1a9ba375e5
child 45942 89a2afe31e82
--- a/tests/test-match.py	Fri Dec 27 16:47:47 2019 +0100
+++ b/tests/test-match.py	Thu Dec 26 16:45:56 2019 -0500
@@ -66,7 +66,9 @@
 
 class PatternMatcherTests(unittest.TestCase):
     def testVisitdirPrefix(self):
-        m = matchmod.match(b'/repo', b'', patterns=[b'path:dir/subdir'])
+        m = matchmod.match(
+            util.localpath(b'/repo'), b'', patterns=[b'path:dir/subdir']
+        )
         assert isinstance(m, matchmod.patternmatcher)
         self.assertTrue(m.visitdir(b''))
         self.assertTrue(m.visitdir(b'dir'))
@@ -76,7 +78,9 @@
         self.assertFalse(m.visitdir(b'folder'))
 
     def testVisitchildrensetPrefix(self):
-        m = matchmod.match(b'/repo', b'', patterns=[b'path:dir/subdir'])
+        m = matchmod.match(
+            util.localpath(b'/repo'), b'', patterns=[b'path:dir/subdir']
+        )
         assert isinstance(m, matchmod.patternmatcher)
         self.assertEqual(m.visitchildrenset(b''), b'this')
         self.assertEqual(m.visitchildrenset(b'dir'), b'this')
@@ -86,7 +90,9 @@
         self.assertEqual(m.visitchildrenset(b'folder'), set())
 
     def testVisitdirRootfilesin(self):
-        m = matchmod.match(b'/repo', b'', patterns=[b'rootfilesin:dir/subdir'])
+        m = matchmod.match(
+            util.localpath(b'/repo'), b'', patterns=[b'rootfilesin:dir/subdir'],
+        )
         assert isinstance(m, matchmod.patternmatcher)
         self.assertFalse(m.visitdir(b'dir/subdir/x'))
         self.assertFalse(m.visitdir(b'folder'))
@@ -96,7 +102,9 @@
         self.assertFalse(m.visitdir(b'dir/subdir'))
 
     def testVisitchildrensetRootfilesin(self):
-        m = matchmod.match(b'/repo', b'', patterns=[b'rootfilesin:dir/subdir'])
+        m = matchmod.match(
+            util.localpath(b'/repo'), b'', patterns=[b'rootfilesin:dir/subdir'],
+        )
         assert isinstance(m, matchmod.patternmatcher)
         self.assertEqual(m.visitchildrenset(b'dir/subdir/x'), set())
         self.assertEqual(m.visitchildrenset(b'folder'), set())
@@ -107,7 +115,9 @@
         self.assertEqual(m.visitchildrenset(b'dir/subdir'), set())
 
     def testVisitdirGlob(self):
-        m = matchmod.match(b'/repo', b'', patterns=[b'glob:dir/z*'])
+        m = matchmod.match(
+            util.localpath(b'/repo'), b'', patterns=[b'glob:dir/z*']
+        )
         assert isinstance(m, matchmod.patternmatcher)
         self.assertTrue(m.visitdir(b''))
         self.assertTrue(m.visitdir(b'dir'))
@@ -117,7 +127,9 @@
         self.assertTrue(m.visitdir(b'dir/subdir/x'))
 
     def testVisitchildrensetGlob(self):
-        m = matchmod.match(b'/repo', b'', patterns=[b'glob:dir/z*'])
+        m = matchmod.match(
+            util.localpath(b'/repo'), b'', patterns=[b'glob:dir/z*']
+        )
         assert isinstance(m, matchmod.patternmatcher)
         self.assertEqual(m.visitchildrenset(b''), b'this')
         self.assertEqual(m.visitchildrenset(b'folder'), set())
@@ -129,7 +141,9 @@
 
 class IncludeMatcherTests(unittest.TestCase):
     def testVisitdirPrefix(self):
-        m = matchmod.match(b'/repo', b'', include=[b'path:dir/subdir'])
+        m = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
+        )
         assert isinstance(m, matchmod.includematcher)
         self.assertTrue(m.visitdir(b''))
         self.assertTrue(m.visitdir(b'dir'))
@@ -139,7 +153,9 @@
         self.assertFalse(m.visitdir(b'folder'))
 
     def testVisitchildrensetPrefix(self):
-        m = matchmod.match(b'/repo', b'', include=[b'path:dir/subdir'])
+        m = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
+        )
         assert isinstance(m, matchmod.includematcher)
         self.assertEqual(m.visitchildrenset(b''), {b'dir'})
         self.assertEqual(m.visitchildrenset(b'dir'), {b'subdir'})
@@ -149,7 +165,9 @@
         self.assertEqual(m.visitchildrenset(b'folder'), set())
 
     def testVisitdirRootfilesin(self):
-        m = matchmod.match(b'/repo', b'', include=[b'rootfilesin:dir/subdir'])
+        m = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'rootfilesin:dir/subdir']
+        )
         assert isinstance(m, matchmod.includematcher)
         self.assertTrue(m.visitdir(b''))
         self.assertTrue(m.visitdir(b'dir'))
@@ -158,7 +176,9 @@
         self.assertFalse(m.visitdir(b'folder'))
 
     def testVisitchildrensetRootfilesin(self):
-        m = matchmod.match(b'/repo', b'', include=[b'rootfilesin:dir/subdir'])
+        m = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'rootfilesin:dir/subdir']
+        )
         assert isinstance(m, matchmod.includematcher)
         self.assertEqual(m.visitchildrenset(b''), {b'dir'})
         self.assertEqual(m.visitchildrenset(b'dir'), {b'subdir'})
@@ -167,7 +187,9 @@
         self.assertEqual(m.visitchildrenset(b'folder'), set())
 
     def testVisitdirGlob(self):
-        m = matchmod.match(b'/repo', b'', include=[b'glob:dir/z*'])
+        m = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'glob:dir/z*']
+        )
         assert isinstance(m, matchmod.includematcher)
         self.assertTrue(m.visitdir(b''))
         self.assertTrue(m.visitdir(b'dir'))
@@ -177,7 +199,9 @@
         self.assertTrue(m.visitdir(b'dir/subdir/x'))
 
     def testVisitchildrensetGlob(self):
-        m = matchmod.match(b'/repo', b'', include=[b'glob:dir/z*'])
+        m = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'glob:dir/z*']
+        )
         assert isinstance(m, matchmod.includematcher)
         self.assertEqual(m.visitchildrenset(b''), {b'dir'})
         self.assertEqual(m.visitchildrenset(b'folder'), set())
@@ -289,7 +313,9 @@
 
     def testVisitdirM2SubdirPrefix(self):
         m1 = matchmod.alwaysmatcher()
-        m2 = matchmod.match(b'/repo', b'', patterns=[b'path:dir/subdir'])
+        m2 = matchmod.match(
+            util.localpath(b'/repo'), b'', patterns=[b'path:dir/subdir']
+        )
         dm = matchmod.differencematcher(m1, m2)
         self.assertEqual(dm.visitdir(b''), True)
         self.assertEqual(dm.visitdir(b'dir'), True)
@@ -304,7 +330,9 @@
 
     def testVisitchildrensetM2SubdirPrefix(self):
         m1 = matchmod.alwaysmatcher()
-        m2 = matchmod.match(b'/repo', b'', patterns=[b'path:dir/subdir'])
+        m2 = matchmod.match(
+            util.localpath(b'/repo'), b'', patterns=[b'path:dir/subdir']
+        )
         dm = matchmod.differencematcher(m1, m2)
         self.assertEqual(dm.visitchildrenset(b''), b'this')
         self.assertEqual(dm.visitchildrenset(b'dir'), b'this')
@@ -320,8 +348,12 @@
     # We're using includematcher instead of patterns because it behaves slightly
     # better (giving narrower results) than patternmatcher.
     def testVisitdirIncludeInclude(self):
-        m1 = matchmod.match(b'/repo', b'', include=[b'path:dir/subdir'])
-        m2 = matchmod.match(b'/repo', b'', include=[b'rootfilesin:dir'])
+        m1 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
+        )
+        m2 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'rootfilesin:dir']
+        )
         dm = matchmod.differencematcher(m1, m2)
         self.assertEqual(dm.visitdir(b''), True)
         self.assertEqual(dm.visitdir(b'dir'), True)
@@ -335,8 +367,12 @@
         self.assertEqual(dm.visitdir(b'dir/subdir/x'), True)
 
     def testVisitchildrensetIncludeInclude(self):
-        m1 = matchmod.match(b'/repo', b'', include=[b'path:dir/subdir'])
-        m2 = matchmod.match(b'/repo', b'', include=[b'rootfilesin:dir'])
+        m1 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
+        )
+        m2 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'rootfilesin:dir']
+        )
         dm = matchmod.differencematcher(m1, m2)
         self.assertEqual(dm.visitchildrenset(b''), {b'dir'})
         self.assertEqual(dm.visitchildrenset(b'dir'), {b'subdir'})
@@ -405,7 +441,9 @@
 
     def testVisitdirM2SubdirPrefix(self):
         m1 = matchmod.alwaysmatcher()
-        m2 = matchmod.match(b'/repo', b'', patterns=[b'path:dir/subdir'])
+        m2 = matchmod.match(
+            util.localpath(b'/repo'), b'', patterns=[b'path:dir/subdir']
+        )
         im = matchmod.intersectmatchers(m1, m2)
         self.assertEqual(im.visitdir(b''), True)
         self.assertEqual(im.visitdir(b'dir'), True)
@@ -420,7 +458,9 @@
 
     def testVisitchildrensetM2SubdirPrefix(self):
         m1 = matchmod.alwaysmatcher()
-        m2 = matchmod.match(b'/repo', b'', include=[b'path:dir/subdir'])
+        m2 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
+        )
         im = matchmod.intersectmatchers(m1, m2)
         self.assertEqual(im.visitchildrenset(b''), {b'dir'})
         self.assertEqual(im.visitchildrenset(b'dir'), {b'subdir'})
@@ -434,8 +474,12 @@
     # We're using includematcher instead of patterns because it behaves slightly
     # better (giving narrower results) than patternmatcher.
     def testVisitdirIncludeInclude(self):
-        m1 = matchmod.match(b'/repo', b'', include=[b'path:dir/subdir'])
-        m2 = matchmod.match(b'/repo', b'', include=[b'rootfilesin:dir'])
+        m1 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
+        )
+        m2 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'rootfilesin:dir']
+        )
         im = matchmod.intersectmatchers(m1, m2)
         self.assertEqual(im.visitdir(b''), True)
         self.assertEqual(im.visitdir(b'dir'), True)
@@ -446,8 +490,12 @@
         self.assertFalse(im.visitdir(b'dir/subdir/x'))
 
     def testVisitchildrensetIncludeInclude(self):
-        m1 = matchmod.match(b'/repo', b'', include=[b'path:dir/subdir'])
-        m2 = matchmod.match(b'/repo', b'', include=[b'rootfilesin:dir'])
+        m1 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
+        )
+        m2 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'rootfilesin:dir']
+        )
         im = matchmod.intersectmatchers(m1, m2)
         self.assertEqual(im.visitchildrenset(b''), {b'dir'})
         self.assertEqual(im.visitchildrenset(b'dir'), b'this')
@@ -460,8 +508,12 @@
     # We're using includematcher instead of patterns because it behaves slightly
     # better (giving narrower results) than patternmatcher.
     def testVisitdirIncludeInclude2(self):
-        m1 = matchmod.match(b'/repo', b'', include=[b'path:dir/subdir'])
-        m2 = matchmod.match(b'/repo', b'', include=[b'path:folder'])
+        m1 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
+        )
+        m2 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:folder']
+        )
         im = matchmod.intersectmatchers(m1, m2)
         # FIXME: is True correct here?
         self.assertEqual(im.visitdir(b''), True)
@@ -473,8 +525,12 @@
         self.assertFalse(im.visitdir(b'dir/subdir/x'))
 
     def testVisitchildrensetIncludeInclude2(self):
-        m1 = matchmod.match(b'/repo', b'', include=[b'path:dir/subdir'])
-        m2 = matchmod.match(b'/repo', b'', include=[b'path:folder'])
+        m1 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
+        )
+        m2 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:folder']
+        )
         im = matchmod.intersectmatchers(m1, m2)
         # FIXME: is set() correct here?
         self.assertEqual(im.visitchildrenset(b''), set())
@@ -488,8 +544,12 @@
     # We're using includematcher instead of patterns because it behaves slightly
     # better (giving narrower results) than patternmatcher.
     def testVisitdirIncludeInclude3(self):
-        m1 = matchmod.match(b'/repo', b'', include=[b'path:dir/subdir/x'])
-        m2 = matchmod.match(b'/repo', b'', include=[b'path:dir/subdir'])
+        m1 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/x']
+        )
+        m2 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
+        )
         im = matchmod.intersectmatchers(m1, m2)
         self.assertEqual(im.visitdir(b''), True)
         self.assertEqual(im.visitdir(b'dir'), True)
@@ -501,8 +561,12 @@
         self.assertEqual(im.visitdir(b'dir/subdir/x'), True)
 
     def testVisitchildrensetIncludeInclude3(self):
-        m1 = matchmod.match(b'/repo', b'', include=[b'path:dir/subdir/x'])
-        m2 = matchmod.match(b'/repo', b'', include=[b'path:dir/subdir'])
+        m1 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/x']
+        )
+        m2 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
+        )
         im = matchmod.intersectmatchers(m1, m2)
         self.assertEqual(im.visitchildrenset(b''), {b'dir'})
         self.assertEqual(im.visitchildrenset(b'dir'), {b'subdir'})
@@ -516,8 +580,12 @@
     # We're using includematcher instead of patterns because it behaves slightly
     # better (giving narrower results) than patternmatcher.
     def testVisitdirIncludeInclude4(self):
-        m1 = matchmod.match(b'/repo', b'', include=[b'path:dir/subdir/x'])
-        m2 = matchmod.match(b'/repo', b'', include=[b'path:dir/subdir/z'])
+        m1 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/x']
+        )
+        m2 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/z']
+        )
         im = matchmod.intersectmatchers(m1, m2)
         # OPT: these next three could probably be False as well.
         self.assertEqual(im.visitdir(b''), True)
@@ -529,8 +597,12 @@
         self.assertFalse(im.visitdir(b'dir/subdir/x'))
 
     def testVisitchildrensetIncludeInclude4(self):
-        m1 = matchmod.match(b'/repo', b'', include=[b'path:dir/subdir/x'])
-        m2 = matchmod.match(b'/repo', b'', include=[b'path:dir/subdir/z'])
+        m1 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/x']
+        )
+        m2 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/z']
+        )
         im = matchmod.intersectmatchers(m1, m2)
         # OPT: these next two could probably be set() as well.
         self.assertEqual(im.visitchildrenset(b''), {b'dir'})
@@ -623,7 +695,9 @@
 
     def testVisitdirM2SubdirPrefix(self):
         m1 = matchmod.alwaysmatcher()
-        m2 = matchmod.match(b'/repo', b'', patterns=[b'path:dir/subdir'])
+        m2 = matchmod.match(
+            util.localpath(b'/repo'), b'', patterns=[b'path:dir/subdir']
+        )
         um = matchmod.unionmatcher([m1, m2])
         self.assertEqual(um.visitdir(b''), b'all')
         self.assertEqual(um.visitdir(b'dir'), b'all')
@@ -635,7 +709,9 @@
 
     def testVisitchildrensetM2SubdirPrefix(self):
         m1 = matchmod.alwaysmatcher()
-        m2 = matchmod.match(b'/repo', b'', include=[b'path:dir/subdir'])
+        m2 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
+        )
         um = matchmod.unionmatcher([m1, m2])
         self.assertEqual(um.visitchildrenset(b''), b'all')
         self.assertEqual(um.visitchildrenset(b'dir'), b'all')
@@ -648,8 +724,12 @@
     # We're using includematcher instead of patterns because it behaves slightly
     # better (giving narrower results) than patternmatcher.
     def testVisitdirIncludeInclude(self):
-        m1 = matchmod.match(b'/repo', b'', include=[b'path:dir/subdir'])
-        m2 = matchmod.match(b'/repo', b'', include=[b'rootfilesin:dir'])
+        m1 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
+        )
+        m2 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'rootfilesin:dir']
+        )
         um = matchmod.unionmatcher([m1, m2])
         self.assertEqual(um.visitdir(b''), True)
         self.assertEqual(um.visitdir(b'dir'), True)
@@ -661,8 +741,12 @@
         self.assertEqual(um.visitdir(b'dir/subdir/x'), True)
 
     def testVisitchildrensetIncludeInclude(self):
-        m1 = matchmod.match(b'/repo', b'', include=[b'path:dir/subdir'])
-        m2 = matchmod.match(b'/repo', b'', include=[b'rootfilesin:dir'])
+        m1 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
+        )
+        m2 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'rootfilesin:dir']
+        )
         um = matchmod.unionmatcher([m1, m2])
         self.assertEqual(um.visitchildrenset(b''), {b'dir'})
         self.assertEqual(um.visitchildrenset(b'dir'), b'this')
@@ -676,8 +760,12 @@
     # We're using includematcher instead of patterns because it behaves slightly
     # better (giving narrower results) than patternmatcher.
     def testVisitdirIncludeInclude2(self):
-        m1 = matchmod.match(b'/repo', b'', include=[b'path:dir/subdir'])
-        m2 = matchmod.match(b'/repo', b'', include=[b'path:folder'])
+        m1 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
+        )
+        m2 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:folder']
+        )
         um = matchmod.unionmatcher([m1, m2])
         self.assertEqual(um.visitdir(b''), True)
         self.assertEqual(um.visitdir(b'dir'), True)
@@ -689,8 +777,12 @@
         self.assertEqual(um.visitdir(b'dir/subdir/x'), True)
 
     def testVisitchildrensetIncludeInclude2(self):
-        m1 = matchmod.match(b'/repo', b'', include=[b'path:dir/subdir'])
-        m2 = matchmod.match(b'/repo', b'', include=[b'path:folder'])
+        m1 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
+        )
+        m2 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:folder']
+        )
         um = matchmod.unionmatcher([m1, m2])
         self.assertEqual(um.visitchildrenset(b''), {b'folder', b'dir'})
         self.assertEqual(um.visitchildrenset(b'dir'), {b'subdir'})
@@ -704,8 +796,12 @@
     # We're using includematcher instead of patterns because it behaves slightly
     # better (giving narrower results) than patternmatcher.
     def testVisitdirIncludeInclude3(self):
-        m1 = matchmod.match(b'/repo', b'', include=[b'path:dir/subdir/x'])
-        m2 = matchmod.match(b'/repo', b'', include=[b'path:dir/subdir'])
+        m1 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/x']
+        )
+        m2 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
+        )
         um = matchmod.unionmatcher([m1, m2])
         self.assertEqual(um.visitdir(b''), True)
         self.assertEqual(um.visitdir(b'dir'), True)
@@ -717,8 +813,12 @@
         self.assertEqual(um.visitdir(b'dir/subdir/z'), True)
 
     def testVisitchildrensetIncludeInclude3(self):
-        m1 = matchmod.match(b'/repo', b'', include=[b'path:dir/subdir/x'])
-        m2 = matchmod.match(b'/repo', b'', include=[b'path:dir/subdir'])
+        m1 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/x']
+        )
+        m2 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
+        )
         um = matchmod.unionmatcher([m1, m2])
         self.assertEqual(um.visitchildrenset(b''), {b'dir'})
         self.assertEqual(um.visitchildrenset(b'dir'), {b'subdir'})
@@ -732,8 +832,12 @@
     # We're using includematcher instead of patterns because it behaves slightly
     # better (giving narrower results) than patternmatcher.
     def testVisitdirIncludeInclude4(self):
-        m1 = matchmod.match(b'/repo', b'', include=[b'path:dir/subdir/x'])
-        m2 = matchmod.match(b'/repo', b'', include=[b'path:dir/subdir/z'])
+        m1 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/x']
+        )
+        m2 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/z']
+        )
         um = matchmod.unionmatcher([m1, m2])
         # OPT: these next three could probably be False as well.
         self.assertEqual(um.visitdir(b''), True)
@@ -745,8 +849,12 @@
         self.assertEqual(um.visitdir(b'dir/subdir/x'), b'all')
 
     def testVisitchildrensetIncludeInclude4(self):
-        m1 = matchmod.match(b'/repo', b'', include=[b'path:dir/subdir/x'])
-        m2 = matchmod.match(b'/repo', b'', include=[b'path:dir/subdir/z'])
+        m1 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/x']
+        )
+        m2 = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/z']
+        )
         um = matchmod.unionmatcher([m1, m2])
         self.assertEqual(um.visitchildrenset(b''), {b'dir'})
         self.assertEqual(um.visitchildrenset(b'dir'), {b'subdir'})
@@ -759,7 +867,9 @@
 
 class SubdirMatcherTests(unittest.TestCase):
     def testVisitdir(self):
-        m = matchmod.match(b'/repo', b'', include=[b'path:dir/subdir'])
+        m = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
+        )
         sm = matchmod.subdirmatcher(b'dir', m)
 
         self.assertEqual(sm.visitdir(b''), True)
@@ -770,7 +880,9 @@
         self.assertFalse(sm.visitdir(b'foo'))
 
     def testVisitchildrenset(self):
-        m = matchmod.match(b'/repo', b'', include=[b'path:dir/subdir'])
+        m = matchmod.match(
+            util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
+        )
         sm = matchmod.subdirmatcher(b'dir', m)
 
         self.assertEqual(sm.visitchildrenset(b''), {b'subdir'})