38 return [util.pconvert(os.path.normpath(os.path.join(cwd, x))) |
38 return [util.pconvert(os.path.normpath(os.path.join(cwd, x))) |
39 for x in args] |
39 for x in args] |
40 return args |
40 return args |
41 |
41 |
42 def matchpats(cwd, pats = [], opts = {}, head = ''): |
42 def matchpats(cwd, pats = [], opts = {}, head = ''): |
43 return util.matcher(cwd, pats, opts.get('include'), |
43 return util.matcher(cwd, pats or ['.'], opts.get('include'), |
44 opts.get('exclude'), head) |
44 opts.get('exclude'), head) |
|
45 |
|
46 def pathto(n1, n2): |
|
47 '''return the relative path from one place to another''' |
|
48 if not n1: return n2 |
|
49 a, b = n1.split(os.sep), n2.split(os.sep) |
|
50 a.reverse(), b.reverse() |
|
51 while a and b and a[-1] == b[-1]: |
|
52 a.pop(), b.pop() |
|
53 b.reverse() |
|
54 return os.sep.join((['..'] * len(a)) + b) |
45 |
55 |
46 def walk(repo, pats, opts, head = ''): |
56 def walk(repo, pats, opts, head = ''): |
47 cwd = repo.getcwd() |
57 cwd = repo.getcwd() |
48 c = 0 |
|
49 if cwd: c = len(cwd) + 1 |
|
50 files, matchfn = matchpats(cwd, pats, opts, head) |
58 files, matchfn = matchpats(cwd, pats, opts, head) |
51 for src, fn in repo.walk(files = files, match = matchfn): |
59 for src, fn in repo.walk(files = files, match = matchfn): |
52 yield src, fn, fn[c:] |
60 yield src, fn, pathto(cwd, fn) |
53 |
61 |
54 revrangesep = ':' |
62 revrangesep = ':' |
55 |
63 |
56 def revrange(ui, repo, revs, revlog=None): |
64 def revrange(ui, repo, revs, revlog=None): |
57 if revlog is None: |
65 if revlog is None: |
563 ui.write("\t%d -> %d\n" % (r.rev(e[4]), i)) |
571 ui.write("\t%d -> %d\n" % (r.rev(e[4]), i)) |
564 if e[5] != hg.nullid: |
572 if e[5] != hg.nullid: |
565 ui.write("\t%d -> %d\n" % (r.rev(e[5]), i)) |
573 ui.write("\t%d -> %d\n" % (r.rev(e[5]), i)) |
566 ui.write("}\n") |
574 ui.write("}\n") |
567 |
575 |
|
576 def debugwalk(ui, repo, *pats, **opts): |
|
577 items = list(walk(repo, pats, opts)) |
|
578 fmt = '%%s %%-%ds %%s' % max([len(abs) for (src, abs, rel) in items]) |
|
579 for i in items: print fmt % i |
|
580 |
568 def diff(ui, repo, *pats, **opts): |
581 def diff(ui, repo, *pats, **opts): |
569 """diff working directory (or selected files)""" |
582 """diff working directory (or selected files)""" |
570 revs = [] |
583 revs = [] |
571 if opts['rev']: |
584 if opts['rev']: |
572 revs = map(lambda x: repo.lookup(x), opts['rev']) |
585 revs = map(lambda x: repo.lookup(x), opts['rev']) |
1013 M = modified |
1026 M = modified |
1014 A = added |
1027 A = added |
1015 R = removed |
1028 R = removed |
1016 ? = not tracked''' |
1029 ? = not tracked''' |
1017 |
1030 |
1018 files, matchfn = matchpats(repo.getcwd(), pats, opts) |
1031 cwd = repo.getcwd() |
|
1032 files, matchfn = matchpats(cwd, pats, opts) |
1019 (c, a, d, u) = repo.changes(files = files, match = matchfn) |
1033 (c, a, d, u) = repo.changes(files = files, match = matchfn) |
1020 (c, a, d, u) = map(lambda x: relfilter(repo, x), (c, a, d, u)) |
1034 (c, a, d, u) = [map(lambda x: pathto(cwd, x), n) for n in c, a, d, u] |
1021 |
1035 |
1022 for f in c: |
1036 for f in c: |
1023 ui.write("M ", f, "\n") |
1037 ui.write("M ", f, "\n") |
1024 for f in a: |
1038 for f in a: |
1025 ui.write("A ", f, "\n") |
1039 ui.write("A ", f, "\n") |
1158 "copy": (copy, [], 'hg copy SOURCE DEST'), |
1172 "copy": (copy, [], 'hg copy SOURCE DEST'), |
1159 "debugcheckstate": (debugcheckstate, [], 'debugcheckstate'), |
1173 "debugcheckstate": (debugcheckstate, [], 'debugcheckstate'), |
1160 "debugstate": (debugstate, [], 'debugstate'), |
1174 "debugstate": (debugstate, [], 'debugstate'), |
1161 "debugindex": (debugindex, [], 'debugindex FILE'), |
1175 "debugindex": (debugindex, [], 'debugindex FILE'), |
1162 "debugindexdot": (debugindexdot, [], 'debugindexdot FILE'), |
1176 "debugindexdot": (debugindexdot, [], 'debugindexdot FILE'), |
|
1177 "debugwalk": (debugwalk, |
|
1178 [('I', 'include', [], 'include path in search'), |
|
1179 ('X', 'exclude', [], 'exclude path from search')], |
|
1180 'debugwalk [OPTIONS]... [FILE]...'), |
1163 "^diff": |
1181 "^diff": |
1164 (diff, |
1182 (diff, |
1165 [('r', 'rev', [], 'revision'), |
1183 [('r', 'rev', [], 'revision'), |
1166 ('I', 'include', [], 'include path in search'), |
1184 ('I', 'include', [], 'include path in search'), |
1167 ('X', 'exclude', [], 'exclude path from search')], |
1185 ('X', 'exclude', [], 'exclude path from search')], |