changeset 907:652507dc9fce

Modify init command to take an optional directory to set up. If the directory does not exist, it is created. If no directory is given, the current directory is used.
author Bryan O'Sullivan <bos@serpentine.com>
date Sun, 14 Aug 2005 21:33:09 -0800
parents c711930cf15d
children fcd34a9577e8
files doc/hg.1.txt mercurial/commands.py
diffstat 2 files changed, 11 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/doc/hg.1.txt	Mon Aug 15 06:18:49 2005 +0100
+++ b/doc/hg.1.txt	Sun Aug 14 21:33:09 2005 -0800
@@ -196,8 +196,11 @@
 
     aliases: patch
 
-init::
-    Initialize a new repository in the current directory.
+init [dest]::
+    Initialize a new repository in the given directory.  If the given
+    directory does not exist, it is created.
+
+    If no directory is given, the current directory is used.
 
 locate [options] [files]::
     Print all files under Mercurial control whose names match the
--- a/mercurial/commands.py	Mon Aug 15 06:18:49 2005 +0100
+++ b/mercurial/commands.py	Sun Aug 14 21:33:09 2005 -0800
@@ -772,12 +772,11 @@
             addremove(ui, repo, *files)
         repo.commit(files, message, user)
 
-def init(ui, source=None):
-    """create a new repository in the current directory"""
-
-    if source:
-        raise util.Abort("no longer supported: use \"hg clone\" instead")
-    hg.repository(ui, ".", create=1)
+def init(ui, dest="."):
+    """create a new repository in the given directory"""
+    if not os.path.exists(dest):
+        os.mkdir(dest)
+    hg.repository(ui, dest, create=1)
 
 def locate(ui, repo, *pats, **opts):
     """locate files matching specific patterns"""
@@ -1279,7 +1278,7 @@
          [('p', 'strip', 1, 'path strip'),
           ('b', 'base', "", 'base path')],
          "hg import [-p NUM] [-b BASE] PATCH..."),
-    "^init": (init, [], 'hg init'),
+    "^init": (init, [], 'hg init [DEST]'),
     "locate":
         (locate,
          [('r', 'rev', '', 'revision'),