##// END OF EJS Templates
Add support for url#id syntax...
Matt Mackall -
r4478:b2b55acb default
parent child Browse files
Show More
@@ -11,6 +11,15 b' import os, sys, mdiff, bdiff, util, temp'
11 11
12 12 revrangesep = ':'
13 13
14 def parseurl(url, revs):
15 '''parse url#branch, returning url, branch + revs'''
16
17 if '#' not in url:
18 return url, (revs or None)
19
20 url, rev = url.split('#', 1)
21 return url, revs + [rev]
22
14 23 def revpair(repo, revs):
15 24 '''return pair of nodes, given list of revisions. second item can
16 25 be None, meaning use working dir.'''
@@ -336,7 +336,8 b' def bundle(ui, repo, fname, dest=None, *'
336 336 visit.append(p)
337 337 else:
338 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 341 other = hg.repository(ui, dest)
341 342 o = repo.findoutgoing(other, force=opts['force'])
342 343
@@ -407,7 +408,7 b' def clone(ui, source, dest=None, **opts)'
407 408 about ssh:// URLs.
408 409 """
409 410 setremoteconfig(ui, opts)
410 hg.clone(ui, ui.expandpath(source), dest,
411 hg.clone(ui, source, dest,
411 412 pull=opts['pull'],
412 413 stream=opts['uncompressed'],
413 414 rev=opts['rev'],
@@ -1588,15 +1589,14 b' def incoming(ui, repo, source="default",'
1588 1589
1589 1590 See pull for valid source format details.
1590 1591 """
1591 source = ui.expandpath(source)
1592 source, revs = cmdutil.parseurl(ui.expandpath(source), opts['rev'])
1592 1593 setremoteconfig(ui, opts)
1593 1594
1594 1595 other = hg.repository(ui, source)
1595 1596 ui.status(_('comparing with %s\n') % source)
1596 revs = None
1597 if opts['rev']:
1597 if revs:
1598 1598 if 'lookup' in other.capabilities:
1599 revs = [other.lookup(rev) for rev in opts['rev']]
1599 revs = [other.lookup(rev) for rev in revs]
1600 1600 else:
1601 1601 error = _("Other repository doesn't support revision lookup, so a rev cannot be specified.")
1602 1602 raise util.Abort(error)
@@ -1891,11 +1891,11 b' def outgoing(ui, repo, dest=None, **opts'
1891 1891
1892 1892 See pull for valid destination format details.
1893 1893 """
1894 dest = ui.expandpath(dest or 'default-push', dest or 'default')
1894 dest, revs = cmdutil.parseurl(
1895 ui.expandpath(dest or 'default-push', dest or 'default'), opts['rev'])
1895 1896 setremoteconfig(ui, opts)
1896 revs = None
1897 if opts['rev']:
1898 revs = [repo.lookup(rev) for rev in opts['rev']]
1897 if revs:
1898 revs = [repo.lookup(rev) for rev in revs]
1899 1899
1900 1900 other = hg.repository(ui, dest)
1901 1901 ui.status(_('comparing with %s\n') % dest)
@@ -1989,6 +1989,9 b' def pull(ui, repo, source="default", **o'
1989 1989 allows access to a Mercurial repository where you simply use a web
1990 1990 server to publish the .hg directory as static content.
1991 1991
1992 An optional identifier after # indicates a particular branch, tag,
1993 or changeset to pull.
1994
1992 1995 Some notes about using SSH with Mercurial:
1993 1996 - SSH requires an accessible shell account on the destination machine
1994 1997 and a copy of hg in the remote path or specified with as remotecmd.
@@ -2004,18 +2007,18 b' def pull(ui, repo, source="default", **o'
2004 2007 Alternatively specify "ssh -C" as your ssh command in your hgrc or
2005 2008 with the --ssh command line option.
2006 2009 """
2007 source = ui.expandpath(source)
2010 source, revs = cmdutil.parseurl(ui.expandpath(source), opts['rev'])
2008 2011 setremoteconfig(ui, opts)
2009 2012
2010 2013 other = hg.repository(ui, source)
2011 2014 ui.status(_('pulling from %s\n') % (source))
2012 revs = None
2013 if opts['rev']:
2015 if revs:
2014 2016 if 'lookup' in other.capabilities:
2015 revs = [other.lookup(rev) for rev in opts['rev']]
2017 revs = [other.lookup(rev) for rev in revs]
2016 2018 else:
2017 2019 error = _("Other repository doesn't support revision lookup, so a rev cannot be specified.")
2018 2020 raise util.Abort(error)
2021
2019 2022 modheads = repo.pull(other, heads=revs, force=opts['force'])
2020 2023 return postincoming(ui, repo, modheads, opts['update'])
2021 2024
@@ -2040,20 +2043,23 b' def push(ui, repo, dest=None, **opts):'
2040 2043 http://[user@]host[:port]/[path]
2041 2044 https://[user@]host[:port]/[path]
2042 2045
2046 An optional identifier after # indicates a particular branch, tag,
2047 or changeset to push.
2048
2043 2049 Look at the help text for the pull command for important details
2044 2050 about ssh:// URLs.
2045 2051
2046 2052 Pushing to http:// and https:// URLs is only possible, if this
2047 2053 feature is explicitly enabled on the remote Mercurial server.
2048 2054 """
2049 dest = ui.expandpath(dest or 'default-push', dest or 'default')
2055 dest, revs = cmdutil.parseurl(
2056 ui.expandpath(dest or 'default-push', dest or 'default'), opts['rev'])
2050 2057 setremoteconfig(ui, opts)
2051 2058
2052 2059 other = hg.repository(ui, dest)
2053 2060 ui.status('pushing to %s\n' % (dest))
2054 revs = None
2055 if opts['rev']:
2056 revs = [repo.lookup(rev) for rev in opts['rev']]
2061 if revs:
2062 revs = [repo.lookup(rev) for rev in revs]
2057 2063 r = repo.push(other, opts['force'], revs=revs)
2058 2064 return r == 0
2059 2065
@@ -10,7 +10,7 b' from node import *'
10 10 from repo import *
11 11 from i18n import _
12 12 import localrepo, bundlerepo, httprepo, sshrepo, statichttprepo
13 import errno, lock, os, shutil, util
13 import errno, lock, os, shutil, util, cmdutil
14 14 import merge as _merge
15 15 import verify as _verify
16 16
@@ -97,6 +97,10 b' def clone(ui, source, dest=None, pull=Fa'
97 97 update: update working directory after clone completes, if
98 98 destination is local repository
99 99 """
100
101 origsource = source
102 source, rev = cmdutil.parseurl(ui.expandpath(source), rev)
103
100 104 if isinstance(source, str):
101 105 src_repo = repository(ui, source)
102 106 else:
@@ -134,10 +138,10 b' def clone(ui, source, dest=None, pull=Fa'
134 138 if islocal(dest):
135 139 dir_cleanup = DirCleanup(dest)
136 140
137 abspath = source
141 abspath = origsource
138 142 copy = False
139 143 if src_repo.local() and islocal(dest):
140 abspath = os.path.abspath(source)
144 abspath = os.path.abspath(origsource)
141 145 copy = not pull and not rev
142 146
143 147 src_lock, dest_lock = None, None
General Comments 0
You need to be logged in to leave comments. Login now