~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Martin Pool
  • Date: 2005-09-29 12:20:42 UTC
  • mto: (1185.12.2) (1393.1.12)
  • mto: This revision was merged to the branch mainline in revision 1396.
  • Revision ID: mbp@sourcefrog.net-20050929122042-8b647796489a06eb
- move copy_branch into bzrlib.clone

  it's not tightly coupled to the Branch class in bzrlib.branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1346
1346
    return gen_file_id('TREE_ROOT')
1347
1347
 
1348
1348
 
1349
 
def copy_branch(branch_from, to_location, revision=None, basis_branch=None):
1350
 
    """Copy branch_from into the existing directory to_location.
1351
 
 
1352
 
    revision
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
1355
 
        revid or None.
1356
 
 
1357
 
    to_location
1358
 
        The name of a local directory that exists but is empty.
1359
 
 
1360
 
    revno
1361
 
        The revision to copy up to
1362
 
 
1363
 
    basis_branch
1364
 
        A local branch to copy revisions from, related to branch_from
1365
 
    """
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
1370
 
 
1371
 
    assert isinstance(branch_from, Branch)
1372
 
    assert isinstance(to_location, basestring)
1373
 
    
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)
1385
 
    mutter("copied")
1386
 
    return br_to