Show More
@@ -17,7 +17,7 b' from mercurial.cmdutil import revrange, ' | |||
|
17 | 17 | from mercurial.commands import templateopts |
|
18 | 18 | from mercurial.i18n import _ |
|
19 | 19 | from mercurial.node import nullrev |
|
20 |
from mercurial import |
|
|
20 | from mercurial import cmdutil, commands, extensions | |
|
21 | 21 | from mercurial import hg, url, util, graphmod, discovery |
|
22 | 22 | |
|
23 | 23 | ASCIIDATA = 'ASC' |
@@ -307,54 +307,16 b' def gincoming(ui, repo, source="default"' | |||
|
307 | 307 | Nodes printed as an @ character are parents of the working |
|
308 | 308 | directory. |
|
309 | 309 | """ |
|
310 | def subreporecurse(): | |
|
311 | return 1 | |
|
310 | 312 | |
|
311 | 313 | check_unsupported_flags(opts) |
|
312 | source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch')) | |
|
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] | |
|
314 | def display(other, chlist, displayer): | |
|
348 | 315 | revdag = graphrevs(other, chlist, opts) |
|
349 | displayer = show_changeset(ui, other, opts, buffered=True) | |
|
350 | 316 | showparents = [ctx.node() for ctx in repo[None].parents()] |
|
351 | 317 | generate(ui, revdag, displayer, showparents, asciiedges) |
|
352 | 318 | |
|
353 | finally: | |
|
354 | if hasattr(other, 'close'): | |
|
355 | other.close() | |
|
356 | if cleanup: | |
|
357 | os.unlink(cleanup) | |
|
319 | hg._incoming(display, subreporecurse, ui, repo, source, opts, buffered=True) | |
|
358 | 320 | |
|
359 | 321 | def uisetup(ui): |
|
360 | 322 | '''Initialize the extension.''' |
@@ -408,8 +408,72 b' def merge(repo, node, force=None, remind' | |||
|
408 | 408 | repo.ui.status(_("(branch merge, don't forget to commit)\n")) |
|
409 | 409 | return stats[3] > 0 |
|
410 | 410 | |
|
411 | def _incoming(displaychlist, subreporecurse, ui, repo, source, | |
|
412 | opts, buffered=False): | |
|
413 | """ | |
|
414 | Helper for incoming / gincoming. | |
|
415 | displaychlist gets called with | |
|
416 | (remoterepo, incomingchangesetlist, displayer) parameters, | |
|
417 | and is supposed to contain only code that can't be unified. | |
|
418 | """ | |
|
419 | source, branches = parseurl(ui.expandpath(source), opts.get('branch')) | |
|
420 | other = repository(remoteui(repo, opts), source) | |
|
421 | ui.status(_('comparing with %s\n') % url.hidepassword(source)) | |
|
422 | revs, checkout = addbranchrevs(repo, other, branches, opts.get('rev')) | |
|
423 | ||
|
424 | if revs: | |
|
425 | revs = [other.lookup(rev) for rev in revs] | |
|
426 | bundlename = opts["bundle"] | |
|
427 | force = opts["force"] | |
|
428 | tmp = discovery.findcommonincoming(repo, other, heads=revs, force=force) | |
|
429 | common, incoming, rheads = tmp | |
|
430 | if not incoming: | |
|
431 | try: | |
|
432 | os.unlink(bundlename) | |
|
433 | except: | |
|
434 | pass | |
|
435 | ui.status(_("no changes found\n")) | |
|
436 | return subreporecurse() | |
|
437 | ||
|
438 | bundle = None | |
|
439 | if bundlename or not other.local(): | |
|
440 | # create a bundle (uncompressed if other repo is not local) | |
|
441 | ||
|
442 | if revs is None and other.capable('changegroupsubset'): | |
|
443 | revs = rheads | |
|
444 | ||
|
445 | if revs is None: | |
|
446 | cg = other.changegroup(incoming, "incoming") | |
|
447 | else: | |
|
448 | cg = other.changegroupsubset(incoming, revs, 'incoming') | |
|
449 | bundletype = other.local() and "HG10BZ" or "HG10UN" | |
|
450 | fname = bundle = changegroup.writebundle(cg, bundlename, bundletype) | |
|
451 | # keep written bundle? | |
|
452 | if bundlename: | |
|
453 | bundle = None | |
|
454 | if not other.local(): | |
|
455 | # use the created uncompressed bundlerepo | |
|
456 | other = bundlerepo.bundlerepository(ui, repo.root, fname) | |
|
457 | ||
|
458 | try: | |
|
459 | chlist = other.changelog.nodesbetween(incoming, revs)[0] | |
|
460 | displayer = cmdutil.show_changeset(ui, other, opts, buffered) | |
|
461 | ||
|
462 | # XXX once graphlog extension makes it into core, | |
|
463 | # should be replaced by a if graph/else | |
|
464 | displaychlist(other, chlist, displayer) | |
|
465 | ||
|
466 | displayer.close() | |
|
467 | finally: | |
|
468 | if hasattr(other, 'close'): | |
|
469 | other.close() | |
|
470 | if bundle: | |
|
471 | os.unlink(bundle) | |
|
472 | subreporecurse() | |
|
473 | return 0 # exit code is zero since we found incoming changes | |
|
474 | ||
|
411 | 475 | def incoming(ui, repo, source, opts): |
|
412 | def recurse(): | |
|
476 | def subreporecurse(): | |
|
413 | 477 | ret = 1 |
|
414 | 478 | if opts.get('subrepos'): |
|
415 | 479 | ctx = repo[None] |
@@ -418,51 +482,10 b' def incoming(ui, repo, source, opts):' | |||
|
418 | 482 | ret = min(ret, sub.incoming(ui, source, opts)) |
|
419 | 483 | return ret |
|
420 | 484 | |
|
421 | limit = cmdutil.loglimit(opts) | |
|
422 | source, branches = parseurl(ui.expandpath(source), opts.get('branch')) | |
|
423 | other = repository(remoteui(repo, opts), source) | |
|
424 | ui.status(_('comparing with %s\n') % url.hidepassword(source)) | |
|
425 | revs, checkout = addbranchrevs(repo, other, branches, opts.get('rev')) | |
|
426 | if revs: | |
|
427 | revs = [other.lookup(rev) for rev in revs] | |
|
428 | ||
|
429 | tmp = discovery.findcommonincoming(repo, other, heads=revs, | |
|
430 | force=opts.get('force')) | |
|
431 | common, incoming, rheads = tmp | |
|
432 | if not incoming: | |
|
433 | try: | |
|
434 | os.unlink(opts["bundle"]) | |
|
435 | except: | |
|
436 | pass | |
|
437 | ui.status(_("no changes found\n")) | |
|
438 | return recurse() | |
|
439 | ||
|
440 | cleanup = None | |
|
441 | try: | |
|
442 | fname = opts["bundle"] | |
|
443 | if fname or not other.local(): | |
|
444 | # create a bundle (uncompressed if other repo is not local) | |
|
445 | ||
|
446 | if revs is None and other.capable('changegroupsubset'): | |
|
447 | revs = rheads | |
|
448 | ||
|
449 | if revs is None: | |
|
450 | cg = other.changegroup(incoming, "incoming") | |
|
451 | else: | |
|
452 | cg = other.changegroupsubset(incoming, revs, 'incoming') | |
|
453 | bundletype = other.local() and "HG10BZ" or "HG10UN" | |
|
454 | fname = cleanup = changegroup.writebundle(cg, fname, bundletype) | |
|
455 | # keep written bundle? | |
|
456 | if opts["bundle"]: | |
|
457 | cleanup = None | |
|
458 | if not other.local(): | |
|
459 | # use the created uncompressed bundlerepo | |
|
460 | other = bundlerepo.bundlerepository(ui, repo.root, fname) | |
|
461 | ||
|
462 | chlist = other.changelog.nodesbetween(incoming, revs)[0] | |
|
485 | def display(other, chlist, displayer): | |
|
486 | limit = cmdutil.loglimit(opts) | |
|
463 | 487 | if opts.get('newest_first'): |
|
464 | 488 | chlist.reverse() |
|
465 | displayer = cmdutil.show_changeset(ui, other, opts) | |
|
466 | 489 | count = 0 |
|
467 | 490 | for n in chlist: |
|
468 | 491 | if limit is not None and count >= limit: |
@@ -472,14 +495,7 b' def incoming(ui, repo, source, opts):' | |||
|
472 | 495 | continue |
|
473 | 496 | count += 1 |
|
474 | 497 | displayer.show(other[n]) |
|
475 | displayer.close() | |
|
476 | finally: | |
|
477 | if hasattr(other, 'close'): | |
|
478 | other.close() | |
|
479 | if cleanup: | |
|
480 | os.unlink(cleanup) | |
|
481 | recurse() | |
|
482 | return 0 # exit code is zero since we found incoming changes | |
|
498 | return _incoming(display, subreporecurse, ui, repo, source, opts) | |
|
483 | 499 | |
|
484 | 500 | def outgoing(ui, repo, dest, opts): |
|
485 | 501 | def recurse(): |
General Comments 0
You need to be logged in to leave comments.
Login now