259 return open(make_filename(repo, r, pat, node, total, seqno, revwidth, |
259 return open(make_filename(repo, r, pat, node, total, seqno, revwidth, |
260 pathname), |
260 pathname), |
261 mode) |
261 mode) |
262 |
262 |
263 def dodiff(fp, ui, repo, node1, node2, files=None, match=util.always, |
263 def dodiff(fp, ui, repo, node1, node2, files=None, match=util.always, |
264 changes=None, text=False): |
264 changes=None, text=False, opts={}): |
265 if not changes: |
265 if not changes: |
266 changes = repo.changes(node1, node2, files, match=match) |
266 changes = repo.changes(node1, node2, files, match=match) |
267 modified, added, removed, deleted, unknown = changes |
267 modified, added, removed, deleted, unknown = changes |
268 if files: |
268 if files: |
269 modified, added, removed = map(lambda x: filterfiles(files, x), |
269 modified, added, removed = map(lambda x: filterfiles(files, x), |
294 change = repo.changelog.read(node1) |
294 change = repo.changelog.read(node1) |
295 mmap = repo.manifest.read(change[0]) |
295 mmap = repo.manifest.read(change[0]) |
296 date1 = util.datestr(change[2]) |
296 date1 = util.datestr(change[2]) |
297 |
297 |
298 diffopts = ui.diffopts() |
298 diffopts = ui.diffopts() |
299 showfunc = diffopts['showfunc'] |
299 showfunc = opts.get('show_function') or diffopts['showfunc'] |
300 ignorews = diffopts['ignorews'] |
300 ignorews = opts.get('ignore_all_space') or diffopts['ignorews'] |
301 for f in modified: |
301 for f in modified: |
302 to = None |
302 to = None |
303 if f in mmap: |
303 if f in mmap: |
304 to = repo.file(f).read(mmap[f]) |
304 to = repo.file(f).read(mmap[f]) |
305 tn = read(f) |
305 tn = read(f) |
1138 raise util.Abort(_("too many revisions to diff")) |
1138 raise util.Abort(_("too many revisions to diff")) |
1139 |
1139 |
1140 fns, matchfn, anypats = matchpats(repo, pats, opts) |
1140 fns, matchfn, anypats = matchpats(repo, pats, opts) |
1141 |
1141 |
1142 dodiff(sys.stdout, ui, repo, node1, node2, fns, match=matchfn, |
1142 dodiff(sys.stdout, ui, repo, node1, node2, fns, match=matchfn, |
1143 text=opts['text']) |
1143 text=opts['text'], opts=opts) |
1144 |
1144 |
1145 def doexport(ui, repo, changeset, seqno, total, revwidth, opts): |
1145 def doexport(ui, repo, changeset, seqno, total, revwidth, opts): |
1146 node = repo.lookup(changeset) |
1146 node = repo.lookup(changeset) |
1147 parents = [p for p in repo.changelog.parents(node) if p != nullid] |
1147 parents = [p for p in repo.changelog.parents(node) if p != nullid] |
1148 if opts['switch_parent']: |
1148 if opts['switch_parent']: |
2156 r = "%5d:%s" % (repo.changelog.rev(n), hex(n)) |
2156 r = "%5d:%s" % (repo.changelog.rev(n), hex(n)) |
2157 except KeyError: |
2157 except KeyError: |
2158 r = " ?:?" |
2158 r = " ?:?" |
2159 ui.write("%-30s %s\n" % (t, r)) |
2159 ui.write("%-30s %s\n" % (t, r)) |
2160 |
2160 |
2161 def tip(ui, repo): |
2161 def tip(ui, repo, **opts): |
2162 """show the tip revision |
2162 """show the tip revision |
2163 |
2163 |
2164 Show the tip revision. |
2164 Show the tip revision. |
2165 """ |
2165 """ |
2166 n = repo.changelog.tip() |
2166 n = repo.changelog.tip() |
2167 show_changeset(ui, repo, changenode=n) |
2167 show_changeset(ui, repo, changenode=n) |
|
2168 if opts['patch']: |
|
2169 dodiff(ui, ui, repo, repo.changelog.parents(n)[0], n) |
2168 |
2170 |
2169 def unbundle(ui, repo, fname, **opts): |
2171 def unbundle(ui, repo, fname, **opts): |
2170 """apply a changegroup file |
2172 """apply a changegroup file |
2171 |
2173 |
2172 Apply a compressed changegroup file generated by the bundle |
2174 Apply a compressed changegroup file generated by the bundle |
2338 "^diff": |
2340 "^diff": |
2339 (diff, |
2341 (diff, |
2340 [('r', 'rev', [], _('revision')), |
2342 [('r', 'rev', [], _('revision')), |
2341 ('a', 'text', None, _('treat all files as text')), |
2343 ('a', 'text', None, _('treat all files as text')), |
2342 ('I', 'include', [], _('include names matching the given patterns')), |
2344 ('I', 'include', [], _('include names matching the given patterns')), |
2343 ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
2345 ('p', 'show-function', None, |
|
2346 _('show which function each change is in')), |
|
2347 ('w', 'ignore-all-space', None, |
|
2348 _('ignore white space when comparing lines')), |
|
2349 ('X', 'exclude', [], |
|
2350 _('exclude names matching the given patterns'))], |
2344 _('hg diff [-a] [-I] [-X] [-r REV1 [-r REV2]] [FILE]...')), |
2351 _('hg diff [-a] [-I] [-X] [-r REV1 [-r REV2]] [FILE]...')), |
2345 "^export": |
2352 "^export": |
2346 (export, |
2353 (export, |
2347 [('o', 'output', '', _('print output to file with formatted name')), |
2354 [('o', 'output', '', _('print output to file with formatted name')), |
2348 ('a', 'text', None, _('treat all files as text')), |
2355 ('a', 'text', None, _('treat all files as text')), |
2499 ('d', 'date', '', _('record datecode as commit date')), |
2506 ('d', 'date', '', _('record datecode as commit date')), |
2500 ('u', 'user', '', _('record user as commiter')), |
2507 ('u', 'user', '', _('record user as commiter')), |
2501 ('r', 'rev', '', _('revision to tag'))], |
2508 ('r', 'rev', '', _('revision to tag'))], |
2502 _('hg tag [-r REV] [OPTION]... NAME')), |
2509 _('hg tag [-r REV] [OPTION]... NAME')), |
2503 "tags": (tags, [], _('hg tags')), |
2510 "tags": (tags, [], _('hg tags')), |
2504 "tip": (tip, [], _('hg tip')), |
2511 "tip": (tip, [('p', 'patch', None, _('show patch'))], _('hg tip')), |
2505 "unbundle": |
2512 "unbundle": |
2506 (unbundle, |
2513 (unbundle, |
2507 [('u', 'update', None, |
2514 [('u', 'update', None, |
2508 _('update the working directory to tip after unbundle'))], |
2515 _('update the working directory to tip after unbundle'))], |
2509 _('hg unbundle [-u] FILE')), |
2516 _('hg unbundle [-u] FILE')), |