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