~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Aaron Bentley
  • Date: 2005-09-25 05:01:17 UTC
  • mto: (1185.14.1) (1393.1.21)
  • mto: This revision was merged to the branch mainline in revision 1391.
  • Revision ID: aaron.bentley@utoronto.ca-20050925050117-dc4b46505adfc0d7
Added --basis option to bzr branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
     splitpath, \
25
25
     sha_file, appendpath, file_kind
26
26
 
 
27
from bzrlib.store import copy_all
27
28
from bzrlib.errors import BzrError, InvalidRevisionNumber, InvalidRevisionId, \
28
 
     DivergedBranches, NotBranchError
 
29
     DivergedBranches, NotBranchError, UnlistableStore, UnlistableBranch
29
30
from bzrlib.textui import show_status
30
31
from bzrlib.revision import Revision
31
32
from bzrlib.delta import compare_trees
1331
1332
    return gen_file_id('TREE_ROOT')
1332
1333
 
1333
1334
 
1334
 
def copy_branch(branch_from, to_location, revno=None):
 
1335
def copy_branch(branch_from, to_location, revno=None, basis_branch=None):
1335
1336
    """Copy branch_from into the existing directory to_location.
1336
1337
 
1337
1338
    revision
1340
1341
 
1341
1342
    to_location
1342
1343
        The name of a local directory that exists but is empty.
 
1344
 
 
1345
    revno
 
1346
        The revision to copy up to
 
1347
 
 
1348
    basis_branch
 
1349
        A local branch to copy revisions from, related to branch_from
1343
1350
    """
1344
1351
    from bzrlib.merge import merge
1345
1352
 
1346
1353
    assert isinstance(branch_from, Branch)
 
1354
    print repr(to_location)
1347
1355
    assert isinstance(to_location, basestring)
1348
1356
    
1349
1357
    br_to = Branch.initialize(to_location)
 
1358
    if basis_branch is not None:
 
1359
        copy_stores(basis_branch, br_to)
1350
1360
    br_to.set_root_id(branch_from.get_root_id())
1351
1361
    if revno is None:
1352
1362
        revno = branch_from.revno()
1355
1365
          check_clean=False, ignore_zero=True)
1356
1366
    br_to.set_parent(branch_from.base)
1357
1367
    return br_to
 
1368
 
 
1369
def copy_stores(branch_from, branch_to):
 
1370
    """Copies all entries from branch stores to another branch's stores.
 
1371
    """
 
1372
    store_pairs = ((branch_from.text_store,      branch_to.text_store),
 
1373
                   (branch_from.inventory_store, branch_to.inventory_store),
 
1374
                   (branch_from.revision_store,  branch_to.revision_store))
 
1375
    try:
 
1376
        for from_store, to_store in store_pairs: 
 
1377
            copy_all(from_store, to_store)
 
1378
    except UnlistableStore:
 
1379
        raise UnlistableBranch(from_store)