/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: Aaron Bentley
  • Date: 2006-08-16 04:04:30 UTC
  • mfrom: (1922 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1934.
  • Revision ID: aaron.bentley@utoronto.ca-20060816040430-3d869d673bdde644
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
534
541
                rev = self.repository.get_revision(revision_id)
535
542
                new_history = rev.get_history(self.repository)[1:]
536
543
        destination.set_revision_history(new_history)
537
 
        parent = self.get_parent()
538
 
        if parent:
539
 
            destination.set_parent(parent)
 
544
        try:
 
545
            parent = self.get_parent()
 
546
        except errors.InaccessibleParent, e:
 
547
            mutter('parent was not accessible to copy: %s', e)
 
548
        else:
 
549
            if parent:
 
550
                destination.set_parent(parent)
540
551
 
541
552
    @needs_read_lock
542
553
    def check(self):
568
579
            mainline_parent_id = revision_id
569
580
        return BranchCheckResult(self)
570
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
 
571
611
 
572
612
class BranchFormat(object):
573
613
    """An encapsulation of the initialization and open routines for a format.
1170
1210
            # turn it into a url
1171
1211
            if parent.startswith('/'):
1172
1212
                parent = urlutils.local_path_to_url(parent.decode('utf8'))
1173
 
            return urlutils.join(self.base[:-1], parent)
 
1213
            try:
 
1214
                return urlutils.join(self.base[:-1], parent)
 
1215
            except errors.InvalidURLJoin, e:
 
1216
                raise errors.InaccessibleParent(parent, self.base)
1174
1217
        return None
1175
1218
 
1176
1219
    def get_push_location(self):