Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 4494:649dd2492ae5
Merge with crew.
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Sat, 02 Jun 2007 09:04:23 -0700 |
parents | c927c568a5ad b2b55acbacdd |
children | 0ca5ef554987 |
comparison
equal
deleted
inserted
replaced
4493:ead2fa544cbf | 4494:649dd2492ae5 |
---|---|
334 if p not in seen: | 334 if p not in seen: |
335 seen[p] = 1 | 335 seen[p] = 1 |
336 visit.append(p) | 336 visit.append(p) |
337 else: | 337 else: |
338 setremoteconfig(ui, opts) | 338 setremoteconfig(ui, opts) |
339 dest = ui.expandpath(dest or 'default-push', dest or 'default') | 339 dest, revs = cmdutil.parseurl( |
340 ui.expandpath(dest or 'default-push', dest or 'default'), revs) | |
340 other = hg.repository(ui, dest) | 341 other = hg.repository(ui, dest) |
341 o = repo.findoutgoing(other, force=opts['force']) | 342 o = repo.findoutgoing(other, force=opts['force']) |
342 | 343 |
343 if revs: | 344 if revs: |
344 cg = repo.changegroupsubset(o, revs, 'bundle') | 345 cg = repo.changegroupsubset(o, revs, 'bundle') |
405 .hg/hgrc and working directory will be created on the remote side. | 406 .hg/hgrc and working directory will be created on the remote side. |
406 Look at the help text for the pull command for important details | 407 Look at the help text for the pull command for important details |
407 about ssh:// URLs. | 408 about ssh:// URLs. |
408 """ | 409 """ |
409 setremoteconfig(ui, opts) | 410 setremoteconfig(ui, opts) |
410 hg.clone(ui, ui.expandpath(source), dest, | 411 hg.clone(ui, source, dest, |
411 pull=opts['pull'], | 412 pull=opts['pull'], |
412 stream=opts['uncompressed'], | 413 stream=opts['uncompressed'], |
413 rev=opts['rev'], | 414 rev=opts['rev'], |
414 update=not opts['noupdate']) | 415 update=not opts['noupdate']) |
415 | 416 |
1581 For remote repository, using --bundle avoids downloading the changesets | 1582 For remote repository, using --bundle avoids downloading the changesets |
1582 twice if the incoming is followed by a pull. | 1583 twice if the incoming is followed by a pull. |
1583 | 1584 |
1584 See pull for valid source format details. | 1585 See pull for valid source format details. |
1585 """ | 1586 """ |
1586 source = ui.expandpath(source) | 1587 source, revs = cmdutil.parseurl(ui.expandpath(source), opts['rev']) |
1587 setremoteconfig(ui, opts) | 1588 setremoteconfig(ui, opts) |
1588 | 1589 |
1589 other = hg.repository(ui, source) | 1590 other = hg.repository(ui, source) |
1590 ui.status(_('comparing with %s\n') % source) | 1591 ui.status(_('comparing with %s\n') % source) |
1591 incoming = repo.findincoming(other, force=opts["force"]) | 1592 if revs: |
1593 if 'lookup' in other.capabilities: | |
1594 revs = [other.lookup(rev) for rev in revs] | |
1595 else: | |
1596 error = _("Other repository doesn't support revision lookup, so a rev cannot be specified.") | |
1597 raise util.Abort(error) | |
1598 incoming = repo.findincoming(other, heads=revs, force=opts["force"]) | |
1592 if not incoming: | 1599 if not incoming: |
1593 try: | 1600 try: |
1594 os.unlink(opts["bundle"]) | 1601 os.unlink(opts["bundle"]) |
1595 except: | 1602 except: |
1596 pass | 1603 pass |
1600 cleanup = None | 1607 cleanup = None |
1601 try: | 1608 try: |
1602 fname = opts["bundle"] | 1609 fname = opts["bundle"] |
1603 if fname or not other.local(): | 1610 if fname or not other.local(): |
1604 # create a bundle (uncompressed if other repo is not local) | 1611 # create a bundle (uncompressed if other repo is not local) |
1605 cg = other.changegroup(incoming, "incoming") | 1612 if revs is None: |
1613 cg = other.changegroup(incoming, "incoming") | |
1614 else: | |
1615 if 'changegroupsubset' not in other.capabilities: | |
1616 raise util.Abort(_("Partial incoming cannot be done because other repository doesn't support changegroupsubset.")) | |
1617 cg = other.changegroupsubset(incoming, revs, 'incoming') | |
1606 bundletype = other.local() and "HG10BZ" or "HG10UN" | 1618 bundletype = other.local() and "HG10BZ" or "HG10UN" |
1607 fname = cleanup = changegroup.writebundle(cg, fname, bundletype) | 1619 fname = cleanup = changegroup.writebundle(cg, fname, bundletype) |
1608 # keep written bundle? | 1620 # keep written bundle? |
1609 if opts["bundle"]: | 1621 if opts["bundle"]: |
1610 cleanup = None | 1622 cleanup = None |
1611 if not other.local(): | 1623 if not other.local(): |
1612 # use the created uncompressed bundlerepo | 1624 # use the created uncompressed bundlerepo |
1613 other = bundlerepo.bundlerepository(ui, repo.root, fname) | 1625 other = bundlerepo.bundlerepository(ui, repo.root, fname) |
1614 | 1626 |
1615 revs = None | |
1616 if opts['rev']: | |
1617 revs = [other.lookup(rev) for rev in opts['rev']] | |
1618 o = other.changelog.nodesbetween(incoming, revs)[0] | 1627 o = other.changelog.nodesbetween(incoming, revs)[0] |
1619 if opts['newest_first']: | 1628 if opts['newest_first']: |
1620 o.reverse() | 1629 o.reverse() |
1621 displayer = cmdutil.show_changeset(ui, other, opts) | 1630 displayer = cmdutil.show_changeset(ui, other, opts) |
1622 for n in o: | 1631 for n in o: |
1875 the default push location. These are the changesets that would be pushed | 1884 the default push location. These are the changesets that would be pushed |
1876 if a push was requested. | 1885 if a push was requested. |
1877 | 1886 |
1878 See pull for valid destination format details. | 1887 See pull for valid destination format details. |
1879 """ | 1888 """ |
1880 dest = ui.expandpath(dest or 'default-push', dest or 'default') | 1889 dest, revs = cmdutil.parseurl( |
1890 ui.expandpath(dest or 'default-push', dest or 'default'), opts['rev']) | |
1881 setremoteconfig(ui, opts) | 1891 setremoteconfig(ui, opts) |
1882 revs = None | 1892 if revs: |
1883 if opts['rev']: | 1893 revs = [repo.lookup(rev) for rev in revs] |
1884 revs = [repo.lookup(rev) for rev in opts['rev']] | |
1885 | 1894 |
1886 other = hg.repository(ui, dest) | 1895 other = hg.repository(ui, dest) |
1887 ui.status(_('comparing with %s\n') % dest) | 1896 ui.status(_('comparing with %s\n') % dest) |
1888 o = repo.findoutgoing(other, force=opts['force']) | 1897 o = repo.findoutgoing(other, force=opts['force']) |
1889 if not o: | 1898 if not o: |
1973 repositories or to bundle files (as created by 'hg bundle' or | 1982 repositories or to bundle files (as created by 'hg bundle' or |
1974 'hg incoming --bundle'). The static-http:// protocol, albeit slow, | 1983 'hg incoming --bundle'). The static-http:// protocol, albeit slow, |
1975 allows access to a Mercurial repository where you simply use a web | 1984 allows access to a Mercurial repository where you simply use a web |
1976 server to publish the .hg directory as static content. | 1985 server to publish the .hg directory as static content. |
1977 | 1986 |
1987 An optional identifier after # indicates a particular branch, tag, | |
1988 or changeset to pull. | |
1989 | |
1978 Some notes about using SSH with Mercurial: | 1990 Some notes about using SSH with Mercurial: |
1979 - SSH requires an accessible shell account on the destination machine | 1991 - SSH requires an accessible shell account on the destination machine |
1980 and a copy of hg in the remote path or specified with as remotecmd. | 1992 and a copy of hg in the remote path or specified with as remotecmd. |
1981 - path is relative to the remote user's home directory by default. | 1993 - path is relative to the remote user's home directory by default. |
1982 Use an extra slash at the start of a path to specify an absolute path: | 1994 Use an extra slash at the start of a path to specify an absolute path: |
1988 Host * | 2000 Host * |
1989 Compression yes | 2001 Compression yes |
1990 Alternatively specify "ssh -C" as your ssh command in your hgrc or | 2002 Alternatively specify "ssh -C" as your ssh command in your hgrc or |
1991 with the --ssh command line option. | 2003 with the --ssh command line option. |
1992 """ | 2004 """ |
1993 source = ui.expandpath(source) | 2005 source, revs = cmdutil.parseurl(ui.expandpath(source), opts['rev']) |
1994 setremoteconfig(ui, opts) | 2006 setremoteconfig(ui, opts) |
1995 | 2007 |
1996 other = hg.repository(ui, source) | 2008 other = hg.repository(ui, source) |
1997 ui.status(_('pulling from %s\n') % (source)) | 2009 ui.status(_('pulling from %s\n') % (source)) |
1998 revs = None | 2010 if revs: |
1999 if opts['rev']: | |
2000 if 'lookup' in other.capabilities: | 2011 if 'lookup' in other.capabilities: |
2001 revs = [other.lookup(rev) for rev in opts['rev']] | 2012 revs = [other.lookup(rev) for rev in revs] |
2002 else: | 2013 else: |
2003 error = _("Other repository doesn't support revision lookup, so a rev cannot be specified.") | 2014 error = _("Other repository doesn't support revision lookup, so a rev cannot be specified.") |
2004 raise util.Abort(error) | 2015 raise util.Abort(error) |
2016 | |
2005 modheads = repo.pull(other, heads=revs, force=opts['force']) | 2017 modheads = repo.pull(other, heads=revs, force=opts['force']) |
2006 return postincoming(ui, repo, modheads, opts['update']) | 2018 return postincoming(ui, repo, modheads, opts['update']) |
2007 | 2019 |
2008 def push(ui, repo, dest=None, **opts): | 2020 def push(ui, repo, dest=None, **opts): |
2009 """push changes to the specified destination | 2021 """push changes to the specified destination |
2024 local/filesystem/path (or file://local/filesystem/path) | 2036 local/filesystem/path (or file://local/filesystem/path) |
2025 ssh://[user@]host[:port]/[path] | 2037 ssh://[user@]host[:port]/[path] |
2026 http://[user@]host[:port]/[path] | 2038 http://[user@]host[:port]/[path] |
2027 https://[user@]host[:port]/[path] | 2039 https://[user@]host[:port]/[path] |
2028 | 2040 |
2041 An optional identifier after # indicates a particular branch, tag, | |
2042 or changeset to push. | |
2043 | |
2029 Look at the help text for the pull command for important details | 2044 Look at the help text for the pull command for important details |
2030 about ssh:// URLs. | 2045 about ssh:// URLs. |
2031 | 2046 |
2032 Pushing to http:// and https:// URLs is only possible, if this | 2047 Pushing to http:// and https:// URLs is only possible, if this |
2033 feature is explicitly enabled on the remote Mercurial server. | 2048 feature is explicitly enabled on the remote Mercurial server. |
2034 """ | 2049 """ |
2035 dest = ui.expandpath(dest or 'default-push', dest or 'default') | 2050 dest, revs = cmdutil.parseurl( |
2051 ui.expandpath(dest or 'default-push', dest or 'default'), opts['rev']) | |
2036 setremoteconfig(ui, opts) | 2052 setremoteconfig(ui, opts) |
2037 | 2053 |
2038 other = hg.repository(ui, dest) | 2054 other = hg.repository(ui, dest) |
2039 ui.status('pushing to %s\n' % (dest)) | 2055 ui.status('pushing to %s\n' % (dest)) |
2040 revs = None | 2056 if revs: |
2041 if opts['rev']: | 2057 revs = [repo.lookup(rev) for rev in revs] |
2042 revs = [repo.lookup(rev) for rev in opts['rev']] | |
2043 r = repo.push(other, opts['force'], revs=revs) | 2058 r = repo.push(other, opts['force'], revs=revs) |
2044 return r == 0 | 2059 return r == 0 |
2045 | 2060 |
2046 def rawcommit(ui, repo, *pats, **opts): | 2061 def rawcommit(ui, repo, *pats, **opts): |
2047 """raw commit interface (DEPRECATED) | 2062 """raw commit interface (DEPRECATED) |