/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Martin Pool
  • Date: 2006-08-15 13:19:12 UTC
  • mfrom: (1923 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1925.
  • Revision ID: mbp@sourcefrog.net-20060815131912-7bbc6d387bb32d16
[merge] bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
from warnings import warn
22
22
 
23
23
import bzrlib
24
 
from bzrlib import bzrdir, errors, lockdir, osutils, revision, \
25
 
        tree, \
26
 
        ui, \
 
24
from bzrlib import (
 
25
        bzrdir, 
 
26
        errors, 
 
27
        lockdir, 
 
28
        osutils, 
 
29
        revision,
 
30
        transport,
 
31
        tree,
 
32
        ui,
27
33
        urlutils
 
34
        )
28
35
from bzrlib.config import TreeConfig
29
36
from bzrlib.decorators import needs_read_lock, needs_write_lock
30
37
import bzrlib.errors as errors
572
579
            mainline_parent_id = revision_id
573
580
        return BranchCheckResult(self)
574
581
 
 
582
    def create_checkout(self, to_location, revision_id=None, 
 
583
                        lightweight=False):
 
584
        """Create a checkout of a branch.
 
585
        
 
586
        :param to_location: The url to produce the checkout at
 
587
        :param revision_id: The revision to check out
 
588
        :param lightweight: If True, produce a lightweight checkout, otherwise,
 
589
        produce a bound branch (heavyweight checkout)
 
590
        :return: The tree of the created checkout
 
591
        """
 
592
        if lightweight:
 
593
            t = transport.get_transport(to_location)
 
594
            try:
 
595
                t.mkdir('.')
 
596
            except errors.FileExists:
 
597
                pass
 
598
            checkout = bzrdir.BzrDirMetaFormat1().initialize_on_transport(t)
 
599
            BranchReferenceFormat().initialize(checkout, self)
 
600
        else:
 
601
            checkout_branch = bzrdir.BzrDir.create_branch_convenience(
 
602
                to_location, force_new_tree=False)
 
603
            checkout = checkout_branch.bzrdir
 
604
            checkout_branch.bind(self)
 
605
            if revision_id is not None:
 
606
                rh = checkout_branch.revision_history()
 
607
                new_rh = rh[:rh.index(revision_id) + 1]
 
608
                checkout_branch.set_revision_history(new_rh)
 
609
        return checkout.create_workingtree(revision_id)
 
610
 
575
611
 
576
612
class BranchFormat(object):
577
613
    """An encapsulation of the initialization and open routines for a format.