comparison mercurial/commands.py @ 885:6594ba2a0f51

Merge latest round of walk fixes.
author Bryan O'Sullivan <bos@serpentine.com>
date Fri, 12 Aug 2005 11:18:41 -0800
parents 781266a78fe1 087771ebe2e6
children 882756761433
comparison
equal deleted inserted replaced
878:781266a78fe1 885:6594ba2a0f51
38 38
39 def matchpats(repo, cwd, pats = [], opts = {}, head = ''): 39 def matchpats(repo, cwd, pats = [], opts = {}, head = ''):
40 return util.matcher(repo, cwd, pats or ['.'], opts.get('include'), 40 return util.matcher(repo, cwd, pats or ['.'], opts.get('include'),
41 opts.get('exclude'), head) 41 opts.get('exclude'), head)
42 42
43 def pathto(n1, n2):
44 '''return the relative path from one place to another'''
45 if not n1: return n2
46 a, b = n1.split(os.sep), n2.split(os.sep)
47 a.reverse(), b.reverse()
48 while a and b and a[-1] == b[-1]:
49 a.pop(), b.pop()
50 b.reverse()
51 return os.sep.join((['..'] * len(a)) + b)
52
53 def makewalk(repo, pats, opts, head = ''): 43 def makewalk(repo, pats, opts, head = ''):
54 cwd = repo.getcwd() 44 cwd = repo.getcwd()
55 files, matchfn = matchpats(repo, cwd, pats, opts, head) 45 files, matchfn = matchpats(repo, cwd, pats, opts, head)
56 def walk(): 46 def walk():
57 for src, fn in repo.walk(files = files, match = matchfn): 47 for src, fn in repo.walk(files = files, match = matchfn):
58 yield src, fn, pathto(cwd, fn) 48 yield src, fn, util.pathto(cwd, fn)
59 return files, matchfn, walk() 49 return files, matchfn, walk()
60 50
61 def walk(repo, pats, opts, head = ''): 51 def walk(repo, pats, opts, head = ''):
62 files, matchfn, results = makewalk(repo, pats, opts, head) 52 files, matchfn, results = makewalk(repo, pats, opts, head)
63 for r in results: yield r 53 for r in results: yield r
1076 ? = not tracked 1066 ? = not tracked
1077 ''' 1067 '''
1078 1068
1079 cwd = repo.getcwd() 1069 cwd = repo.getcwd()
1080 files, matchfn = matchpats(repo, cwd, pats, opts) 1070 files, matchfn = matchpats(repo, cwd, pats, opts)
1081 (c, a, d, u) = [[pathto(cwd, x) for x in n] 1071 (c, a, d, u) = [[util.pathto(cwd, x) for x in n]
1082 for n in repo.changes(files=files, match=matchfn)] 1072 for n in repo.changes(files=files, match=matchfn)]
1083 1073
1084 changetypes = [('modified', 'M', c), 1074 changetypes = [('modified', 'M', c),
1085 ('added', 'A', a), 1075 ('added', 'A', a),
1086 ('removed', 'R', d), 1076 ('removed', 'R', d),