Show More
@@ -17,7 +17,7 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 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,39 +408,35 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(ui, repo, source, |
|
|
412 | def recurse(): | |
|
413 | ret = 1 | |
|
414 | if opts.get('subrepos'): | |
|
415 | ctx = repo[None] | |
|
416 | for subpath in sorted(ctx.substate): | |
|
417 | sub = ctx.sub(subpath) | |
|
418 | ret = min(ret, sub.incoming(ui, source, opts)) | |
|
419 | return ret | |
|
420 | ||
|
421 | limit = cmdutil.loglimit(opts) | |
|
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 | """ | |
|
422 | 419 | source, branches = parseurl(ui.expandpath(source), opts.get('branch')) |
|
423 | 420 | other = repository(remoteui(repo, opts), source) |
|
424 | 421 | ui.status(_('comparing with %s\n') % url.hidepassword(source)) |
|
425 | 422 | revs, checkout = addbranchrevs(repo, other, branches, opts.get('rev')) |
|
423 | ||
|
426 | 424 | if revs: |
|
427 | 425 | revs = [other.lookup(rev) for rev in revs] |
|
428 | ||
|
429 | tmp = discovery.findcommonincoming(repo, other, heads=revs, | |
|
430 | force=opts.get('force')) | |
|
426 | bundlename = opts["bundle"] | |
|
427 | force = opts["force"] | |
|
428 | tmp = discovery.findcommonincoming(repo, other, heads=revs, force=force) | |
|
431 | 429 | common, incoming, rheads = tmp |
|
432 | 430 | if not incoming: |
|
433 | 431 | try: |
|
434 |
os.unlink( |
|
|
432 | os.unlink(bundlename) | |
|
435 | 433 | except: |
|
436 | 434 | pass |
|
437 | 435 | ui.status(_("no changes found\n")) |
|
438 | return recurse() | |
|
436 | return subreporecurse() | |
|
439 | 437 | |
|
440 |
|
|
|
441 | try: | |
|
442 | fname = opts["bundle"] | |
|
443 | if fname or not other.local(): | |
|
438 | bundle = None | |
|
439 | if bundlename or not other.local(): | |
|
444 | 440 |
|
|
445 | 441 | |
|
446 | 442 |
|
@@ -451,18 +447,45 def incoming(ui, repo, source, opts): | |||
|
451 | 447 |
|
|
452 | 448 |
|
|
453 | 449 |
|
|
454 |
|
|
|
450 | fname = bundle = changegroup.writebundle(cg, bundlename, bundletype) | |
|
455 | 451 |
|
|
456 |
|
|
|
457 |
|
|
|
452 | if bundlename: | |
|
453 | bundle = None | |
|
458 | 454 |
|
|
459 | 455 |
|
|
460 | 456 |
|
|
461 | 457 | |
|
458 | try: | |
|
462 | 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 | 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 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