Rev 2479: Fix bug #111702. in file:///v/home/vila/src/bugs/111702/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Wed May 2 21:18:40 BST 2007
At file:///v/home/vila/src/bugs/111702/
------------------------------------------------------------
revno: 2479
revision-id: v.ladeuil+lp at free.fr-20070502201837-od1q12zbvr90kyni
parent: v.ladeuil+lp at free.fr-20070502162141-zwqhrx0ydx7hzwv0
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 111702
timestamp: Wed 2007-05-02 22:18:37 +0200
message:
Fix bug #111702.
* bzrdir.py:
(BzrDir.create_branch_convenience): Add 'transport' as an
alternate way to specify the URL to create the branch at.
* builtins.py:
(cmd_init.run): We have a transport, use it.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS 2007-05-01 22:41:41 +0000
+++ b/NEWS 2007-05-02 20:18:37 +0000
@@ -18,6 +18,13 @@
that we can pass in the Transport that we already have.
(John Arbash Meinel, #75721)
+ * ``bzr init`` should only connect to the remote location one time.
+ We have been connecting several times because we forget to pass
+ around the Transport object. This modifies
+ ``BzrDir.create_branch_convenienve``, so that we can pass in the
+ Transport that we already have.
+ (John Arbash Meinel, Vincent Ladeuil, #111702)
+
bzr 0.16rc2 2007-04-30
BUGFIXES:
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2007-05-02 14:54:20 +0000
+++ b/bzrlib/builtins.py 2007-05-02 20:18:37 +0000
@@ -1277,20 +1277,15 @@
to_transport = transport.get_transport(location)
- # The path has to exist to initialize a
- # branch inside of it.
- # Just using os.mkdir, since I don't
- # believe that we want to create a bunch of
- # locations if the user supplies an extended path
# TODO: create-prefix
to_transport.ensure_base()
try:
- existing_bzrdir = bzrdir.BzrDir.open(location)
+ existing_bzrdir = bzrdir.BzrDir.open_from_transport(to_transport)
except errors.NotBranchError:
# really a NotBzrDir error...
- branch = bzrdir.BzrDir.create_branch_convenience(to_transport.base,
- format=format)
+ create_branch= bzrdir.BzrDir.create_branch_convenience
+ branch = create_branch(transport=to_transport, format=format)
else:
from bzrlib.transport.local import LocalTransport
if existing_bzrdir.has_branch():
=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py 2007-05-02 14:54:20 +0000
+++ b/bzrlib/bzrdir.py 2007-05-02 20:18:37 +0000
@@ -267,10 +267,12 @@
return self.find_repository()
except errors.NoRepositoryPresent:
return self.create_repository()
-
+
@staticmethod
- def create_branch_convenience(base, force_new_repo=False,
- force_new_tree=None, format=None):
+ def create_branch_convenience(base=None, transport=None,
+ force_new_repo=False,
+ force_new_tree=None, format=None,
+ ):
"""Create a new BzrDir, Branch and Repository at the url 'base'.
This is a convenience function - it will use an existing repository
@@ -289,17 +291,28 @@
data is created on disk and NotLocalUrl is raised.
:param base: The URL to create the branch at.
+ :param transport: An alternate way to specify the URL.
+ 'format' must also be specified.
:param force_new_repo: If True a new repository is always created.
:param force_new_tree: If True or False force creation of a tree or
prevent such creation respectively.
:param format: Override for the for the bzrdir format to create
"""
+ if base is None and transport is None:
+ raise AssertionError('You should specify one of '
+ 'base or transport parameter')
if force_new_tree:
+ if base:
+ transport = get_transport(base)
# check for non local urls
- t = get_transport(safe_unicode(base))
- if not isinstance(t, LocalTransport):
- raise errors.NotLocalUrl(base)
- bzrdir = BzrDir.create(base, format)
+ if not isinstance(transport, LocalTransport):
+ raise errors.NotLocalUrl(transport.base)
+ if format is None:
+ format = BzrDirFormat.get_default_format()
+ if base:
+ bzrdir = BzrDir.create(base, format)
+ else:
+ bzrdir = format.initialize_on_transport(transport)
repo = bzrdir._find_or_create_repository(force_new_repo)
result = bzrdir.create_branch()
if force_new_tree or (repo.make_working_trees() and
More information about the bazaar-commits
mailing list