mercurial/cmdutil.py
changeset 4055 e37786b29bed
parent 3838 dec4eba7ccad
child 4059 431f3c1d3a37
child 4181 08d31e43592a
child 4204 f9bbcebcacea
equal deleted inserted replaced
4054:e6d54283c090 4055:e37786b29bed
   125         return pat
   125         return pat
   126     return open(make_filename(repo, pat, node, total, seqno, revwidth,
   126     return open(make_filename(repo, pat, node, total, seqno, revwidth,
   127                               pathname),
   127                               pathname),
   128                 mode)
   128                 mode)
   129 
   129 
   130 def matchpats(repo, pats=[], opts={}, head=''):
   130 def matchpats(repo, pats=[], opts={}, head='', globbed=False):
   131     cwd = repo.getcwd()
   131     cwd = repo.getcwd()
   132     if not pats and cwd:
   132     if not pats and cwd:
   133         opts['include'] = [os.path.join(cwd, i)
   133         opts['include'] = [os.path.join(cwd, i)
   134                            for i in opts.get('include', [])]
   134                            for i in opts.get('include', [])]
   135         opts['exclude'] = [os.path.join(cwd, x)
   135         opts['exclude'] = [os.path.join(cwd, x)
   136                            for x in opts.get('exclude', [])]
   136                            for x in opts.get('exclude', [])]
   137         cwd = ''
   137         cwd = ''
   138     return util.cmdmatcher(repo.root, cwd, pats or ['.'], opts.get('include'),
   138     return util.cmdmatcher(repo.root, cwd, pats or ['.'], opts.get('include'),
   139                            opts.get('exclude'), head)
   139                            opts.get('exclude'), head, globbed=globbed)
   140 
   140 
   141 def walk(repo, pats=[], opts={}, node=None, head='', badmatch=None):
   141 def walk(repo, pats=[], opts={}, node=None, head='', badmatch=None,
   142     files, matchfn, anypats = matchpats(repo, pats, opts, head)
   142          globbed=False):
       
   143     files, matchfn, anypats = matchpats(repo, pats, opts, head,
       
   144                                         globbed=globbed)
   143     exact = dict.fromkeys(files)
   145     exact = dict.fromkeys(files)
   144     for src, fn in repo.walk(node=node, files=files, match=matchfn,
   146     for src, fn in repo.walk(node=node, files=files, match=matchfn,
   145                              badmatch=badmatch):
   147                              badmatch=badmatch):
   146         yield src, fn, util.pathto(repo.getcwd(), fn), fn in exact
   148         yield src, fn, util.pathto(repo.getcwd(), fn), fn in exact
   147 
   149