Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 12273:e392d00ab5b0
incoming: move code from commands to cmdutil
This makes it easier to reuse it in a recursive fashion for subrepos.
author | Martin Geisler <mg@lazybytes.net> |
---|---|
date | Mon, 13 Sep 2010 13:09:30 +0200 |
parents | 42ecd56399d7 |
children | c02e1ed3d407 |
comparison
equal
deleted
inserted
replaced
12272:42ecd56399d7 | 12273:e392d00ab5b0 |
---|---|
7 | 7 |
8 from node import hex, nullid, nullrev, short | 8 from node import hex, nullid, nullrev, short |
9 from lock import release | 9 from lock import release |
10 from i18n import _, gettext | 10 from i18n import _, gettext |
11 import os, re, sys, difflib, time, tempfile | 11 import os, re, sys, difflib, time, tempfile |
12 import hg, util, revlog, bundlerepo, extensions, copies, error | 12 import hg, util, revlog, extensions, copies, error |
13 import patch, help, mdiff, url, encoding, templatekw, discovery | 13 import patch, help, mdiff, url, encoding, templatekw, discovery |
14 import archival, changegroup, cmdutil, sshserver, hbisect, hgweb, hgweb.server | 14 import archival, changegroup, cmdutil, sshserver, hbisect, hgweb, hgweb.server |
15 import merge as mergemod | 15 import merge as mergemod |
16 import minirst, revset | 16 import minirst, revset |
17 import dagparser | 17 import dagparser |
2355 | 2355 |
2356 See pull for valid source format details. | 2356 See pull for valid source format details. |
2357 | 2357 |
2358 Returns 0 if there are incoming changes, 1 otherwise. | 2358 Returns 0 if there are incoming changes, 1 otherwise. |
2359 """ | 2359 """ |
2360 limit = cmdutil.loglimit(opts) | 2360 return hg.incoming(ui, repo, source, 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) | |
2420 | 2361 |
2421 def init(ui, dest=".", **opts): | 2362 def init(ui, dest=".", **opts): |
2422 """create a new repository in the given directory | 2363 """create a new repository in the given directory |
2423 | 2364 |
2424 Initialize a new repository in the given directory. If the given | 2365 Initialize a new repository in the given directory. If the given |