mercurial/sparse.py
changeset 33447 6f4e5e5940a5
parent 33376 d5a38eae67e5
child 33499 0407a51b9d8c
equal deleted inserted replaced
33446:fad6852cf879 33447:6f4e5e5940a5
   240     repo._sparsesignaturecache.clear()
   240     repo._sparsesignaturecache.clear()
   241     msg = _('cleaned up %d temporarily added file(s) from the '
   241     msg = _('cleaned up %d temporarily added file(s) from the '
   242             'sparse checkout\n')
   242             'sparse checkout\n')
   243     repo.ui.status(msg % len(tempincludes))
   243     repo.ui.status(msg % len(tempincludes))
   244 
   244 
       
   245 def forceincludematcher(matcher, includes):
       
   246     """Returns a matcher that returns true for any of the forced includes
       
   247     before testing against the actual matcher."""
       
   248     kindpats = [('path', include, '') for include in includes]
       
   249     includematcher = matchmod.includematcher('', '', kindpats)
       
   250     return matchmod.unionmatcher([includematcher, matcher])
       
   251 
   245 def matcher(repo, revs=None, includetemp=True):
   252 def matcher(repo, revs=None, includetemp=True):
   246     """Obtain a matcher for sparse working directories for the given revs.
   253     """Obtain a matcher for sparse working directories for the given revs.
   247 
   254 
   248     If multiple revisions are specified, the matcher is the union of all
   255     If multiple revisions are specified, the matcher is the union of all
   249     revs.
   256     revs.
   287 
   294 
   288                 matcher = matchmod.match(repo.root, '', [],
   295                 matcher = matchmod.match(repo.root, '', [],
   289                                          include=includes, exclude=excludes,
   296                                          include=includes, exclude=excludes,
   290                                          default='relpath')
   297                                          default='relpath')
   291                 if subdirs:
   298                 if subdirs:
   292                     matcher = matchmod.forceincludematcher(matcher, subdirs)
   299                     matcher = forceincludematcher(matcher, subdirs)
   293                 matchers.append(matcher)
   300                 matchers.append(matcher)
   294         except IOError:
   301         except IOError:
   295             pass
   302             pass
   296 
   303 
   297     if not matchers:
   304     if not matchers:
   301     else:
   308     else:
   302         result = matchmod.unionmatcher(matchers)
   309         result = matchmod.unionmatcher(matchers)
   303 
   310 
   304     if includetemp:
   311     if includetemp:
   305         tempincludes = readtemporaryincludes(repo)
   312         tempincludes = readtemporaryincludes(repo)
   306         result = matchmod.forceincludematcher(result, tempincludes)
   313         result = forceincludematcher(result, tempincludes)
   307 
   314 
   308     repo._sparsematchercache[key] = result
   315     repo._sparsematchercache[key] = result
   309 
   316 
   310     return result
   317     return result
   311 
   318