Show More
@@ -38,23 +38,13 b' def help():' | |||||
38 | diff [files...] diff working directory (or selected files) |
|
38 | diff [files...] diff working directory (or selected files) | |
39 | """ |
|
39 | """ | |
40 |
|
40 | |||
41 | def diffdir(node, files = None): |
|
41 | def filterfiles(list, files): | |
42 | (c, a, d) = repo.diffdir(repo.root, node) |
|
42 | l = [ x for x in list if x in files ] | |
43 |
|
43 | |||
44 | if args: |
|
44 | for f in files: | |
45 | nc = [ x for x in c if x in args ] |
|
45 | if f[-1] != os.sep: f += os.sep | |
46 |
|
|
46 | l += [ x for x in list if x.startswith(f) ] | |
47 | nd = [ x for x in d if x in args ] |
|
47 | return l | |
48 | for arg in args: |
|
|||
49 | if not os.path.isdir(arg): continue |
|
|||
50 | if arg[-1] != os.sep: arg += os.sep |
|
|||
51 | nc += [ x for x in c if x.startswith(arg) ] |
|
|||
52 | na += [ x for x in a if x.startswith(arg) ] |
|
|||
53 | nd += [ x for x in d if x.startswith(arg) ] |
|
|||
54 | (c, a, d) = (nc, na, nd) |
|
|||
55 |
|
||||
56 | return (c, a, d) |
|
|||
57 |
|
||||
58 |
|
48 | |||
59 | options = {} |
|
49 | options = {} | |
60 | opts = [('v', 'verbose', None, 'verbose'), |
|
50 | opts = [('v', 'verbose', None, 'verbose'), | |
@@ -130,26 +120,52 b' elif cmd == "import" or cmd == "patch":' | |||||
130 | repo.commit(files) |
|
120 | repo.commit(files) | |
131 |
|
121 | |||
132 | elif cmd == "status": |
|
122 | elif cmd == "status": | |
133 | (c, a, d) = diffdir(repo.current) |
|
123 | (c, a, d) = repo.diffdir(repo.root, repo.current) | |
134 | for f in c: print "C", f |
|
124 | for f in c: print "C", f | |
135 | for f in a: print "?", f |
|
125 | for f in a: print "?", f | |
136 | for f in d: print "R", f |
|
126 | for f in d: print "R", f | |
137 |
|
127 | |||
138 | elif cmd == "diff": |
|
128 | elif cmd == "diff": | |
139 | (c, a, d) = diffdir(repo.current, args) |
|
129 | doptions = {} | |
|
130 | revs = [repo.current] | |||
140 |
|
131 | |||
141 | mmap = {} |
|
132 | if args: | |
142 | if repo.current: |
|
133 | opts = [('r', 'revision', [], 'revision')] | |
143 | change = repo.changelog.read(repo.current) |
|
134 | args = fancyopts.fancyopts(args, opts, doptions, | |
144 | mmap = repo.manifest.read(change[0]) |
|
135 | 'hg diff [options] [files]') | |
|
136 | # revs = [ repo.lookup(x) for x in doptions['revision'] ] | |||
|
137 | revs = [hg.bin(x) for x in doptions['revision']] | |||
|
138 | ||||
|
139 | if len(revs) > 2: | |||
|
140 | print "too many revisions to diff" | |||
|
141 | sys.exit(1) | |||
|
142 | elif len(revs) == 2: | |||
|
143 | change = repo.changelog.read(revs[1]) | |||
|
144 | mmap2 = repo.manifest.read(change[0]) | |||
|
145 | (c, a, d) = repo.diffrevs(revs[0], revs[1]) | |||
|
146 | def read(f): return repo.file(f).read(mmap2[f]) | |||
|
147 | else: | |||
|
148 | if len(revs) < 1: | |||
|
149 | if not repo.current: | |||
|
150 | sys.exit(0) | |||
|
151 | (c, a, d) = repo.diffdir(repo.root, revs[0]) | |||
|
152 | def read(f): return file(f).read() | |||
|
153 | ||||
|
154 | change = repo.changelog.read(revs[0]) | |||
|
155 | mmap = repo.manifest.read(change[0]) | |||
|
156 | ||||
|
157 | if args: | |||
|
158 | c = filterfiles(c, args) | |||
|
159 | a = filterfiles(a, args) | |||
|
160 | d = filterfiles(d, args) | |||
145 |
|
161 | |||
146 | for f in c: |
|
162 | for f in c: | |
147 | to = repo.file(f).read(mmap[f]) |
|
163 | to = repo.file(f).read(mmap[f]) | |
148 |
tn = |
|
164 | tn = read(f) | |
149 | sys.stdout.write(mdiff.unidiff(to, tn, f)) |
|
165 | sys.stdout.write(mdiff.unidiff(to, tn, f)) | |
150 | for f in a: |
|
166 | for f in a: | |
151 | to = "" |
|
167 | to = "" | |
152 |
tn = |
|
168 | tn = read(f) | |
153 | sys.stdout.write(mdiff.unidiff(to, tn, f)) |
|
169 | sys.stdout.write(mdiff.unidiff(to, tn, f)) | |
154 | for f in d: |
|
170 | for f in d: | |
155 | to = repo.file(f).read(mmap[f]) |
|
171 | to = repo.file(f).read(mmap[f]) |
@@ -517,7 +517,7 b' class repository:' | |||||
517 | if not c: |
|
517 | if not c: | |
518 | if fcmp(fn): |
|
518 | if fcmp(fn): | |
519 | changed.append(fn) |
|
519 | changed.append(fn) | |
520 | if c[1] != s.st_size: |
|
520 | elif c[1] != s.st_size: | |
521 | changed.append(fn) |
|
521 | changed.append(fn) | |
522 | elif c[0] != s.st_mode or c[2] != s.st_mtime: |
|
522 | elif c[0] != s.st_mode or c[2] != s.st_mtime: | |
523 | if fcmp(fn): |
|
523 | if fcmp(fn): | |
@@ -532,11 +532,11 b' class repository:' | |||||
532 | return (changed, added, deleted) |
|
532 | return (changed, added, deleted) | |
533 |
|
533 | |||
534 | def diffrevs(self, node1, node2): |
|
534 | def diffrevs(self, node1, node2): | |
535 |
changed, added = [], [] |
|
535 | changed, added = [], [] | |
536 |
|
536 | |||
537 | change = self.changelog.read(node1) |
|
537 | change = self.changelog.read(node1) | |
538 | mf1 = self.manifest.read(change[0]) |
|
538 | mf1 = self.manifest.read(change[0]) | |
539 |
change = self.changelog.read( |
|
539 | change = self.changelog.read(node2) | |
540 | mf2 = self.manifest.read(change[0]) |
|
540 | mf2 = self.manifest.read(change[0]) | |
541 |
|
541 | |||
542 | for fn in mf2: |
|
542 | for fn in mf2: |
General Comments 0
You need to be logged in to leave comments.
Login now