##// END OF EJS Templates
Modify commands.walk to yield a 4-tuple....
Bryan O'Sullivan -
r942:7eb8cbcc default
parent child Browse files
Show More
@@ -42,9 +42,10 b' def matchpats(repo, cwd, pats = [], opts'
42 def makewalk(repo, pats, opts, head = ''):
42 def makewalk(repo, pats, opts, head = ''):
43 cwd = repo.getcwd()
43 cwd = repo.getcwd()
44 files, matchfn = matchpats(repo, cwd, pats, opts, head)
44 files, matchfn = matchpats(repo, cwd, pats, opts, head)
45 exact = dict(zip(files, files))
45 def walk():
46 def walk():
46 for src, fn in repo.walk(files = files, match = matchfn):
47 for src, fn in repo.walk(files = files, match = matchfn):
47 yield src, fn, util.pathto(cwd, fn)
48 yield src, fn, util.pathto(cwd, fn), fn in exact
48 return files, matchfn, walk()
49 return files, matchfn, walk()
49
50
50 def walk(repo, pats, opts, head = ''):
51 def walk(repo, pats, opts, head = ''):
@@ -375,9 +376,8 b' def help_(ui, cmd=None):'
375 def add(ui, repo, *pats, **opts):
376 def add(ui, repo, *pats, **opts):
376 '''add the specified files on the next commit'''
377 '''add the specified files on the next commit'''
377 names = []
378 names = []
378 q = dict(zip(pats, pats))
379 for src, abs, rel, exact in walk(repo, pats, opts):
379 for src, abs, rel in walk(repo, pats, opts):
380 if exact:
380 if rel in q or abs in q:
381 names.append(abs)
381 names.append(abs)
382 elif repo.dirstate.state(abs) == '?':
382 elif repo.dirstate.state(abs) == '?':
383 ui.status('adding %s\n' % rel)
383 ui.status('adding %s\n' % rel)
@@ -386,15 +386,14 b' def add(ui, repo, *pats, **opts):'
386
386
387 def addremove(ui, repo, *pats, **opts):
387 def addremove(ui, repo, *pats, **opts):
388 """add all new files, delete all missing files"""
388 """add all new files, delete all missing files"""
389 q = dict(zip(pats, pats))
390 add, remove = [], []
389 add, remove = [], []
391 for src, abs, rel in walk(repo, pats, opts):
390 for src, abs, rel, exact in walk(repo, pats, opts):
392 if src == 'f' and repo.dirstate.state(abs) == '?':
391 if src == 'f' and repo.dirstate.state(abs) == '?':
393 add.append(abs)
392 add.append(abs)
394 if rel not in q: ui.status('adding ', rel, '\n')
393 if not exact: ui.status('adding ', rel, '\n')
395 if repo.dirstate.state(abs) != 'r' and not os.path.exists(rel):
394 if repo.dirstate.state(abs) != 'r' and not os.path.exists(rel):
396 remove.append(abs)
395 remove.append(abs)
397 if rel not in q: ui.status('removing ', rel, '\n')
396 if not exact: ui.status('removing ', rel, '\n')
398 repo.add(add)
397 repo.add(add)
399 repo.remove(remove)
398 repo.remove(remove)
400
399
@@ -432,7 +431,7 b' def annotate(ui, repo, *pats, **opts):'
432 node = repo.dirstate.parents()[0]
431 node = repo.dirstate.parents()[0]
433 change = repo.changelog.read(node)
432 change = repo.changelog.read(node)
434 mmap = repo.manifest.read(change[0])
433 mmap = repo.manifest.read(change[0])
435 for src, abs, rel in walk(repo, pats, opts):
434 for src, abs, rel, exact in walk(repo, pats, opts):
436 if abs not in mmap:
435 if abs not in mmap:
437 ui.warn("warning: %s is not in the repository!\n" % rel)
436 ui.warn("warning: %s is not in the repository!\n" % rel)
438 continue
437 continue
@@ -629,8 +628,12 b' def debugindexdot(ui, file_):'
629 def debugwalk(ui, repo, *pats, **opts):
628 def debugwalk(ui, repo, *pats, **opts):
630 items = list(walk(repo, pats, opts))
629 items = list(walk(repo, pats, opts))
631 if not items: return
630 if not items: return
632 fmt = '%%s %%-%ds %%s' % max([len(abs) for (src, abs, rel) in items])
631 fmt = '%%s %%-%ds %%-%ds %%s' % (
633 for i in items: print fmt % i
632 max([len(abs) for (src, abs, rel, exact) in items]),
633 max([len(rel) for (src, abs, rel, exact) in items]))
634 exactly = {True: 'exact', False: ''}
635 for src, abs, rel, exact in items:
636 print fmt % (src, abs, rel, exactly[exact])
634
637
635 def diff(ui, repo, *pats, **opts):
638 def diff(ui, repo, *pats, **opts):
636 """diff working directory (or selected files)"""
639 """diff working directory (or selected files)"""
@@ -645,7 +648,7 b' def diff(ui, repo, *pats, **opts):'
645 match = util.always
648 match = util.always
646 if pats:
649 if pats:
647 roots, match, results = makewalk(repo, pats, opts)
650 roots, match, results = makewalk(repo, pats, opts)
648 for src, abs, rel in results:
651 for src, abs, rel, exact in results:
649 files.append(abs)
652 files.append(abs)
650 dodiff(sys.stdout, ui, repo, files, *revs, **{'match': match})
653 dodiff(sys.stdout, ui, repo, files, *revs, **{'match': match})
651
654
@@ -687,12 +690,11 b' def export(ui, repo, *changesets, **opts'
687
690
688 def forget(ui, repo, *pats, **opts):
691 def forget(ui, repo, *pats, **opts):
689 """don't add the specified files on the next commit"""
692 """don't add the specified files on the next commit"""
690 q = dict(zip(pats, pats))
691 forget = []
693 forget = []
692 for src, abs, rel in walk(repo, pats, opts):
694 for src, abs, rel, exact in walk(repo, pats, opts):
693 if repo.dirstate.state(abs) == 'a':
695 if repo.dirstate.state(abs) == 'a':
694 forget.append(abs)
696 forget.append(abs)
695 if rel not in q: ui.status('forgetting ', rel, '\n')
697 if not exact: ui.status('forgetting ', rel, '\n')
696 repo.forget(forget)
698 repo.forget(forget)
697
699
698 def heads(ui, repo, **opts):
700 def heads(ui, repo, **opts):
@@ -809,7 +811,7 b' def locate(ui, repo, *pats, **opts):'
809 end = '\n'
811 end = '\n'
810 if opts['print0']: end = '\0'
812 if opts['print0']: end = '\0'
811
813
812 for src, abs, rel in walk(repo, pats, opts, '(?:.*/|)'):
814 for src, abs, rel, exact in walk(repo, pats, opts, '(?:.*/|)'):
813 if repo.dirstate.state(abs) == '?': continue
815 if repo.dirstate.state(abs) == '?': continue
814 if opts['fullpath']:
816 if opts['fullpath']:
815 ui.write(os.path.join(repo.root, abs), end)
817 ui.write(os.path.join(repo.root, abs), end)
@@ -82,6 +82,6 b' f beans/pinto beans/pinto'
82 f beans/turtle beans/turtle
82 f beans/turtle beans/turtle
83 NOEXIST: No such file or directory
83 NOEXIST: No such file or directory
84 fifo: unsupported file type (type is fifo)
84 fifo: unsupported file type (type is fifo)
85 m fenugreek fenugreek
85 m fenugreek fenugreek exact
86 m fenugreek fenugreek
86 m fenugreek fenugreek exact
87 f new new
87 f new new exact
General Comments 0
You need to be logged in to leave comments. Login now