##// 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 42 def makewalk(repo, pats, opts, head = ''):
43 43 cwd = repo.getcwd()
44 44 files, matchfn = matchpats(repo, cwd, pats, opts, head)
45 exact = dict(zip(files, files))
45 46 def walk():
46 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 49 return files, matchfn, walk()
49 50
50 51 def walk(repo, pats, opts, head = ''):
@@ -375,9 +376,8 b' def help_(ui, cmd=None):'
375 376 def add(ui, repo, *pats, **opts):
376 377 '''add the specified files on the next commit'''
377 378 names = []
378 q = dict(zip(pats, pats))
379 for src, abs, rel in walk(repo, pats, opts):
380 if rel in q or abs in q:
379 for src, abs, rel, exact in walk(repo, pats, opts):
380 if exact:
381 381 names.append(abs)
382 382 elif repo.dirstate.state(abs) == '?':
383 383 ui.status('adding %s\n' % rel)
@@ -386,15 +386,14 b' def add(ui, repo, *pats, **opts):'
386 386
387 387 def addremove(ui, repo, *pats, **opts):
388 388 """add all new files, delete all missing files"""
389 q = dict(zip(pats, pats))
390 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 391 if src == 'f' and repo.dirstate.state(abs) == '?':
393 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 394 if repo.dirstate.state(abs) != 'r' and not os.path.exists(rel):
396 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 397 repo.add(add)
399 398 repo.remove(remove)
400 399
@@ -432,7 +431,7 b' def annotate(ui, repo, *pats, **opts):'
432 431 node = repo.dirstate.parents()[0]
433 432 change = repo.changelog.read(node)
434 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 435 if abs not in mmap:
437 436 ui.warn("warning: %s is not in the repository!\n" % rel)
438 437 continue
@@ -629,8 +628,12 b' def debugindexdot(ui, file_):'
629 628 def debugwalk(ui, repo, *pats, **opts):
630 629 items = list(walk(repo, pats, opts))
631 630 if not items: return
632 fmt = '%%s %%-%ds %%s' % max([len(abs) for (src, abs, rel) in items])
633 for i in items: print fmt % i
631 fmt = '%%s %%-%ds %%-%ds %%s' % (
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 638 def diff(ui, repo, *pats, **opts):
636 639 """diff working directory (or selected files)"""
@@ -645,7 +648,7 b' def diff(ui, repo, *pats, **opts):'
645 648 match = util.always
646 649 if pats:
647 650 roots, match, results = makewalk(repo, pats, opts)
648 for src, abs, rel in results:
651 for src, abs, rel, exact in results:
649 652 files.append(abs)
650 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 691 def forget(ui, repo, *pats, **opts):
689 692 """don't add the specified files on the next commit"""
690 q = dict(zip(pats, pats))
691 693 forget = []
692 for src, abs, rel in walk(repo, pats, opts):
694 for src, abs, rel, exact in walk(repo, pats, opts):
693 695 if repo.dirstate.state(abs) == 'a':
694 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 698 repo.forget(forget)
697 699
698 700 def heads(ui, repo, **opts):
@@ -809,7 +811,7 b' def locate(ui, repo, *pats, **opts):'
809 811 end = '\n'
810 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 815 if repo.dirstate.state(abs) == '?': continue
814 816 if opts['fullpath']:
815 817 ui.write(os.path.join(repo.root, abs), end)
@@ -12,76 +12,76 b' adding mammals/skunk'
12 12 adding mammals/Procyonidae/cacomistle
13 13 adding mammals/Procyonidae/coatimundi
14 14 adding mammals/Procyonidae/raccoon
15 f fennel fennel
16 f fenugreek fenugreek
17 f fiddlehead fiddlehead
18 f glob:glob glob:glob
19 f beans/black beans/black
20 f beans/borlotti beans/borlotti
21 f beans/kidney beans/kidney
22 f beans/navy beans/navy
23 f beans/pinto beans/pinto
24 f beans/turtle beans/turtle
25 f mammals/skunk mammals/skunk
26 f mammals/Procyonidae/cacomistle mammals/Procyonidae/cacomistle
27 f mammals/Procyonidae/coatimundi mammals/Procyonidae/coatimundi
28 f mammals/Procyonidae/raccoon mammals/Procyonidae/raccoon
29 f mammals/skunk skunk
30 f mammals/Procyonidae/cacomistle Procyonidae/cacomistle
31 f mammals/Procyonidae/coatimundi Procyonidae/coatimundi
32 f mammals/Procyonidae/raccoon Procyonidae/raccoon
33 f mammals/Procyonidae/cacomistle Procyonidae/cacomistle
34 f mammals/Procyonidae/coatimundi Procyonidae/coatimundi
35 f mammals/Procyonidae/raccoon Procyonidae/raccoon
36 f mammals/Procyonidae/cacomistle cacomistle
37 f mammals/Procyonidae/coatimundi coatimundi
38 f mammals/Procyonidae/raccoon raccoon
39 f mammals/skunk ../skunk
40 f mammals/Procyonidae/cacomistle cacomistle
41 f mammals/Procyonidae/coatimundi coatimundi
42 f mammals/Procyonidae/raccoon raccoon
43 f beans/black ../beans/black
44 f beans/borlotti ../beans/borlotti
45 f beans/kidney ../beans/kidney
46 f beans/navy ../beans/navy
47 f beans/pinto ../beans/pinto
48 f beans/turtle ../beans/turtle
49 f mammals/skunk skunk
50 f mammals/Procyonidae/cacomistle Procyonidae/cacomistle
51 f mammals/Procyonidae/coatimundi Procyonidae/coatimundi
52 f mammals/Procyonidae/raccoon Procyonidae/raccoon
53 f beans/black beans/black
54 f beans/borlotti beans/borlotti
55 f beans/kidney beans/kidney
56 f beans/navy beans/navy
57 f beans/pinto beans/pinto
58 f beans/turtle beans/turtle
59 f beans/black beans/black
60 f beans/borlotti beans/borlotti
61 f mammals/skunk mammals/skunk
62 f mammals/skunk mammals/skunk
63 f mammals/Procyonidae/cacomistle mammals/Procyonidae/cacomistle
64 f mammals/Procyonidae/coatimundi mammals/Procyonidae/coatimundi
65 f mammals/Procyonidae/raccoon mammals/Procyonidae/raccoon
15 f fennel fennel
16 f fenugreek fenugreek
17 f fiddlehead fiddlehead
18 f glob:glob glob:glob
19 f beans/black beans/black
20 f beans/borlotti beans/borlotti
21 f beans/kidney beans/kidney
22 f beans/navy beans/navy
23 f beans/pinto beans/pinto
24 f beans/turtle beans/turtle
25 f mammals/skunk mammals/skunk
26 f mammals/Procyonidae/cacomistle mammals/Procyonidae/cacomistle
27 f mammals/Procyonidae/coatimundi mammals/Procyonidae/coatimundi
28 f mammals/Procyonidae/raccoon mammals/Procyonidae/raccoon
29 f mammals/skunk skunk
30 f mammals/Procyonidae/cacomistle Procyonidae/cacomistle
31 f mammals/Procyonidae/coatimundi Procyonidae/coatimundi
32 f mammals/Procyonidae/raccoon Procyonidae/raccoon
33 f mammals/Procyonidae/cacomistle Procyonidae/cacomistle
34 f mammals/Procyonidae/coatimundi Procyonidae/coatimundi
35 f mammals/Procyonidae/raccoon Procyonidae/raccoon
36 f mammals/Procyonidae/cacomistle cacomistle
37 f mammals/Procyonidae/coatimundi coatimundi
38 f mammals/Procyonidae/raccoon raccoon
39 f mammals/skunk ../skunk
40 f mammals/Procyonidae/cacomistle cacomistle
41 f mammals/Procyonidae/coatimundi coatimundi
42 f mammals/Procyonidae/raccoon raccoon
43 f beans/black ../beans/black
44 f beans/borlotti ../beans/borlotti
45 f beans/kidney ../beans/kidney
46 f beans/navy ../beans/navy
47 f beans/pinto ../beans/pinto
48 f beans/turtle ../beans/turtle
49 f mammals/skunk skunk
50 f mammals/Procyonidae/cacomistle Procyonidae/cacomistle
51 f mammals/Procyonidae/coatimundi Procyonidae/coatimundi
52 f mammals/Procyonidae/raccoon Procyonidae/raccoon
53 f beans/black beans/black
54 f beans/borlotti beans/borlotti
55 f beans/kidney beans/kidney
56 f beans/navy beans/navy
57 f beans/pinto beans/pinto
58 f beans/turtle beans/turtle
59 f beans/black beans/black
60 f beans/borlotti beans/borlotti
61 f mammals/skunk mammals/skunk
62 f mammals/skunk mammals/skunk
63 f mammals/Procyonidae/cacomistle mammals/Procyonidae/cacomistle
64 f mammals/Procyonidae/coatimundi mammals/Procyonidae/coatimundi
65 f mammals/Procyonidae/raccoon mammals/Procyonidae/raccoon
66 66 abort: .. not under repository root
67 67 abort: beans/../.. not under repository root
68 f fennel fennel
69 f fenugreek fenugreek
70 f fiddlehead fiddlehead
71 f glob:glob glob:glob
72 f fenugreek fenugreek
73 f glob:glob glob:glob
74 f beans/black beans/black
75 f mammals/skunk mammals/skunk
76 f beans/black beans/black
77 f beans/black beans/black
78 f beans/borlotti beans/borlotti
79 f beans/kidney beans/kidney
80 f beans/navy beans/navy
81 f beans/pinto beans/pinto
82 f beans/turtle beans/turtle
68 f fennel fennel
69 f fenugreek fenugreek
70 f fiddlehead fiddlehead
71 f glob:glob glob:glob
72 f fenugreek fenugreek
73 f glob:glob glob:glob
74 f beans/black beans/black
75 f mammals/skunk mammals/skunk
76 f beans/black beans/black
77 f beans/black beans/black
78 f beans/borlotti beans/borlotti
79 f beans/kidney beans/kidney
80 f beans/navy beans/navy
81 f beans/pinto beans/pinto
82 f beans/turtle beans/turtle
83 83 NOEXIST: No such file or directory
84 84 fifo: unsupported file type (type is fifo)
85 m fenugreek fenugreek
86 m fenugreek fenugreek
87 f new new
85 m fenugreek fenugreek exact
86 m fenugreek fenugreek exact
87 f new new exact
General Comments 0
You need to be logged in to leave comments. Login now