~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: John Arbash Meinel
  • Date: 2006-08-15 16:59:36 UTC
  • mfrom: (1927 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1929.
  • Revision ID: john@arbash-meinel.com-20060815165936-fdb89c9f58831367
[merge] bzr.dev 1927

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, \
27
 
        urlutils
 
24
from bzrlib import (
 
25
        bzrdir,
 
26
        cache_utf8,
 
27
        errors,
 
28
        lockdir,
 
29
        osutils,
 
30
        revision,
 
31
        transport,
 
32
        tree,
 
33
        ui,
 
34
        urlutils,
 
35
        )
28
36
from bzrlib.config import TreeConfig
29
37
from bzrlib.decorators import needs_read_lock, needs_write_lock
30
38
import bzrlib.errors as errors
572
580
            mainline_parent_id = revision_id
573
581
        return BranchCheckResult(self)
574
582
 
 
583
    def create_checkout(self, to_location, revision_id=None, 
 
584
                        lightweight=False):
 
585
        """Create a checkout of a branch.
 
586
        
 
587
        :param to_location: The url to produce the checkout at
 
588
        :param revision_id: The revision to check out
 
589
        :param lightweight: If True, produce a lightweight checkout, otherwise,
 
590
        produce a bound branch (heavyweight checkout)
 
591
        :return: The tree of the created checkout
 
592
        """
 
593
        if lightweight:
 
594
            t = transport.get_transport(to_location)
 
595
            try:
 
596
                t.mkdir('.')
 
597
            except errors.FileExists:
 
598
                pass
 
599
            checkout = bzrdir.BzrDirMetaFormat1().initialize_on_transport(t)
 
600
            BranchReferenceFormat().initialize(checkout, self)
 
601
        else:
 
602
            checkout_branch = bzrdir.BzrDir.create_branch_convenience(
 
603
                to_location, force_new_tree=False)
 
604
            checkout = checkout_branch.bzrdir
 
605
            checkout_branch.bind(self)
 
606
            if revision_id is not None:
 
607
                rh = checkout_branch.revision_history()
 
608
                new_rh = rh[:rh.index(revision_id) + 1]
 
609
                checkout_branch.set_revision_history(new_rh)
 
610
        return checkout.create_workingtree(revision_id)
 
611
 
575
612
 
576
613
class BranchFormat(object):
577
614
    """An encapsulation of the initialization and open routines for a format.
1064
1101
        transaction = self.get_transaction()
1065
1102
        history = transaction.map.find_revision_history()
1066
1103
        if history is not None:
1067
 
            mutter("cache hit for revision-history in %s", self)
 
1104
            # mutter("cache hit for revision-history in %s", self)
1068
1105
            return list(history)
1069
 
        history = [l.rstrip('\r\n') for l in
1070
 
                self.control_files.get_utf8('revision-history').readlines()]
 
1106
        decode_utf8 = cache_utf8.decode
 
1107
        history = [decode_utf8(l.rstrip('\r\n')) for l in
 
1108
                self.control_files.get('revision-history').readlines()]
1071
1109
        transaction.map.add_revision_history(history)
1072
1110
        # this call is disabled because revision_history is 
1073
1111
        # not really an object yet, and the transaction is for objects.