129 if node2: |
129 if node2: |
130 node2 = repo.lookup(node2) |
130 node2 = repo.lookup(node2) |
131 else: |
131 else: |
132 node2 = node1 |
132 node2 = node1 |
133 node1 = repo.changelog.parents(node1)[0] |
133 node1 = repo.changelog.parents(node1)[0] |
134 if opts[r'patch']: |
134 if opts['patch']: |
135 if opts[r'pretty']: |
135 if opts['pretty']: |
136 catcommit(ui, repo, node2, b"") |
136 catcommit(ui, repo, node2, b"") |
137 m = scmutil.match(repo[node1], files) |
137 m = scmutil.match(repo[node1], files) |
138 diffopts = patch.difffeatureopts(ui) |
138 diffopts = patch.difffeatureopts(ui) |
139 diffopts.git = True |
139 diffopts.git = True |
140 chunks = patch.diff(repo, node1, node2, match=m, opts=diffopts) |
140 chunks = patch.diff(repo, node1, node2, match=m, opts=diffopts) |
141 for chunk in chunks: |
141 for chunk in chunks: |
142 ui.write(chunk) |
142 ui.write(chunk) |
143 else: |
143 else: |
144 __difftree(repo, node1, node2, files=files) |
144 __difftree(repo, node1, node2, files=files) |
145 if not opts[r'stdin']: |
145 if not opts['stdin']: |
146 break |
146 break |
147 |
147 |
148 |
148 |
149 def catcommit(ui, repo, n, prefix, ctx=None): |
149 def catcommit(ui, repo, n, prefix, ctx=None): |
150 nlprefix = b'\n' + prefix |
150 nlprefix = b'\n' + prefix |
199 # in stdin mode, every line except the commit is prefixed with two |
199 # in stdin mode, every line except the commit is prefixed with two |
200 # spaces. This way the our caller can find the commit without magic |
200 # spaces. This way the our caller can find the commit without magic |
201 # strings |
201 # strings |
202 # |
202 # |
203 prefix = b"" |
203 prefix = b"" |
204 if opts[r'stdin']: |
204 if opts['stdin']: |
205 line = ui.fin.readline() |
205 line = ui.fin.readline() |
206 if not line: |
206 if not line: |
207 return |
207 return |
208 (type, r) = line.rstrip(pycompat.oslinesep).split(b' ') |
208 (type, r) = line.rstrip(pycompat.oslinesep).split(b' ') |
209 prefix = b" " |
209 prefix = b" " |
216 if type != b"commit": |
216 if type != b"commit": |
217 ui.warn(_(b"aborting hg cat-file only understands commits\n")) |
217 ui.warn(_(b"aborting hg cat-file only understands commits\n")) |
218 return 1 |
218 return 1 |
219 n = repo.lookup(r) |
219 n = repo.lookup(r) |
220 catcommit(ui, repo, n, prefix) |
220 catcommit(ui, repo, n, prefix) |
221 if opts[r'stdin']: |
221 if opts['stdin']: |
222 line = ui.fin.readline() |
222 line = ui.fin.readline() |
223 if not line: |
223 if not line: |
224 break |
224 break |
225 (type, r) = line.rstrip(pycompat.oslinesep).split(b' ') |
225 (type, r) = line.rstrip(pycompat.oslinesep).split(b' ') |
226 else: |
226 else: |
361 if opts[b'header']: |
361 if opts[b'header']: |
362 full = b"commit" |
362 full = b"commit" |
363 else: |
363 else: |
364 full = None |
364 full = None |
365 copy = [x for x in revs] |
365 copy = [x for x in revs] |
366 revtree(ui, copy, repo, full, opts[r'max_count'], opts[r'parents']) |
366 revtree(ui, copy, repo, full, opts['max_count'], opts[r'parents']) |
367 |
367 |
368 |
368 |
369 @command( |
369 @command( |
370 b'view', |
370 b'view', |
371 [(b'l', b'limit', b'', _(b'limit number of changes displayed'), _(b'NUM'))], |
371 [(b'l', b'limit', b'', _(b'limit number of changes displayed'), _(b'NUM'))], |