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

Merge up bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
94
94
        if committer is None:
95
95
            self._committer = self._config.username()
96
96
        else:
97
 
            assert isinstance(committer, basestring), type(committer)
98
97
            self._committer = committer
99
98
 
100
99
        self.new_inventory = Inventory(None)
327
326
            if kind != parent_entry.kind:
328
327
                store = True
329
328
        if kind == 'file':
330
 
            assert content_summary[2] is not None, \
331
 
                "Files must not have executable = None"
 
329
            if content_summary[2] is None:
 
330
                raise ValueError("Files must not have executable = None")
332
331
            if not store:
333
332
                if (# if the file length changed we have to store:
334
333
                    parent_entry.text_size != content_summary[1] or
500
499
        :returns: The validator(which is a sha1 digest, though what is sha'd is
501
500
            repository format specific) of the serialized inventory.
502
501
        """
503
 
        assert self.is_in_write_group()
 
502
        if not self.is_in_write_group():
 
503
            raise AssertionError("%r not in write group" % (self,))
504
504
        _mod_revision.check_not_reserved_id(revision_id)
505
 
        assert inv.revision_id is None or inv.revision_id == revision_id, \
506
 
            "Mismatch between inventory revision" \
507
 
            " id and insertion revid (%r, %r)" % (inv.revision_id, revision_id)
508
 
        assert inv.root is not None
 
505
        if not (inv.revision_id is None or inv.revision_id == revision_id):
 
506
            raise AssertionError(
 
507
                "Mismatch between inventory revision"
 
508
                " id and insertion revid (%r, %r)"
 
509
                % (inv.revision_id, revision_id))
 
510
        if inv.root is None:
 
511
            raise AssertionError()
509
512
        inv_lines = self._serialise_inventory_to_lines(inv)
510
513
        inv_vf = self.get_inventory_weave()
511
514
        return self._inventory_add_lines(inv_vf, revision_id, parents,
541
544
            plaintext = Testament(rev, inv).as_short_text()
542
545
            self.store_revision_signature(
543
546
                gpg.GPGStrategy(config), plaintext, revision_id)
544
 
        if not revision_id in self.get_inventory_weave():
 
547
        inventory_vf = self.get_inventory_weave()
 
548
        if not revision_id in inventory_vf:
545
549
            if inv is None:
546
550
                raise errors.WeaveRevisionNotPresent(revision_id,
547
 
                                                     self.get_inventory_weave())
 
551
                                                     inventory_vf)
548
552
            else:
549
553
                # yes, this is not suitable for adding with ghosts.
550
 
                rev.inventory_sha1 = self.add_inventory(revision_id, inv, 
 
554
                rev.inventory_sha1 = self.add_inventory(revision_id, inv,
551
555
                                                        rev.parent_ids)
 
556
        else:
 
557
            rev.inventory_sha1 = inventory_vf.get_sha1s([revision_id])[0]
552
558
        self._revision_store.add_revision(rev, self.get_transaction())
553
559
 
554
560
    def _add_revision_text(self, revision_id, text):
1091
1097
                raise errors.InvalidRevisionId(revision_id=rev_id, branch=self)
1092
1098
        revs = self._revision_store.get_revisions(revision_ids,
1093
1099
                                                  self.get_transaction())
1094
 
        for rev in revs:
1095
 
            assert not isinstance(rev.revision_id, unicode)
1096
 
            for parent_id in rev.parent_ids:
1097
 
                assert not isinstance(parent_id, unicode)
1098
1100
        return revs
1099
1101
 
1100
1102
    @needs_read_lock
1497
1499
 
1498
1500
        :return: An iterator of inventories.
1499
1501
        """
1500
 
        assert None not in revision_ids
1501
 
        assert _mod_revision.NULL_REVISION not in revision_ids
 
1502
        if ((None in revision_ids)
 
1503
            or (_mod_revision.NULL_REVISION in revision_ids)):
 
1504
            raise ValueError('cannot get null revision inventory')
1502
1505
        return self._iter_inventories(revision_ids)
1503
1506
 
1504
1507
    def _iter_inventories(self, revision_ids):
1532
1535
    def get_inventory_xml(self, revision_id):
1533
1536
        """Get inventory XML as a file object."""
1534
1537
        try:
1535
 
            assert isinstance(revision_id, str), type(revision_id)
1536
1538
            iw = self.get_inventory_weave()
1537
1539
            return iw.get_text(revision_id)
1538
1540
        except IndexError:
1679
1681
    def get_transaction(self):
1680
1682
        return self.control_files.get_transaction()
1681
1683
 
 
1684
    @deprecated_method(symbol_versioning.one_five)
1682
1685
    def revision_parents(self, revision_id):
1683
1686
        return self.get_inventory_weave().parent_names(revision_id)
1684
1687
 
2322
2325
        :param revision_ids: The start point for the search.
2323
2326
        :return: A set of revision ids.
2324
2327
        """
2325
 
        graph = self.source.get_graph()
2326
2328
        target_graph = self.target.get_graph()
 
2329
        revision_ids = frozenset(revision_ids)
 
2330
        if set(target_graph.get_parent_map(revision_ids)) == revision_ids:
 
2331
            return graph.SearchResult(revision_ids, set(), 0, set())
2327
2332
        missing_revs = set()
 
2333
        source_graph = self.source.get_graph()
2328
2334
        # ensure we don't pay silly lookup costs.
2329
 
        revision_ids = frozenset(revision_ids)
2330
 
        searcher = graph._make_breadth_first_searcher(revision_ids)
 
2335
        searcher = source_graph._make_breadth_first_searcher(revision_ids)
2331
2336
        null_set = frozenset([_mod_revision.NULL_REVISION])
2332
2337
        while True:
2333
2338
            try:
2382
2387
        target_ids = set(self.target.all_revision_ids())
2383
2388
        if revision_id is not None:
2384
2389
            source_ids = self.source.get_ancestry(revision_id)
2385
 
            assert source_ids[0] is None
 
2390
            if source_ids[0] is not None:
 
2391
                raise AssertionError()
2386
2392
            source_ids.pop(0)
2387
2393
        else:
2388
2394
            source_ids = self.source.all_revision_ids()
2549
2555
        # - RBC 20060209
2550
2556
        if revision_id is not None:
2551
2557
            source_ids = self.source.get_ancestry(revision_id)
2552
 
            assert source_ids[0] is None
 
2558
            if source_ids[0] is not None:
 
2559
                raise AssertionError()
2553
2560
            source_ids.pop(0)
2554
2561
        else:
2555
2562
            source_ids = self.source._all_possible_ids()
2618
2625
        """See InterRepository.missing_revision_ids()."""
2619
2626
        if revision_id is not None:
2620
2627
            source_ids = self.source.get_ancestry(revision_id)
2621
 
            assert source_ids[0] is None
 
2628
            if source_ids[0] is not None:
 
2629
                raise AssertionError()
2622
2630
            source_ids.pop(0)
2623
2631
        else:
2624
2632
            source_ids = self.source.all_revision_ids()
2705
2713
                    find_ghosts=find_ghosts).get_keys()
2706
2714
            except errors.NoSuchRevision:
2707
2715
                raise errors.InstallFailed([revision_id])
 
2716
            if len(revision_ids) == 0:
 
2717
                return (0, [])
2708
2718
        packs = self.source._pack_collection.all_packs()
2709
2719
        pack = Packer(self.target._pack_collection, packs, '.fetch',
2710
2720
            revision_ids).pack()
2729
2739
            return self._walk_to_common_revisions([revision_id])
2730
2740
        elif revision_id is not None:
2731
2741
            source_ids = self.source.get_ancestry(revision_id)
2732
 
            assert source_ids[0] is None
 
2742
            if source_ids[0] is not None:
 
2743
                raise AssertionError()
2733
2744
            source_ids.pop(0)
2734
2745
        else:
2735
2746
            source_ids = self.source.all_revision_ids()
2896
2907
        # Is source's model compatible with target's model?
2897
2908
        source._ensure_real()
2898
2909
        real_source = source._real_repository
2899
 
        assert not isinstance(real_source, remote.RemoteRepository), (
2900
 
            "We don't support remote repos backed by remote repos yet.")
 
2910
        if isinstance(real_source, remote.RemoteRepository):
 
2911
            raise NotImplementedError(
 
2912
                "We don't support remote repos backed by remote repos yet.")
2901
2913
        return InterRepository._same_model(real_source, target)
2902
2914
 
2903
2915
    @needs_write_lock