Mercurial > hg
comparison contrib/hgk.py @ 1618:ff339dd21976
Renamed c, a, d, u to modified, added, removed, unknown for users of changes()
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Thu, 12 Jan 2006 13:35:09 +0100 |
parents | 0952d164030e |
children | 1ba0d7041ac4 |
comparison
equal
deleted
inserted
replaced
1617:ece5d785e87a | 1618:ff339dd21976 |
---|---|
12 changes=None, text=False): | 12 changes=None, text=False): |
13 def date(c): | 13 def date(c): |
14 return time.asctime(time.gmtime(c[2][0])) | 14 return time.asctime(time.gmtime(c[2][0])) |
15 | 15 |
16 if not changes: | 16 if not changes: |
17 (c, a, d, u) = repo.changes(node1, node2, files, match=match) | 17 changes = repo.changes(node1, node2, files, match=match) |
18 else: | 18 modified, added, removed, unknown = changes |
19 (c, a, d, u) = changes | |
20 if files: | 19 if files: |
21 c, a, d = map(lambda x: filterfiles(files, x), (c, a, d)) | 20 modified, added, removed = map(lambda x: filterfiles(x, files), |
22 | 21 (modified, added, removed)) |
23 if not c and not a and not d: | 22 |
23 if not modified and not added and not removed: | |
24 return | 24 return |
25 | 25 |
26 if node2: | 26 if node2: |
27 change = repo.changelog.read(node2) | 27 change = repo.changelog.read(node2) |
28 mmap2 = repo.manifest.read(change[0]) | 28 mmap2 = repo.manifest.read(change[0]) |
38 | 38 |
39 change = repo.changelog.read(node1) | 39 change = repo.changelog.read(node1) |
40 mmap = repo.manifest.read(change[0]) | 40 mmap = repo.manifest.read(change[0]) |
41 date1 = date(change) | 41 date1 = date(change) |
42 | 42 |
43 for f in c: | 43 for f in modified: |
44 to = None | 44 to = None |
45 if f in mmap: | 45 if f in mmap: |
46 to = repo.file(f).read(mmap[f]) | 46 to = repo.file(f).read(mmap[f]) |
47 tn = read(f) | 47 tn = read(f) |
48 fp.write("diff --git a/%s b/%s\n" % (f, f)) | 48 fp.write("diff --git a/%s b/%s\n" % (f, f)) |
49 fp.write(mdiff.unidiff(to, date1, tn, date2, f, None, text=text)) | 49 fp.write(mdiff.unidiff(to, date1, tn, date2, f, None, text=text)) |
50 for f in a: | 50 for f in added: |
51 to = None | 51 to = None |
52 tn = read(f) | 52 tn = read(f) |
53 fp.write("diff --git /dev/null b/%s\n" % (f)) | 53 fp.write("diff --git /dev/null b/%s\n" % (f)) |
54 fp.write(mdiff.unidiff(to, date1, tn, date2, f, None, text=text)) | 54 fp.write(mdiff.unidiff(to, date1, tn, date2, f, None, text=text)) |
55 for f in d: | 55 for f in removed: |
56 to = repo.file(f).read(mmap[f]) | 56 to = repo.file(f).read(mmap[f]) |
57 tn = None | 57 tn = None |
58 fp.write("diff --git a/%s /dev/null\n" % (f)) | 58 fp.write("diff --git a/%s /dev/null\n" % (f)) |
59 fp.write(mdiff.unidiff(to, date1, tn, date2, f, None, text=text)) | 59 fp.write(mdiff.unidiff(to, date1, tn, date2, f, None, text=text)) |
60 | 60 |
65 return time.asctime(time.gmtime(c[2][0])) | 65 return time.asctime(time.gmtime(c[2][0])) |
66 | 66 |
67 if node2: | 67 if node2: |
68 change = repo.changelog.read(node2) | 68 change = repo.changelog.read(node2) |
69 mmap2 = repo.manifest.read(change[0]) | 69 mmap2 = repo.manifest.read(change[0]) |
70 (c, a, d, u) = repo.changes(node1, node2) | 70 modified, added, removed, unknown = repo.changes(node1, node2) |
71 def read(f): return repo.file(f).read(mmap2[f]) | 71 def read(f): return repo.file(f).read(mmap2[f]) |
72 date2 = date(change) | 72 date2 = date(change) |
73 else: | 73 else: |
74 date2 = time.asctime() | 74 date2 = time.asctime() |
75 (c, a, d, u) = repo.changes(node1, None) | 75 modified, added, removed, unknown = repo.changes(node1) |
76 if not node1: | 76 if not node1: |
77 node1 = repo.dirstate.parents()[0] | 77 node1 = repo.dirstate.parents()[0] |
78 def read(f): return file(os.path.join(repo.root, f)).read() | 78 def read(f): return file(os.path.join(repo.root, f)).read() |
79 | 79 |
80 change = repo.changelog.read(node1) | 80 change = repo.changelog.read(node1) |
81 mmap = repo.manifest.read(change[0]) | 81 mmap = repo.manifest.read(change[0]) |
82 date1 = date(change) | 82 date1 = date(change) |
83 empty = "0" * 40; | 83 empty = "0" * 40; |
84 | 84 |
85 for f in c: | 85 for f in modified: |
86 # TODO get file permissions | 86 # TODO get file permissions |
87 print ":100664 100664 %s %s M\t%s\t%s" % (hg.hex(mmap[f]), | 87 print ":100664 100664 %s %s M\t%s\t%s" % (hg.hex(mmap[f]), |
88 hg.hex(mmap2[f]), f, f) | 88 hg.hex(mmap2[f]), f, f) |
89 for f in a: | 89 for f in added: |
90 print ":000000 100664 %s %s N\t%s\t%s" % (empty, hg.hex(mmap2[f]), f, f) | 90 print ":000000 100664 %s %s N\t%s\t%s" % (empty, hg.hex(mmap2[f]), f, f) |
91 for f in d: | 91 for f in removed: |
92 print ":100664 000000 %s %s D\t%s\t%s" % (hg.hex(mmap[f]), empty, f, f) | 92 print ":100664 000000 %s %s D\t%s\t%s" % (hg.hex(mmap[f]), empty, f, f) |
93 ## | 93 ## |
94 | 94 |
95 while True: | 95 while True: |
96 if opts['stdin']: | 96 if opts['stdin']: |