diff mercurial/hg.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 6cbfa740c129
children 63b9d2deed48
line wrap: on
line diff
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -10,7 +10,7 @@ from node import *
 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 @@ def clone(ui, source, dest=None, pull=Fa
     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 @@ def clone(ui, source, dest=None, pull=Fa
     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