Mercurial > hg-stable
comparison contrib/hgit @ 737:8db4d406b3d3
Merge with Matt's tip.
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Wed, 20 Jul 2005 03:52:06 -0800 |
parents | 688d03d6997a 095dd8c757e0 |
children | d2422f10c136 |
comparison
equal
deleted
inserted
replaced
736:1e84f1014f33 | 737:8db4d406b3d3 |
---|---|
16 return time.asctime(time.gmtime(float(c[2].split(' ')[0]))) | 16 return time.asctime(time.gmtime(float(c[2].split(' ')[0]))) |
17 | 17 |
18 if node2: | 18 if node2: |
19 change = repo.changelog.read(node2) | 19 change = repo.changelog.read(node2) |
20 mmap2 = repo.manifest.read(change[0]) | 20 mmap2 = repo.manifest.read(change[0]) |
21 (c, a, d) = repo.diffrevs(node1, node2) | 21 (c, a, d, u) = repo.changes(node1, node2) |
22 def read(f): return repo.file(f).read(mmap2[f]) | 22 def read(f): return repo.file(f).read(mmap2[f]) |
23 date2 = date(change) | 23 date2 = date(change) |
24 else: | 24 else: |
25 date2 = time.asctime() | 25 date2 = time.asctime() |
26 (c, a, d, u) = repo.diffdir(repo.root, node1) | 26 (c, a, d, u) = repo.diffdir(repo.root, node1) |
49 revs = [] | 49 revs = [] |
50 if args: | 50 if args: |
51 doptions = {} | 51 doptions = {} |
52 opts = [('p', 'patch', None, 'patch'), | 52 opts = [('p', 'patch', None, 'patch'), |
53 ('r', 'recursive', None, 'recursive')] | 53 ('r', 'recursive', None, 'recursive')] |
54 args = fancyopts.fancyopts(args, opts, doptions, | 54 args = fancyopts.fancyopts(args, opts, doptions) |
55 'hg diff-tree [options] sha1 sha1') | |
56 | 55 |
57 if len(args) < 2: | 56 if len(args) < 2: |
58 help() | 57 help() |
59 sys.exit(1) | 58 sys.exit(1) |
60 revs.append(repo.lookup(args[0])) | 59 revs.append(repo.lookup(args[0])) |
61 revs.append(repo.lookup(args[1])) | 60 revs.append(repo.lookup(args[1])) |
62 args = args[2:] | 61 args = args[2:] |
63 if doptions['patch']: | 62 if doptions['patch']: |
64 commands.dodiff(ui, repo, "", args, *revs) | 63 commands.dodiff(sys.stdout, ui, repo, args, *revs) |
65 else: | 64 else: |
66 __difftree(repo, args, *revs) | 65 __difftree(repo, args, *revs) |
67 | 66 |
68 def catcommit(repo, n, prefix): | 67 def catcommit(repo, n, prefix): |
69 nlprefix = '\n' + prefix; | 68 nlprefix = '\n' + prefix; |
85 print changes[4] | 84 print changes[4] |
86 | 85 |
87 def catfile(args, ui, repo): | 86 def catfile(args, ui, repo): |
88 doptions = {} | 87 doptions = {} |
89 opts = [('s', 'stdin', None, 'stdin')] | 88 opts = [('s', 'stdin', None, 'stdin')] |
90 args = fancyopts.fancyopts(args, opts, doptions, | 89 args = fancyopts.fancyopts(args, opts, doptions) |
91 'hg cat-file type sha1') | |
92 | 90 |
93 # in stdin mode, every line except the commit is prefixed with two | 91 # in stdin mode, every line except the commit is prefixed with two |
94 # spaces. This way the our caller can find the commit without magic | 92 # spaces. This way the our caller can find the commit without magic |
95 # strings | 93 # strings |
96 # | 94 # |
111 | 109 |
112 while r: | 110 while r: |
113 if type != "commit": | 111 if type != "commit": |
114 sys.stderr.write("aborting hg cat-file only understands commits\n") | 112 sys.stderr.write("aborting hg cat-file only understands commits\n") |
115 sys.exit(1); | 113 sys.exit(1); |
116 n = repo.changelog.lookup(r) | 114 n = repo.lookup(r) |
117 catcommit(repo, n, prefix) | 115 catcommit(repo, n, prefix) |
118 if doptions['stdin']: | 116 if doptions['stdin']: |
119 try: | 117 try: |
120 (type, r) = raw_input().split(' '); | 118 (type, r) = raw_input().split(' '); |
121 except EOFError: | 119 except EOFError: |
146 count = 0 | 144 count = 0 |
147 | 145 |
148 # figure out which commits they are asking for and which ones they | 146 # figure out which commits they are asking for and which ones they |
149 # want us to stop on | 147 # want us to stop on |
150 for i in range(len(args)): | 148 for i in range(len(args)): |
151 if args[i].count('^'): | 149 if args[i].startswith('^'): |
152 s = args[i].split('^')[1] | 150 s = repo.lookup(args[i][1:]) |
153 stop_sha1.append(repo.changelog.lookup(s)) | 151 stop_sha1.append(s) |
154 want_sha1.append(s) | 152 want_sha1.append(s) |
155 elif args[i] != 'HEAD': | 153 elif args[i] != 'HEAD': |
156 want_sha1.append(args[i]) | 154 want_sha1.append(repo.lookup(args[i])) |
157 | 155 |
158 # calculate the graph for the supplied commits | 156 # calculate the graph for the supplied commits |
159 for i in range(len(want_sha1)): | 157 for i in range(len(want_sha1)): |
160 reachable.append({}); | 158 reachable.append({}); |
161 n = repo.changelog.lookup(want_sha1[i]); | 159 n = want_sha1[i]; |
162 visit = [n]; | 160 visit = [n]; |
163 reachable[i][n] = 1 | 161 reachable[i][n] = 1 |
164 while visit: | 162 while visit: |
165 n = visit.pop(0) | 163 n = visit.pop(0) |
166 if n in stop_sha1: | 164 if n in stop_sha1: |
207 # parameter | 205 # parameter |
208 def revlist(args, repo): | 206 def revlist(args, repo): |
209 doptions = {} | 207 doptions = {} |
210 opts = [('c', 'commit', None, 'commit'), | 208 opts = [('c', 'commit', None, 'commit'), |
211 ('n', 'max-nr', 0, 'max-nr')] | 209 ('n', 'max-nr', 0, 'max-nr')] |
212 args = fancyopts.fancyopts(args, opts, doptions, | 210 args = fancyopts.fancyopts(args, opts, doptions) |
213 'hg rev-list') | |
214 if doptions['commit']: | 211 if doptions['commit']: |
215 full = "commit" | 212 full = "commit" |
216 else: | 213 else: |
217 full = None | 214 full = None |
218 for i in range(1, len(args)): | 215 for i in range(1, len(args)): |
225 def help(): | 222 def help(): |
226 sys.stderr.write("commands:\n") | 223 sys.stderr.write("commands:\n") |
227 sys.stderr.write(" hgit cat-file [type] sha1\n") | 224 sys.stderr.write(" hgit cat-file [type] sha1\n") |
228 sys.stderr.write(" hgit diff-tree [-p] [-r] sha1 sha1\n") | 225 sys.stderr.write(" hgit diff-tree [-p] [-r] sha1 sha1\n") |
229 sys.stderr.write(" hgit rev-tree [sha1 ... [^stop sha1]]\n") | 226 sys.stderr.write(" hgit rev-tree [sha1 ... [^stop sha1]]\n") |
230 sys.stderr.write(" hgit rev-list [-c]\n") | 227 sys.stderr.write(" hgit rev-list [-c] [sha1 [stop sha1]\n") |
231 | 228 |
232 cmd = sys.argv[1] | 229 cmd = sys.argv[1] |
233 args = sys.argv[2:] | 230 args = sys.argv[2:] |
234 u = ui.ui() | 231 u = ui.ui() |
235 signal.signal(signal.SIGTERM, catchterm) | 232 signal.signal(signal.SIGTERM, catchterm) |