Add support for url#id syntax
This allows you to do:
hg clone http://server/repo#stable
which is equivalent to:
hg clone -r stable http://server/repo
Future incoming, outgoing, and push commands will default to using
this id because it's recorded in the default path.
Other commands that accept URLs (push, pull, bundle, incoming, and
outgoing) also accept this syntax.
--- a/mercurial/cmdutil.py Fri Jun 01 18:52:18 2007 -0500
+++ b/mercurial/cmdutil.py Fri Jun 01 18:40:14 2007 -0500
@@ -11,6 +11,15 @@
revrangesep = ':'
+def parseurl(url, revs):
+ '''parse url#branch, returning url, branch + revs'''
+
+ if '#' not in url:
+ return url, (revs or None)
+
+ url, rev = url.split('#', 1)
+ return url, revs + [rev]
+
def revpair(repo, revs):
'''return pair of nodes, given list of revisions. second item can
be None, meaning use working dir.'''
--- a/mercurial/commands.py Fri Jun 01 18:52:18 2007 -0500
+++ b/mercurial/commands.py Fri Jun 01 18:40:14 2007 -0500
@@ -336,7 +336,8 @@
visit.append(p)
else:
setremoteconfig(ui, opts)
- dest = ui.expandpath(dest or 'default-push', dest or 'default')
+ dest, revs = cmdutil.parseurl(
+ ui.expandpath(dest or 'default-push', dest or 'default'), revs)
other = hg.repository(ui, dest)
o = repo.findoutgoing(other, force=opts['force'])
@@ -407,7 +408,7 @@
about ssh:// URLs.
"""
setremoteconfig(ui, opts)
- hg.clone(ui, ui.expandpath(source), dest,
+ hg.clone(ui, source, dest,
pull=opts['pull'],
stream=opts['uncompressed'],
rev=opts['rev'],
@@ -1588,15 +1589,14 @@
See pull for valid source format details.
"""
- source = ui.expandpath(source)
+ source, revs = cmdutil.parseurl(ui.expandpath(source), opts['rev'])
setremoteconfig(ui, opts)
other = hg.repository(ui, source)
ui.status(_('comparing with %s\n') % source)
- revs = None
- if opts['rev']:
+ if revs:
if 'lookup' in other.capabilities:
- revs = [other.lookup(rev) for rev in opts['rev']]
+ revs = [other.lookup(rev) for rev in revs]
else:
error = _("Other repository doesn't support revision lookup, so a rev cannot be specified.")
raise util.Abort(error)
@@ -1891,11 +1891,11 @@
See pull for valid destination format details.
"""
- dest = ui.expandpath(dest or 'default-push', dest or 'default')
+ dest, revs = cmdutil.parseurl(
+ ui.expandpath(dest or 'default-push', dest or 'default'), opts['rev'])
setremoteconfig(ui, opts)
- revs = None
- if opts['rev']:
- revs = [repo.lookup(rev) for rev in opts['rev']]
+ if revs:
+ revs = [repo.lookup(rev) for rev in revs]
other = hg.repository(ui, dest)
ui.status(_('comparing with %s\n') % dest)
@@ -1989,6 +1989,9 @@
allows access to a Mercurial repository where you simply use a web
server to publish the .hg directory as static content.
+ An optional identifier after # indicates a particular branch, tag,
+ or changeset to pull.
+
Some notes about using SSH with Mercurial:
- SSH requires an accessible shell account on the destination machine
and a copy of hg in the remote path or specified with as remotecmd.
@@ -2004,18 +2007,18 @@
Alternatively specify "ssh -C" as your ssh command in your hgrc or
with the --ssh command line option.
"""
- source = ui.expandpath(source)
+ source, revs = cmdutil.parseurl(ui.expandpath(source), opts['rev'])
setremoteconfig(ui, opts)
other = hg.repository(ui, source)
ui.status(_('pulling from %s\n') % (source))
- revs = None
- if opts['rev']:
+ if revs:
if 'lookup' in other.capabilities:
- revs = [other.lookup(rev) for rev in opts['rev']]
+ revs = [other.lookup(rev) for rev in revs]
else:
error = _("Other repository doesn't support revision lookup, so a rev cannot be specified.")
raise util.Abort(error)
+
modheads = repo.pull(other, heads=revs, force=opts['force'])
return postincoming(ui, repo, modheads, opts['update'])
@@ -2040,20 +2043,23 @@
http://[user@]host[:port]/[path]
https://[user@]host[:port]/[path]
+ An optional identifier after # indicates a particular branch, tag,
+ or changeset to push.
+
Look at the help text for the pull command for important details
about ssh:// URLs.
Pushing to http:// and https:// URLs is only possible, if this
feature is explicitly enabled on the remote Mercurial server.
"""
- dest = ui.expandpath(dest or 'default-push', dest or 'default')
+ dest, revs = cmdutil.parseurl(
+ ui.expandpath(dest or 'default-push', dest or 'default'), opts['rev'])
setremoteconfig(ui, opts)
other = hg.repository(ui, dest)
ui.status('pushing to %s\n' % (dest))
- revs = None
- if opts['rev']:
- revs = [repo.lookup(rev) for rev in opts['rev']]
+ if revs:
+ revs = [repo.lookup(rev) for rev in revs]
r = repo.push(other, opts['force'], revs=revs)
return r == 0
--- a/mercurial/hg.py Fri Jun 01 18:52:18 2007 -0500
+++ b/mercurial/hg.py Fri Jun 01 18:40:14 2007 -0500
@@ -10,7 +10,7 @@
from repo import *
from i18n import _
import localrepo, bundlerepo, httprepo, sshrepo, statichttprepo
-import errno, lock, os, shutil, util
+import errno, lock, os, shutil, util, cmdutil
import merge as _merge
import verify as _verify
@@ -97,6 +97,10 @@
update: update working directory after clone completes, if
destination is local repository
"""
+
+ origsource = source
+ source, rev = cmdutil.parseurl(ui.expandpath(source), rev)
+
if isinstance(source, str):
src_repo = repository(ui, source)
else:
@@ -134,10 +138,10 @@
if islocal(dest):
dir_cleanup = DirCleanup(dest)
- abspath = source
+ abspath = origsource
copy = False
if src_repo.local() and islocal(dest):
- abspath = os.path.abspath(source)
+ abspath = os.path.abspath(origsource)
copy = not pull and not rev
src_lock, dest_lock = None, None