15 import os |
15 import os |
16 from mercurial.cmdutil import revrange, show_changeset |
16 from mercurial.cmdutil import revrange, show_changeset |
17 from mercurial.commands import templateopts |
17 from mercurial.commands import templateopts |
18 from mercurial.i18n import _ |
18 from mercurial.i18n import _ |
19 from mercurial.node import nullrev |
19 from mercurial.node import nullrev |
20 from mercurial import bundlerepo, changegroup, cmdutil, commands, extensions |
20 from mercurial import cmdutil, commands, extensions |
21 from mercurial import hg, url, util, graphmod, discovery |
21 from mercurial import hg, url, util, graphmod, discovery |
22 |
22 |
23 ASCIIDATA = 'ASC' |
23 ASCIIDATA = 'ASC' |
24 |
24 |
25 def asciiedges(seen, rev, parents): |
25 def asciiedges(seen, rev, parents): |
305 ASCII characters. |
305 ASCII characters. |
306 |
306 |
307 Nodes printed as an @ character are parents of the working |
307 Nodes printed as an @ character are parents of the working |
308 directory. |
308 directory. |
309 """ |
309 """ |
|
310 def subreporecurse(): |
|
311 return 1 |
310 |
312 |
311 check_unsupported_flags(opts) |
313 check_unsupported_flags(opts) |
312 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch')) |
314 def display(other, chlist, displayer): |
313 other = hg.repository(hg.remoteui(repo, opts), source) |
|
314 revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev')) |
|
315 ui.status(_('comparing with %s\n') % url.hidepassword(source)) |
|
316 if revs: |
|
317 revs = [other.lookup(rev) for rev in revs] |
|
318 incoming = discovery.findincoming(repo, other, heads=revs, |
|
319 force=opts["force"]) |
|
320 if not incoming: |
|
321 try: |
|
322 os.unlink(opts["bundle"]) |
|
323 except: |
|
324 pass |
|
325 ui.status(_("no changes found\n")) |
|
326 return |
|
327 |
|
328 cleanup = None |
|
329 try: |
|
330 |
|
331 fname = opts["bundle"] |
|
332 if fname or not other.local(): |
|
333 # create a bundle (uncompressed if other repo is not local) |
|
334 if revs is None: |
|
335 cg = other.changegroup(incoming, "incoming") |
|
336 else: |
|
337 cg = other.changegroupsubset(incoming, revs, 'incoming') |
|
338 bundletype = other.local() and "HG10BZ" or "HG10UN" |
|
339 fname = cleanup = changegroup.writebundle(cg, fname, bundletype) |
|
340 # keep written bundle? |
|
341 if opts["bundle"]: |
|
342 cleanup = None |
|
343 if not other.local(): |
|
344 # use the created uncompressed bundlerepo |
|
345 other = bundlerepo.bundlerepository(ui, repo.root, fname) |
|
346 |
|
347 chlist = other.changelog.nodesbetween(incoming, revs)[0] |
|
348 revdag = graphrevs(other, chlist, opts) |
315 revdag = graphrevs(other, chlist, opts) |
349 displayer = show_changeset(ui, other, opts, buffered=True) |
|
350 showparents = [ctx.node() for ctx in repo[None].parents()] |
316 showparents = [ctx.node() for ctx in repo[None].parents()] |
351 generate(ui, revdag, displayer, showparents, asciiedges) |
317 generate(ui, revdag, displayer, showparents, asciiedges) |
352 |
318 |
353 finally: |
319 hg._incoming(display, subreporecurse, ui, repo, source, opts, buffered=True) |
354 if hasattr(other, 'close'): |
|
355 other.close() |
|
356 if cleanup: |
|
357 os.unlink(cleanup) |
|
358 |
320 |
359 def uisetup(ui): |
321 def uisetup(ui): |
360 '''Initialize the extension.''' |
322 '''Initialize the extension.''' |
361 _wrapcmd(ui, 'log', commands.table, graphlog) |
323 _wrapcmd(ui, 'log', commands.table, graphlog) |
362 _wrapcmd(ui, 'incoming', commands.table, gincoming) |
324 _wrapcmd(ui, 'incoming', commands.table, gincoming) |