# HG changeset patch # User Bryan O'Sullivan # Date 1124083989 28800 # Node ID 652507dc9fce7883917c95f975754cc744b5dea4 # Parent c711930cf15da1d1ad2be39ef2476e2652d48b45 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. diff --git a/doc/hg.1.txt b/doc/hg.1.txt --- a/doc/hg.1.txt +++ b/doc/hg.1.txt @@ -196,8 +196,11 @@ import [-p -b -q] :: 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 diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -772,12 +772,11 @@ def import_(ui, repo, patch1, *patches, 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 @@ table = { [('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'),