20 from mercurial import bundlerepo, changegroup, cmdutil, commands, extensions |
20 from mercurial import bundlerepo, changegroup, cmdutil, commands, extensions |
21 from mercurial import hg, url, util, graphmod |
21 from mercurial import hg, url, util, graphmod |
22 |
22 |
23 ASCIIDATA = 'ASC' |
23 ASCIIDATA = 'ASC' |
24 |
24 |
25 def asciiformat(ui, repo, revdag, opts, parentrepo=None): |
25 def asciiformat(revdag, displayer, parents): |
26 """formats a changelog DAG walk for ASCII output""" |
26 """formats a changelog DAG walk for ASCII output""" |
27 if parentrepo is None: |
|
28 parentrepo = repo |
|
29 showparents = [ctx.node() for ctx in parentrepo[None].parents()] |
|
30 displayer = show_changeset(ui, repo, opts, buffered=True) |
|
31 for (id, type, ctx, parentids) in revdag: |
27 for (id, type, ctx, parentids) in revdag: |
32 if type != graphmod.CHANGESET: |
28 if type != graphmod.CHANGESET: |
33 continue |
29 continue |
34 displayer.show(ctx) |
30 displayer.show(ctx) |
35 lines = displayer.hunk.pop(ctx.rev()).split('\n')[:-1] |
31 lines = displayer.hunk.pop(ctx.rev()).split('\n')[:-1] |
36 char = ctx.node() in showparents and '@' or 'o' |
32 char = ctx.node() in parents and '@' or 'o' |
37 yield (id, ASCIIDATA, (char, lines), parentids) |
33 yield (id, ASCIIDATA, (char, lines), parentids) |
38 |
34 |
39 def asciiedges(nodes): |
35 def asciiedges(nodes): |
40 """adds edge info to changelog DAG walk suitable for ascii()""" |
36 """adds edge info to changelog DAG walk suitable for ascii()""" |
41 seen = [] |
37 seen = [] |
257 if path: # could be reset in canonpath |
253 if path: # could be reset in canonpath |
258 revdag = graphmod.filerevs(repo, path, start, stop) |
254 revdag = graphmod.filerevs(repo, path, start, stop) |
259 else: |
255 else: |
260 revdag = graphmod.revisions(repo, start, stop) |
256 revdag = graphmod.revisions(repo, start, stop) |
261 |
257 |
262 fmtdag = asciiformat(ui, repo, revdag, opts) |
258 displayer = show_changeset(ui, repo, opts, buffered=True) |
|
259 showparents = [ctx.node() for ctx in repo[None].parents()] |
|
260 fmtdag = asciiformat(revdag, displayer, showparents) |
263 ascii(ui, asciiedges(fmtdag)) |
261 ascii(ui, asciiedges(fmtdag)) |
264 |
262 |
265 def graphrevs(repo, nodes, opts): |
263 def graphrevs(repo, nodes, opts): |
266 limit = cmdutil.loglimit(opts) |
264 limit = cmdutil.loglimit(opts) |
267 nodes.reverse() |
265 nodes.reverse() |
292 ui.status(_("no changes found\n")) |
290 ui.status(_("no changes found\n")) |
293 return |
291 return |
294 |
292 |
295 o = repo.changelog.nodesbetween(o, revs)[0] |
293 o = repo.changelog.nodesbetween(o, revs)[0] |
296 revdag = graphrevs(repo, o, opts) |
294 revdag = graphrevs(repo, o, opts) |
297 fmtdag = asciiformat(ui, repo, revdag, opts) |
295 displayer = show_changeset(ui, repo, opts, buffered=True) |
|
296 showparents = [ctx.node() for ctx in repo[None].parents()] |
|
297 fmtdag = asciiformat(revdag, displayer, showparents) |
298 ascii(ui, asciiedges(fmtdag)) |
298 ascii(ui, asciiedges(fmtdag)) |
299 |
299 |
300 def gincoming(ui, repo, source="default", **opts): |
300 def gincoming(ui, repo, source="default", **opts): |
301 """show the incoming changesets alongside an ASCII revision graph |
301 """show the incoming changesets alongside an ASCII revision graph |
302 |
302 |
341 # use the created uncompressed bundlerepo |
341 # use the created uncompressed bundlerepo |
342 other = bundlerepo.bundlerepository(ui, repo.root, fname) |
342 other = bundlerepo.bundlerepository(ui, repo.root, fname) |
343 |
343 |
344 chlist = other.changelog.nodesbetween(incoming, revs)[0] |
344 chlist = other.changelog.nodesbetween(incoming, revs)[0] |
345 revdag = graphrevs(other, chlist, opts) |
345 revdag = graphrevs(other, chlist, opts) |
346 fmtdag = asciiformat(ui, other, revdag, opts, parentrepo=repo) |
346 displayer = show_changeset(ui, other, opts, buffered=True) |
|
347 showparents = [ctx.node() for ctx in repo[None].parents()] |
|
348 fmtdag = asciiformat(revdag, displayer, showparents) |
347 ascii(ui, asciiedges(fmtdag)) |
349 ascii(ui, asciiedges(fmtdag)) |
348 |
350 |
349 finally: |
351 finally: |
350 if hasattr(other, 'close'): |
352 if hasattr(other, 'close'): |
351 other.close() |
353 other.close() |