543
543
raise InvalidRevisionNumber(revno)
546
def clone(self, *args, **kwargs):
546
def clone(self, to_bzrdir, revision_id=None):
547
547
"""Clone this branch into to_bzrdir preserving all semantic values.
549
549
revision_id: if not None, the revision history in the new branch will
550
550
be truncated to end with revision_id.
552
# for API compatibility, until 0.8 releases we provide the old api:
553
# def clone(self, to_location, revision=None, basis_branch=None, to_branch_format=None):
554
# after 0.8 releases, the *args and **kwargs should be changed:
555
# def clone(self, to_bzrdir, revision_id=None):
556
if (kwargs.get('to_location', None) or
557
kwargs.get('revision', None) or
558
kwargs.get('basis_branch', None) or
559
(len(args) and isinstance(args[0], basestring))):
560
# backwards compatibility api:
561
warn("Branch.clone() has been deprecated for BzrDir.clone() from"
562
" bzrlib 0.8.", DeprecationWarning, stacklevel=3)
565
basis_branch = args[2]
567
basis_branch = kwargs.get('basis_branch', None)
569
basis = basis_branch.bzrdir
574
revision_id = args[1]
576
revision_id = kwargs.get('revision', None)
581
# no default to raise if not provided.
582
url = kwargs.get('to_location')
583
return self.bzrdir.clone(url,
584
revision_id=revision_id,
585
basis=basis).open_branch()
587
# generate args by hand
589
revision_id = args[1]
591
revision_id = kwargs.get('revision_id', None)
595
# no default to raise if not provided.
596
to_bzrdir = kwargs.get('to_bzrdir')
597
552
result = self._format.initialize(to_bzrdir)
598
553
self.copy_content_into(result, revision_id=revision_id)
1183
1138
it's writable, and can be accessed via the normal filesystem API.
1186
def __init__(self, transport=DEPRECATED_PARAMETER, init=DEPRECATED_PARAMETER,
1187
relax_version_check=DEPRECATED_PARAMETER, _format=None,
1141
def __init__(self, _format=None,
1188
1142
_control_files=None, a_bzrdir=None, _repository=None):
1189
"""Create new branch object at a particular location.
1191
transport -- A Transport object, defining how to access files.
1193
init -- If True, create new control files in a previously
1194
unversioned directory. If False, the branch must already
1197
relax_version_check -- If true, the usual check for the branch
1198
version is not applied. This is intended only for
1199
upgrade/recovery type use; it's not guaranteed that
1200
all operations will work on old format branches.
1143
"""Create new branch object at a particular location."""
1202
1144
Branch.__init__(self)
1203
1145
if a_bzrdir is None:
1204
self.bzrdir = bzrdir.BzrDir.open(transport.base)
1146
raise ValueError('a_bzrdir must be supplied')
1206
1148
self.bzrdir = a_bzrdir
1207
1149
# self._transport used to point to the directory containing the
1213
1155
raise ValueError('BzrBranch _control_files is None')
1214
1156
self.control_files = _control_files
1215
1157
self._transport = _control_files._transport
1216
if deprecated_passed(init):
1217
warn("BzrBranch.__init__(..., init=XXX): The init parameter is "
1218
"deprecated as of bzr 0.8. Please use Branch.create().",
1222
# this is slower than before deprecation, oh well never mind.
1223
# -> its deprecated.
1224
self._initialize(transport.base)
1225
self._check_format(_format)
1226
if deprecated_passed(relax_version_check):
1227
warn("BzrBranch.__init__(..., relax_version_check=XXX_: The "
1228
"relax_version_check parameter is deprecated as of bzr 0.8. "
1229
"Please use BzrDir.open_downlevel, or a BzrBranchFormat's "
1233
if (not relax_version_check
1234
and not self._format.is_supported()):
1235
raise errors.UnsupportedFormatError(format=fmt)
1236
if deprecated_passed(transport):
1237
warn("BzrBranch.__init__(transport=XXX...): The transport "
1238
"parameter is deprecated as of bzr 0.8. "
1239
"Please use Branch.open, or bzrdir.open_branch().",
1242
1158
self.repository = _repository
1244
1160
def __str__(self):
1279
1195
"""See Branch.abspath."""
1280
1196
return self.control_files._transport.abspath(name)
1282
def _check_format(self, format):
1283
"""Identify the branch format if needed.
1285
The format is stored as a reference to the format object in
1286
self._format for code that needs to check it later.
1288
The format parameter is either None or the branch format class
1289
used to open this branch.
1291
FIXME: DELETE THIS METHOD when pre 0.8 support is removed.
1294
format = BranchFormat.find_format(self.bzrdir)
1295
self._format = format
1296
mutter("got branch format %s", self._format)
1298
1198
@needs_read_lock
1299
1199
def get_root_id(self):
1300
1200
"""See Branch.get_root_id."""