1346
1346
return gen_file_id('TREE_ROOT')
1349
def copy_branch(branch_from, to_location, revision=None, basis_branch=None):
1350
"""Copy branch_from into the existing directory to_location.
1353
If not None, only revisions up to this point will be copied.
1354
The head of the new branch will be that revision. Must be a
1358
The name of a local directory that exists but is empty.
1361
The revision to copy up to
1364
A local branch to copy revisions from, related to branch_from
1366
# TODO: This could be done *much* more efficiently by just copying
1367
# all the whole weaves and revisions, rather than getting one
1368
# revision at a time.
1369
from bzrlib.merge import merge
1371
assert isinstance(branch_from, Branch)
1372
assert isinstance(to_location, basestring)
1374
br_to = Branch.initialize(to_location)
1375
mutter("copy branch from %s to %s", branch_from, br_to)
1376
if basis_branch is not None:
1377
basis_branch.push_stores(br_to)
1378
br_to.set_root_id(branch_from.get_root_id())
1379
if revision is None:
1380
revision = branch_from.last_revision()
1381
br_to.update_revisions(branch_from, stop_revision=revision)
1382
merge((to_location, -1), (to_location, 0), this_dir=to_location,
1383
check_clean=False, ignore_zero=True)
1384
br_to.set_parent(branch_from.base)