mercurial/scmutil.py
changeset 21111 9d28fd795215
parent 20980 6fb4c94ae300
child 21563 764b691b8bda
equal deleted inserted replaced
21110:49e13e76ec5a 21111:9d28fd795215
   562             l = m(repo, revset.spanset(repo))
   562             l = m(repo, revset.spanset(repo))
   563 
   563 
   564     return l
   564     return l
   565 
   565 
   566 def expandpats(pats):
   566 def expandpats(pats):
       
   567     '''Expand bare globs when running on windows.
       
   568     On posix we assume it already has already been done by sh.'''
   567     if not util.expandglobs:
   569     if not util.expandglobs:
   568         return list(pats)
   570         return list(pats)
   569     ret = []
   571     ret = []
   570     for p in pats:
   572     for kindpat in pats:
   571         kind, name = matchmod._patsplit(p, None)
   573         kind, pat = matchmod._patsplit(kindpat, None)
   572         if kind is None:
   574         if kind is None:
   573             try:
   575             try:
   574                 globbed = glob.glob(name)
   576                 globbed = glob.glob(pat)
   575             except re.error:
   577             except re.error:
   576                 globbed = [name]
   578                 globbed = [pat]
   577             if globbed:
   579             if globbed:
   578                 ret.extend(globbed)
   580                 ret.extend(globbed)
   579                 continue
   581                 continue
   580         ret.append(p)
   582         ret.append(kindpat)
   581     return ret
   583     return ret
   582 
   584 
   583 def matchandpats(ctx, pats=[], opts={}, globbed=False, default='relpath'):
   585 def matchandpats(ctx, pats=[], opts={}, globbed=False, default='relpath'):
       
   586     '''Return a matcher and the patterns that were used.
       
   587     The matcher will warn about bad matches.'''
   584     if pats == ("",):
   588     if pats == ("",):
   585         pats = []
   589         pats = []
   586     if not globbed and default == 'relpath':
   590     if not globbed and default == 'relpath':
   587         pats = expandpats(pats or [])
   591         pats = expandpats(pats or [])
   588 
   592 
   592         ctx._repo.ui.warn("%s: %s\n" % (m.rel(f), msg))
   596         ctx._repo.ui.warn("%s: %s\n" % (m.rel(f), msg))
   593     m.bad = badfn
   597     m.bad = badfn
   594     return m, pats
   598     return m, pats
   595 
   599 
   596 def match(ctx, pats=[], opts={}, globbed=False, default='relpath'):
   600 def match(ctx, pats=[], opts={}, globbed=False, default='relpath'):
       
   601     '''Return a matcher that will warn about bad matches.'''
   597     return matchandpats(ctx, pats, opts, globbed, default)[0]
   602     return matchandpats(ctx, pats, opts, globbed, default)[0]
   598 
   603 
   599 def matchall(repo):
   604 def matchall(repo):
       
   605     '''Return a matcher that will efficiently match everything.'''
   600     return matchmod.always(repo.root, repo.getcwd())
   606     return matchmod.always(repo.root, repo.getcwd())
   601 
   607 
   602 def matchfiles(repo, files):
   608 def matchfiles(repo, files):
       
   609     '''Return a matcher that will efficiently match exactly these files.'''
   603     return matchmod.exact(repo.root, repo.getcwd(), files)
   610     return matchmod.exact(repo.root, repo.getcwd(), files)
   604 
   611 
   605 def addremove(repo, pats=[], opts={}, dry_run=None, similarity=None):
   612 def addremove(repo, pats=[], opts={}, dry_run=None, similarity=None):
   606     if dry_run is None:
   613     if dry_run is None:
   607         dry_run = opts.get('dry_run')
   614         dry_run = opts.get('dry_run')