mercurial/match.py
changeset 28017 d3f1b7ee5e70
parent 27595 9e2d01707e71
child 28128 92f2c69ee5a5
equal deleted inserted replaced
28016:a2be6f0f58fb 28017:d3f1b7ee5e70
   332     """
   332     """
   333     m = copy.copy(match)
   333     m = copy.copy(match)
   334     m.bad = badfn
   334     m.bad = badfn
   335     return m
   335     return m
   336 
   336 
   337 class narrowmatcher(match):
   337 class subdirmatcher(match):
   338     """Adapt a matcher to work on a subdirectory only.
   338     """Adapt a matcher to work on a subdirectory only.
   339 
   339 
   340     The paths are remapped to remove/insert the path as needed:
   340     The paths are remapped to remove/insert the path as needed:
   341 
   341 
   342     >>> m1 = match('root', '', ['a.txt', 'sub/b.txt'])
   342     >>> m1 = match('root', '', ['a.txt', 'sub/b.txt'])
   343     >>> m2 = narrowmatcher('sub', m1)
   343     >>> m2 = subdirmatcher('sub', m1)
   344     >>> bool(m2('a.txt'))
   344     >>> bool(m2('a.txt'))
   345     False
   345     False
   346     >>> bool(m2('b.txt'))
   346     >>> bool(m2('b.txt'))
   347     True
   347     True
   348     >>> bool(m2.matchfn('a.txt'))
   348     >>> bool(m2.matchfn('a.txt'))