1675
1675
def _initialize_helper(self, a_bzrdir, utf8_files, name=None,
1676
repository=None, lock_type='metadir',
1678
1677
"""Initialize a branch in a bzrdir, with specified files
1680
1679
:param a_bzrdir: The bzrdir to initialize the branch in
1681
1680
:param utf8_files: The files to create as a list of
1682
1681
(filename, content) tuples
1683
1682
:param name: Name of colocated branch to create, if any
1684
:param set_format: If True, set the format with
1685
self.get_format_string. (BzrBranch4 has its format set
1687
1683
:return: a branch in this format
1689
1685
mutter('creating branch %r in %s', self, a_bzrdir.user_url)
1690
1686
branch_transport = a_bzrdir.get_branch_transport(self, name=name)
1692
'metadir': ('lock', lockdir.LockDir),
1693
'branch4': ('branch-lock', lockable_files.TransportLock),
1695
lock_name, lock_class = lock_map[lock_type]
1696
1687
control_files = lockable_files.LockableFiles(branch_transport,
1697
lock_name, lock_class)
1688
'lock', lockdir.LockDir)
1698
1689
control_files.create_lock()
1690
control_files.lock_write()
1700
control_files.lock_write()
1701
except errors.LockContention:
1702
if lock_type != 'branch4':
1708
1692
utf8_files += [('format', self.get_format_string())]
1710
1693
for (filename, content) in utf8_files:
1711
1694
branch_transport.put_bytes(
1712
1695
filename, content,
1713
1696
mode=a_bzrdir._get_file_mode())
1716
control_files.unlock()
1698
control_files.unlock()
1717
1699
branch = self.open(a_bzrdir, name, _found=True,
1718
1700
found_repository=repository)
1719
1701
self._run_post_branch_init_hooks(a_bzrdir, name, branch)