/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/bzrdir.py

  • Committer: Wouter van Heyst
  • Date: 2006-06-06 12:06:20 UTC
  • mfrom: (1740 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1752.
  • Revision ID: larstiq@larstiq.dyndns.org-20060606120620-50066b0951e4ef7c
merge bzr.dev 1740

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
import bzrlib.urlutils as urlutils
48
48
from bzrlib.weave import Weave
49
49
from bzrlib.xml4 import serializer_v4
50
 
from bzrlib.xml5 import serializer_v5
 
50
import bzrlib.xml5
51
51
 
52
52
 
53
53
class BzrDir(object):
118
118
        if local_repo:
119
119
            # may need to copy content in
120
120
            if force_new_repo:
121
 
                local_repo.clone(result, revision_id=revision_id, basis=basis_repo)
 
121
                result_repo = local_repo.clone(
 
122
                    result,
 
123
                    revision_id=revision_id,
 
124
                    basis=basis_repo)
 
125
                result_repo.set_make_working_trees(local_repo.make_working_trees())
122
126
            else:
123
127
                try:
124
128
                    result_repo = result.find_repository()
130
134
                    result_repo.fetch(local_repo, revision_id=revision_id)
131
135
                except errors.NoRepositoryPresent:
132
136
                    # needed to make one anyway.
133
 
                    local_repo.clone(result, revision_id=revision_id, basis=basis_repo)
 
137
                    result_repo = local_repo.clone(
 
138
                        result,
 
139
                        revision_id=revision_id,
 
140
                        basis=basis_repo)
 
141
                    result_repo.set_make_working_trees(local_repo.make_working_trees())
134
142
        # 1 if there is a branch present
135
143
        #   make sure its content is available in the target repository
136
144
        #   clone it.
405
413
        self.transport = _transport.clone('.bzr')
406
414
        self.root_transport = _transport
407
415
 
 
416
    def is_control_filename(self, filename):
 
417
        """True if filename is the name of a path which is reserved for bzrdir's.
 
418
        
 
419
        :param filename: A filename within the root transport of this bzrdir.
 
420
 
 
421
        This is true IF and ONLY IF the filename is part of the namespace reserved
 
422
        for bzr control dirs. Currently this is the '.bzr' directory in the root
 
423
        of the root_transport. it is expected that plugins will need to extend
 
424
        this in the future - for instance to make bzr talk with svn working
 
425
        trees.
 
426
        """
 
427
        # this might be better on the BzrDirFormat class because it refers to 
 
428
        # all the possible bzrdir disk formats. 
 
429
        # This method is tested via the workingtree is_control_filename tests- 
 
430
        # it was extractd from WorkingTree.is_control_filename. If the methods
 
431
        # contract is extended beyond the current trivial  implementation please
 
432
        # add new tests for it to the appropriate place.
 
433
        return filename == '.bzr' or filename.startswith('.bzr/')
 
434
 
408
435
    def needs_format_conversion(self, format=None):
409
436
        """Return true if this bzrdir needs convert_format run on it.
410
437
        
572
599
            # no repo available, make a new one
573
600
            result.create_repository()
574
601
        elif source_repository is not None and result_repo is None:
575
 
            # have soure, and want to make a new target repo
576
 
            source_repository.clone(result,
577
 
                                    revision_id=revision_id,
578
 
                                    basis=basis_repo)
579
 
        else:
 
602
            # have source, and want to make a new target repo
 
603
            # we dont clone the repo because that preserves attributes
 
604
            # like is_shared(), and we have not yet implemented a 
 
605
            # repository sprout().
 
606
            result_repo = result.create_repository()
 
607
        if result_repo is not None:
580
608
            # fetch needed content into target.
581
609
            if basis_repo:
582
610
                # XXX FIXME RBC 20060214 need tests for this when the basis
1443
1471
 
1444
1472
    def _convert_working_inv(self):
1445
1473
        inv = serializer_v4.read_inventory(self.branch.control_files.get('inventory'))
1446
 
        new_inv_xml = serializer_v5.write_inventory_to_string(inv)
 
1474
        new_inv_xml = bzrlib.xml5.serializer_v5.write_inventory_to_string(inv)
1447
1475
        # FIXME inventory is a working tree change.
1448
1476
        self.branch.control_files.put('inventory', new_inv_xml)
1449
1477
 
1517
1545
    def _load_updated_inventory(self, rev_id):
1518
1546
        assert rev_id in self.converted_revs
1519
1547
        inv_xml = self.inv_weave.get_text(rev_id)
1520
 
        inv = serializer_v5.read_inventory_from_string(inv_xml)
 
1548
        inv = bzrlib.xml5.serializer_v5.read_inventory_from_string(inv_xml)
1521
1549
        return inv
1522
1550
 
1523
1551
    def _convert_one_rev(self, rev_id):
1540
1568
                assert hasattr(ie, 'revision'), \
1541
1569
                    'no revision on {%s} in {%s}' % \
1542
1570
                    (file_id, rev.revision_id)
1543
 
        new_inv_xml = serializer_v5.write_inventory_to_string(inv)
 
1571
        new_inv_xml = bzrlib.xml5.serializer_v5.write_inventory_to_string(inv)
1544
1572
        new_inv_sha1 = sha_string(new_inv_xml)
1545
1573
        self.inv_weave.add_lines(rev.revision_id, 
1546
1574
                                 present_parents,