Show More
@@ -17,7 +17,7 from mercurial.cmdutil import revrange, | |||||
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 |
|
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' | |
@@ -307,54 +307,16 def gincoming(ui, repo, source="default" | |||||
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.''' |
@@ -408,39 +408,35 def merge(repo, node, force=None, remind | |||||
408 | repo.ui.status(_("(branch merge, don't forget to commit)\n")) |
|
408 | repo.ui.status(_("(branch merge, don't forget to commit)\n")) | |
409 | return stats[3] > 0 |
|
409 | return stats[3] > 0 | |
410 |
|
410 | |||
411 |
def incoming(ui, repo, source, |
|
411 | def _incoming(displaychlist, subreporecurse, ui, repo, source, | |
412 | def recurse(): |
|
412 | opts, buffered=False): | |
413 | ret = 1 |
|
413 | """ | |
414 | if opts.get('subrepos'): |
|
414 | Helper for incoming / gincoming. | |
415 | ctx = repo[None] |
|
415 | displaychlist gets called with | |
416 | for subpath in sorted(ctx.substate): |
|
416 | (remoterepo, incomingchangesetlist, displayer) parameters, | |
417 | sub = ctx.sub(subpath) |
|
417 | and is supposed to contain only code that can't be unified. | |
418 | ret = min(ret, sub.incoming(ui, source, opts)) |
|
418 | """ | |
419 | return ret |
|
|||
420 |
|
||||
421 | limit = cmdutil.loglimit(opts) |
|
|||
422 | source, branches = parseurl(ui.expandpath(source), opts.get('branch')) |
|
419 | source, branches = parseurl(ui.expandpath(source), opts.get('branch')) | |
423 | other = repository(remoteui(repo, opts), source) |
|
420 | other = repository(remoteui(repo, opts), source) | |
424 | ui.status(_('comparing with %s\n') % url.hidepassword(source)) |
|
421 | ui.status(_('comparing with %s\n') % url.hidepassword(source)) | |
425 | revs, checkout = addbranchrevs(repo, other, branches, opts.get('rev')) |
|
422 | revs, checkout = addbranchrevs(repo, other, branches, opts.get('rev')) | |
|
423 | ||||
426 | if revs: |
|
424 | if revs: | |
427 | revs = [other.lookup(rev) for rev in revs] |
|
425 | revs = [other.lookup(rev) for rev in revs] | |
428 |
|
426 | bundlename = opts["bundle"] | ||
429 | tmp = discovery.findcommonincoming(repo, other, heads=revs, |
|
427 | force = opts["force"] | |
430 | force=opts.get('force')) |
|
428 | tmp = discovery.findcommonincoming(repo, other, heads=revs, force=force) | |
431 | common, incoming, rheads = tmp |
|
429 | common, incoming, rheads = tmp | |
432 | if not incoming: |
|
430 | if not incoming: | |
433 | try: |
|
431 | try: | |
434 |
os.unlink( |
|
432 | os.unlink(bundlename) | |
435 | except: |
|
433 | except: | |
436 | pass |
|
434 | pass | |
437 | ui.status(_("no changes found\n")) |
|
435 | ui.status(_("no changes found\n")) | |
438 | return recurse() |
|
436 | return subreporecurse() | |
439 |
|
437 | |||
440 |
|
|
438 | bundle = None | |
441 | try: |
|
439 | if bundlename or not other.local(): | |
442 | fname = opts["bundle"] |
|
|||
443 | if fname or not other.local(): |
|
|||
444 |
|
|
440 | # create a bundle (uncompressed if other repo is not local) | |
445 |
|
441 | |||
446 |
|
|
442 | if revs is None and other.capable('changegroupsubset'): | |
@@ -451,18 +447,45 def incoming(ui, repo, source, opts): | |||||
451 |
|
|
447 | else: | |
452 |
|
|
448 | cg = other.changegroupsubset(incoming, revs, 'incoming') | |
453 |
|
|
449 | bundletype = other.local() and "HG10BZ" or "HG10UN" | |
454 |
|
|
450 | fname = bundle = changegroup.writebundle(cg, bundlename, bundletype) | |
455 |
|
|
451 | # keep written bundle? | |
456 |
|
|
452 | if bundlename: | |
457 |
|
|
453 | bundle = None | |
458 |
|
|
454 | if not other.local(): | |
459 |
|
|
455 | # use the created uncompressed bundlerepo | |
460 |
|
|
456 | other = bundlerepo.bundlerepository(ui, repo.root, fname) | |
461 |
|
457 | |||
|
458 | try: | |||
462 | chlist = other.changelog.nodesbetween(incoming, revs)[0] |
|
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 | ||||
|
475 | def incoming(ui, repo, source, opts): | |||
|
476 | def subreporecurse(): | |||
|
477 | ret = 1 | |||
|
478 | if opts.get('subrepos'): | |||
|
479 | ctx = repo[None] | |||
|
480 | for subpath in sorted(ctx.substate): | |||
|
481 | sub = ctx.sub(subpath) | |||
|
482 | ret = min(ret, sub.incoming(ui, source, opts)) | |||
|
483 | return ret | |||
|
484 | ||||
|
485 | def display(other, chlist, displayer): | |||
|
486 | limit = cmdutil.loglimit(opts) | |||
463 | if opts.get('newest_first'): |
|
487 | if opts.get('newest_first'): | |
464 | chlist.reverse() |
|
488 | chlist.reverse() | |
465 | displayer = cmdutil.show_changeset(ui, other, opts) |
|
|||
466 | count = 0 |
|
489 | count = 0 | |
467 | for n in chlist: |
|
490 | for n in chlist: | |
468 | if limit is not None and count >= limit: |
|
491 | if limit is not None and count >= limit: | |
@@ -472,14 +495,7 def incoming(ui, repo, source, opts): | |||||
472 | continue |
|
495 | continue | |
473 | count += 1 |
|
496 | count += 1 | |
474 | displayer.show(other[n]) |
|
497 | displayer.show(other[n]) | |
475 | displayer.close() |
|
498 | return _incoming(display, subreporecurse, ui, repo, source, opts) | |
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 |
|
|||
483 |
|
499 | |||
484 | def outgoing(ui, repo, dest, opts): |
|
500 | def outgoing(ui, repo, dest, opts): | |
485 | def recurse(): |
|
501 | def recurse(): |
General Comments 0
You need to be logged in to leave comments.
Login now