[patch] #38331 init-repo shouldn't insist on creating the directory
Martin Pool
mbp at sourcefrog.net
Thu Apr 13 04:47:33 BST 2006
This also adds some docs to init-repo --help
--
Martin
-------------- next part --------------
=== modified file 'a/bzrlib/builtins.py'
--- a/bzrlib/builtins.py
+++ b/bzrlib/builtins.py
@@ -897,7 +897,18 @@
class cmd_init_repository(Command):
- """Create a shared repository to keep branches in."""
+ """Create a shared repository to hold branches.
+
+ New branches created under the repository directory will store their revisions
+ in the repository, not in the branch directory, if the branch format supports
+ shared storage.
+
+ example:
+ bzr init-repo repo
+ bzr init --format=metadir repo/trunk
+ cd repo/trunk
+ (add files here)
+ """
takes_args = ["location"]
takes_options = [Option('format',
help='Use a specific format rather than the'
@@ -915,8 +926,10 @@
from bzrlib.transport import get_transport
if format is None:
format = BzrDirMetaFormat1()
- get_transport(location).mkdir('')
- newdir = format.initialize(location)
+ transport = get_transport(location)
+ if not transport.has('.'):
+ transport.mkdir('')
+ newdir = format.initialize_on_transport(transport)
repo = newdir.create_repository(shared=True)
repo.set_make_working_trees(trees)
=== modified file 'a/bzrlib/tests/blackbox/test_shared_repository.py'
--- a/bzrlib/tests/blackbox/test_shared_repository.py
+++ b/bzrlib/tests/blackbox/test_shared_repository.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2005 by Canonical Ltd
+# Copyright (C) 2005, 2006 by Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -20,6 +20,7 @@
from bzrlib.tests import TestCaseInTempDir
import bzrlib.bzrdir
+from bzrlib.bzrdir import BzrDir
import bzrlib.errors as errors
class TestSharedRepo(TestCaseInTempDir):
@@ -32,6 +33,15 @@
self.assertIs(dir.open_repository().is_shared(), True)
self.assertRaises(errors.NotBranchError, dir.open_branch)
self.assertRaises(errors.NoWorkingTree, dir.open_workingtree)
+
+ def test_init_repo_existing_dir(self):
+ """Make repo in existing directory.
+
+ (Malone #38331)
+ """
+ out, err = self.run_bzr("init-repository", ".")
+ dir = BzrDir.open('.')
+ self.assertTrue(dir.open_repository())
def test_init(self):
self.run_bzr("init-repo", "a")
More information about the bazaar
mailing list