mercurial/commands.py
changeset 726 809a870a0e73
parent 725 c6b912f8b5b2
child 727 acee766fcb79
equal deleted inserted replaced
725:c6b912f8b5b2 726:809a870a0e73
    63                        (fn.endswith('/') or patmatch(fn)))
    63                        (fn.endswith('/') or patmatch(fn)))
    64 
    64 
    65 def walk(repo, pats, opts):
    65 def walk(repo, pats, opts):
    66     cwd = repo.getcwd()
    66     cwd = repo.getcwd()
    67     if cwd: c = len(cwd) + 1
    67     if cwd: c = len(cwd) + 1
    68     for fn in repo.walk(match = matchpats(repo.ui, cwd, pats, opts)):
    68     for src, fn in repo.walk(match = matchpats(repo.ui, cwd, pats, opts)):
    69         if cwd: yield fn, fn[c:]
    69         if cwd: yield src, fn, fn[c:]
    70         else: yield fn, fn
    70         else: yield src, fn, fn
    71 
    71 
    72 revrangesep = ':'
    72 revrangesep = ':'
    73 
    73 
    74 def revrange(ui, repo, revs, revlog=None):
    74 def revrange(ui, repo, revs, revlog=None):
    75     if revlog is None:
    75     if revlog is None:
   323 
   323 
   324 def add(ui, repo, *pats, **opts):
   324 def add(ui, repo, *pats, **opts):
   325     '''add the specified files on the next commit'''
   325     '''add the specified files on the next commit'''
   326     names = []
   326     names = []
   327     q = dict(zip(pats, pats))
   327     q = dict(zip(pats, pats))
   328     for abs, rel in walk(repo, pats, opts):
   328     for src, abs, rel in walk(repo, pats, opts):
   329         if rel in q or abs in q:
   329         if rel in q or abs in q:
   330             names.append(abs)
   330             names.append(abs)
   331         elif repo.dirstate.state(abs) == '?':
   331         elif repo.dirstate.state(abs) == '?':
   332             ui.status('adding %s\n' % rel)
   332             ui.status('adding %s\n' % rel)
   333             names.append(abs)
   333             names.append(abs)
   713 def locate(ui, repo, *pats, **opts):
   713 def locate(ui, repo, *pats, **opts):
   714     """locate files matching specific patterns"""
   714     """locate files matching specific patterns"""
   715     if opts['print0']: end = '\0'
   715     if opts['print0']: end = '\0'
   716     else: end = '\n'
   716     else: end = '\n'
   717     opts['rootless'] = True
   717     opts['rootless'] = True
   718     for abs, rel in walk(repo, pats, opts):
   718     for src, abs, rel in walk(repo, pats, opts):
   719         if repo.dirstate.state(abs) == '?': continue
   719         if repo.dirstate.state(abs) == '?': continue
   720         if opts['fullpath']:
   720         if opts['fullpath']:
   721             ui.write(os.path.join(repo.root, abs), end)
   721             ui.write(os.path.join(repo.root, abs), end)
   722         else:
   722         else:
   723             ui.write(rel, end)
   723             ui.write(rel, end)