diff mercurial/commands.py @ 4478:b2b55acbacdd

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.
author Matt Mackall <mpm@selenic.com>
date Fri, 01 Jun 2007 18:40:14 -0500
parents 08ae451148b2
children 649dd2492ae5
line wrap: on
line diff
--- 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