Show More
@@ -9,7 +9,7 from node import hex, nullid, nullrev, s | |||
|
9 | 9 | from lock import release |
|
10 | 10 | from i18n import _, gettext |
|
11 | 11 | import os, re, sys, difflib, time, tempfile |
|
12 |
import hg, util, revlog, |
|
|
12 | import hg, util, revlog, extensions, copies, error | |
|
13 | 13 | import patch, help, mdiff, url, encoding, templatekw, discovery |
|
14 | 14 | import archival, changegroup, cmdutil, sshserver, hbisect, hgweb, hgweb.server |
|
15 | 15 | import merge as mergemod |
@@ -2357,66 +2357,7 def incoming(ui, repo, source="default", | |||
|
2357 | 2357 | |
|
2358 | 2358 | Returns 0 if there are incoming changes, 1 otherwise. |
|
2359 | 2359 | """ |
|
2360 | limit = cmdutil.loglimit(opts) | |
|
2361 | source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch')) | |
|
2362 | other = hg.repository(hg.remoteui(repo, opts), source) | |
|
2363 | ui.status(_('comparing with %s\n') % url.hidepassword(source)) | |
|
2364 | revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev')) | |
|
2365 | if revs: | |
|
2366 | revs = [other.lookup(rev) for rev in revs] | |
|
2367 | ||
|
2368 | tmp = discovery.findcommonincoming(repo, other, heads=revs, | |
|
2369 | force=opts.get('force')) | |
|
2370 | common, incoming, rheads = tmp | |
|
2371 | if not incoming: | |
|
2372 | try: | |
|
2373 | os.unlink(opts["bundle"]) | |
|
2374 | except: | |
|
2375 | pass | |
|
2376 | ui.status(_("no changes found\n")) | |
|
2377 | return 1 | |
|
2378 | ||
|
2379 | cleanup = None | |
|
2380 | try: | |
|
2381 | fname = opts["bundle"] | |
|
2382 | if fname or not other.local(): | |
|
2383 | # create a bundle (uncompressed if other repo is not local) | |
|
2384 | ||
|
2385 | if revs is None and other.capable('changegroupsubset'): | |
|
2386 | revs = rheads | |
|
2387 | ||
|
2388 | if revs is None: | |
|
2389 | cg = other.changegroup(incoming, "incoming") | |
|
2390 | else: | |
|
2391 | cg = other.changegroupsubset(incoming, revs, 'incoming') | |
|
2392 | bundletype = other.local() and "HG10BZ" or "HG10UN" | |
|
2393 | fname = cleanup = changegroup.writebundle(cg, fname, bundletype) | |
|
2394 | # keep written bundle? | |
|
2395 | if opts["bundle"]: | |
|
2396 | cleanup = None | |
|
2397 | if not other.local(): | |
|
2398 | # use the created uncompressed bundlerepo | |
|
2399 | other = bundlerepo.bundlerepository(ui, repo.root, fname) | |
|
2400 | ||
|
2401 | o = other.changelog.nodesbetween(incoming, revs)[0] | |
|
2402 | if opts.get('newest_first'): | |
|
2403 | o.reverse() | |
|
2404 | displayer = cmdutil.show_changeset(ui, other, opts) | |
|
2405 | count = 0 | |
|
2406 | for n in o: | |
|
2407 | if limit is not None and count >= limit: | |
|
2408 | break | |
|
2409 | parents = [p for p in other.changelog.parents(n) if p != nullid] | |
|
2410 | if opts.get('no_merges') and len(parents) == 2: | |
|
2411 | continue | |
|
2412 | count += 1 | |
|
2413 | displayer.show(other[n]) | |
|
2414 | displayer.close() | |
|
2415 | finally: | |
|
2416 | if hasattr(other, 'close'): | |
|
2417 | other.close() | |
|
2418 | if cleanup: | |
|
2419 | os.unlink(cleanup) | |
|
2360 | return hg.incoming(ui, repo, source, opts) | |
|
2420 | 2361 | |
|
2421 | 2362 | def init(ui, dest=".", **opts): |
|
2422 | 2363 | """create a new repository in the given directory |
@@ -11,7 +11,7 from lock import release | |||
|
11 | 11 | from node import hex, nullid, nullrev, short |
|
12 | 12 | import localrepo, bundlerepo, httprepo, sshrepo, statichttprepo |
|
13 | 13 | import lock, util, extensions, error, encoding, node |
|
14 | import cmdutil, discovery, url | |
|
14 | import cmdutil, discovery, url, changegroup | |
|
15 | 15 | import merge as mergemod |
|
16 | 16 | import verify as verifymod |
|
17 | 17 | import errno, os, shutil |
@@ -408,6 +408,68 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, opts): | |
|
412 | limit = cmdutil.loglimit(opts) | |
|
413 | source, branches = parseurl(ui.expandpath(source), opts.get('branch')) | |
|
414 | other = repository(remoteui(repo, opts), source) | |
|
415 | ui.status(_('comparing with %s\n') % url.hidepassword(source)) | |
|
416 | revs, checkout = addbranchrevs(repo, other, branches, opts.get('rev')) | |
|
417 | if revs: | |
|
418 | revs = [other.lookup(rev) for rev in revs] | |
|
419 | ||
|
420 | tmp = discovery.findcommonincoming(repo, other, heads=revs, | |
|
421 | force=opts.get('force')) | |
|
422 | common, incoming, rheads = tmp | |
|
423 | if not incoming: | |
|
424 | try: | |
|
425 | os.unlink(opts["bundle"]) | |
|
426 | except: | |
|
427 | pass | |
|
428 | ui.status(_("no changes found\n")) | |
|
429 | return 1 | |
|
430 | ||
|
431 | cleanup = None | |
|
432 | try: | |
|
433 | fname = opts["bundle"] | |
|
434 | if fname or not other.local(): | |
|
435 | # create a bundle (uncompressed if other repo is not local) | |
|
436 | ||
|
437 | if revs is None and other.capable('changegroupsubset'): | |
|
438 | revs = rheads | |
|
439 | ||
|
440 | if revs is None: | |
|
441 | cg = other.changegroup(incoming, "incoming") | |
|
442 | else: | |
|
443 | cg = other.changegroupsubset(incoming, revs, 'incoming') | |
|
444 | bundletype = other.local() and "HG10BZ" or "HG10UN" | |
|
445 | fname = cleanup = changegroup.writebundle(cg, fname, bundletype) | |
|
446 | # keep written bundle? | |
|
447 | if opts["bundle"]: | |
|
448 | cleanup = None | |
|
449 | if not other.local(): | |
|
450 | # use the created uncompressed bundlerepo | |
|
451 | other = bundlerepo.bundlerepository(ui, repo.root, fname) | |
|
452 | ||
|
453 | o = other.changelog.nodesbetween(incoming, revs)[0] | |
|
454 | if opts.get('newest_first'): | |
|
455 | o.reverse() | |
|
456 | displayer = cmdutil.show_changeset(ui, other, opts) | |
|
457 | count = 0 | |
|
458 | for n in o: | |
|
459 | if limit is not None and count >= limit: | |
|
460 | break | |
|
461 | parents = [p for p in other.changelog.parents(n) if p != nullid] | |
|
462 | if opts.get('no_merges') and len(parents) == 2: | |
|
463 | continue | |
|
464 | count += 1 | |
|
465 | displayer.show(other[n]) | |
|
466 | displayer.close() | |
|
467 | finally: | |
|
468 | if hasattr(other, 'close'): | |
|
469 | other.close() | |
|
470 | if cleanup: | |
|
471 | os.unlink(cleanup) | |
|
472 | ||
|
411 | 473 | def outgoing(ui, repo, dest, opts): |
|
412 | 474 | limit = cmdutil.loglimit(opts) |
|
413 | 475 | dest = ui.expandpath(dest or 'default-push', dest or 'default') |
General Comments 0
You need to be logged in to leave comments.
Login now