591
591
raise InvalidRevisionNumber(revno)
594
def clone(self, *args, **kwargs):
594
def clone(self, to_bzrdir, revision_id=None):
595
595
"""Clone this branch into to_bzrdir preserving all semantic values.
597
597
revision_id: if not None, the revision history in the new branch will
598
598
be truncated to end with revision_id.
600
# for API compatibility, until 0.8 releases we provide the old api:
601
# def clone(self, to_location, revision=None, basis_branch=None, to_branch_format=None):
602
# after 0.8 releases, the *args and **kwargs should be changed:
603
# def clone(self, to_bzrdir, revision_id=None):
604
if (kwargs.get('to_location', None) or
605
kwargs.get('revision', None) or
606
kwargs.get('basis_branch', None) or
607
(len(args) and isinstance(args[0], basestring))):
608
# backwards compatibility api:
609
warn("Branch.clone() has been deprecated for BzrDir.clone() from"
610
" bzrlib 0.8.", DeprecationWarning, stacklevel=3)
613
basis_branch = args[2]
615
basis_branch = kwargs.get('basis_branch', None)
617
basis = basis_branch.bzrdir
622
revision_id = args[1]
624
revision_id = kwargs.get('revision', None)
629
# no default to raise if not provided.
630
url = kwargs.get('to_location')
631
return self.bzrdir.clone(url,
632
revision_id=revision_id,
633
basis=basis).open_branch()
635
# generate args by hand
637
revision_id = args[1]
639
revision_id = kwargs.get('revision_id', None)
643
# no default to raise if not provided.
644
to_bzrdir = kwargs.get('to_bzrdir')
645
600
result = self._format.initialize(to_bzrdir)
646
601
self.copy_content_into(result, revision_id=revision_id)
1231
1186
it's writable, and can be accessed via the normal filesystem API.
1234
def __init__(self, transport=DEPRECATED_PARAMETER, init=DEPRECATED_PARAMETER,
1235
relax_version_check=DEPRECATED_PARAMETER, _format=None,
1189
def __init__(self, _format=None,
1236
1190
_control_files=None, a_bzrdir=None, _repository=None):
1237
"""Create new branch object at a particular location.
1239
transport -- A Transport object, defining how to access files.
1241
init -- If True, create new control files in a previously
1242
unversioned directory. If False, the branch must already
1245
relax_version_check -- If true, the usual check for the branch
1246
version is not applied. This is intended only for
1247
upgrade/recovery type use; it's not guaranteed that
1248
all operations will work on old format branches.
1191
"""Create new branch object at a particular location."""
1250
1192
Branch.__init__(self)
1251
1193
if a_bzrdir is None:
1252
self.bzrdir = bzrdir.BzrDir.open(transport.base)
1194
raise ValueError('a_bzrdir must be supplied')
1254
1196
self.bzrdir = a_bzrdir
1255
1197
# self._transport used to point to the directory containing the
1261
1203
raise ValueError('BzrBranch _control_files is None')
1262
1204
self.control_files = _control_files
1263
1205
self._transport = _control_files._transport
1264
if deprecated_passed(init):
1265
warn("BzrBranch.__init__(..., init=XXX): The init parameter is "
1266
"deprecated as of bzr 0.8. Please use Branch.create().",
1270
# this is slower than before deprecation, oh well never mind.
1271
# -> its deprecated.
1272
self._initialize(transport.base)
1273
self._check_format(_format)
1274
if deprecated_passed(relax_version_check):
1275
warn("BzrBranch.__init__(..., relax_version_check=XXX_: The "
1276
"relax_version_check parameter is deprecated as of bzr 0.8. "
1277
"Please use BzrDir.open_downlevel, or a BzrBranchFormat's "
1281
if (not relax_version_check
1282
and not self._format.is_supported()):
1283
raise errors.UnsupportedFormatError(format=fmt)
1284
if deprecated_passed(transport):
1285
warn("BzrBranch.__init__(transport=XXX...): The transport "
1286
"parameter is deprecated as of bzr 0.8. "
1287
"Please use Branch.open, or bzrdir.open_branch().",
1290
1206
self.repository = _repository
1292
1208
def __str__(self):
1304
1220
"""See Branch.abspath."""
1305
1221
return self.control_files._transport.abspath(name)
1307
def _check_format(self, format):
1308
"""Identify the branch format if needed.
1310
The format is stored as a reference to the format object in
1311
self._format for code that needs to check it later.
1313
The format parameter is either None or the branch format class
1314
used to open this branch.
1316
FIXME: DELETE THIS METHOD when pre 0.8 support is removed.
1319
format = BranchFormat.find_format(self.bzrdir)
1320
self._format = format
1321
mutter("got branch format %s", self._format)
1323
1223
@needs_read_lock
1324
1224
def get_root_id(self):
1325
1225
"""See Branch.get_root_id."""