596
596
raise InvalidRevisionNumber(revno)
599
def clone(self, *args, **kwargs):
599
def clone(self, to_bzrdir, revision_id=None):
600
600
"""Clone this branch into to_bzrdir preserving all semantic values.
602
602
revision_id: if not None, the revision history in the new branch will
603
603
be truncated to end with revision_id.
605
# for API compatibility, until 0.8 releases we provide the old api:
606
# def clone(self, to_location, revision=None, basis_branch=None, to_branch_format=None):
607
# after 0.8 releases, the *args and **kwargs should be changed:
608
# def clone(self, to_bzrdir, revision_id=None):
609
if (kwargs.get('to_location', None) or
610
kwargs.get('revision', None) or
611
kwargs.get('basis_branch', None) or
612
(len(args) and isinstance(args[0], basestring))):
613
# backwards compatibility api:
614
warn("Branch.clone() has been deprecated for BzrDir.clone() from"
615
" bzrlib 0.8.", DeprecationWarning, stacklevel=3)
618
basis_branch = args[2]
620
basis_branch = kwargs.get('basis_branch', None)
622
basis = basis_branch.bzrdir
627
revision_id = args[1]
629
revision_id = kwargs.get('revision', None)
634
# no default to raise if not provided.
635
url = kwargs.get('to_location')
636
return self.bzrdir.clone(url,
637
revision_id=revision_id,
638
basis=basis).open_branch()
640
# generate args by hand
642
revision_id = args[1]
644
revision_id = kwargs.get('revision_id', None)
648
# no default to raise if not provided.
649
to_bzrdir = kwargs.get('to_bzrdir')
650
605
result = self._format.initialize(to_bzrdir)
651
606
self.copy_content_into(result, revision_id=revision_id)
1236
1191
it's writable, and can be accessed via the normal filesystem API.
1239
def __init__(self, transport=DEPRECATED_PARAMETER, init=DEPRECATED_PARAMETER,
1240
relax_version_check=DEPRECATED_PARAMETER, _format=None,
1194
def __init__(self, _format=None,
1241
1195
_control_files=None, a_bzrdir=None, _repository=None):
1242
"""Create new branch object at a particular location.
1244
transport -- A Transport object, defining how to access files.
1246
init -- If True, create new control files in a previously
1247
unversioned directory. If False, the branch must already
1250
relax_version_check -- If true, the usual check for the branch
1251
version is not applied. This is intended only for
1252
upgrade/recovery type use; it's not guaranteed that
1253
all operations will work on old format branches.
1196
"""Create new branch object at a particular location."""
1255
1197
Branch.__init__(self)
1256
1198
if a_bzrdir is None:
1257
self.bzrdir = bzrdir.BzrDir.open(transport.base)
1199
raise ValueError('a_bzrdir must be supplied')
1259
1201
self.bzrdir = a_bzrdir
1260
1202
# self._transport used to point to the directory containing the
1266
1208
raise ValueError('BzrBranch _control_files is None')
1267
1209
self.control_files = _control_files
1268
1210
self._transport = _control_files._transport
1269
if deprecated_passed(init):
1270
warn("BzrBranch.__init__(..., init=XXX): The init parameter is "
1271
"deprecated as of bzr 0.8. Please use Branch.create().",
1275
# this is slower than before deprecation, oh well never mind.
1276
# -> its deprecated.
1277
self._initialize(transport.base)
1278
self._check_format(_format)
1279
if deprecated_passed(relax_version_check):
1280
warn("BzrBranch.__init__(..., relax_version_check=XXX_: The "
1281
"relax_version_check parameter is deprecated as of bzr 0.8. "
1282
"Please use BzrDir.open_downlevel, or a BzrBranchFormat's "
1286
if (not relax_version_check
1287
and not self._format.is_supported()):
1288
raise errors.UnsupportedFormatError(format=fmt)
1289
if deprecated_passed(transport):
1290
warn("BzrBranch.__init__(transport=XXX...): The transport "
1291
"parameter is deprecated as of bzr 0.8. "
1292
"Please use Branch.open, or bzrdir.open_branch().",
1295
1211
self.repository = _repository
1297
1213
def __str__(self):
1309
1225
"""See Branch.abspath."""
1310
1226
return self.control_files._transport.abspath(name)
1312
def _check_format(self, format):
1313
"""Identify the branch format if needed.
1315
The format is stored as a reference to the format object in
1316
self._format for code that needs to check it later.
1318
The format parameter is either None or the branch format class
1319
used to open this branch.
1321
FIXME: DELETE THIS METHOD when pre 0.8 support is removed.
1324
format = BranchFormat.find_format(self.bzrdir)
1325
self._format = format
1326
mutter("got branch format %s", self._format)
1328
1229
@deprecated_method(zero_sixteen)
1329
1230
@needs_read_lock