/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

  • Committer: Andrew Bennetts
  • Date: 2008-04-02 00:14:00 UTC
  • mfrom: (3324 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3756.
  • Revision ID: andrew.bennetts@canonical.com-20080402001400-r1pqse38i03dl97w
Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
551
551
                                                     self.get_inventory_weave())
552
552
            else:
553
553
                # yes, this is not suitable for adding with ghosts.
554
 
                self.add_inventory(revision_id, inv, rev.parent_ids)
 
554
                rev.inventory_sha1 = self.add_inventory(revision_id, inv, 
 
555
                                                        rev.parent_ids)
555
556
        self._revision_store.add_revision(rev, self.get_transaction())
556
557
 
557
558
    def _add_revision_text(self, revision_id, text):
1338
1339
        """
1339
1340
        # All revisions, to find inventory parents.
1340
1341
        if ancestors is None:
1341
 
            # self.get_revision_graph_with_ghosts().get_ancestors() wasn't
1342
 
            # returning any ghosts anyway.
1343
 
            ancestors = self.get_revision_graph()
 
1342
            graph = self.get_graph()
 
1343
            ancestors = graph.get_parent_map(self.all_revision_ids())
1344
1344
        if text_key_references is None:
1345
1345
            text_key_references = self.find_text_key_references()
1346
1346
        pb = ui.ui_factory.nested_progress_bar()
1552
1552
        return self.get_revision(revision_id).inventory_sha1
1553
1553
 
1554
1554
    @needs_read_lock
 
1555
    @deprecated_method(symbol_versioning.one_four)
1555
1556
    def get_revision_graph(self, revision_id=None):
1556
1557
        """Return a dictionary containing the revision graph.
1557
1558
 
1607
1608
            done.add(revision_id)
1608
1609
        return result
1609
1610
 
1610
 
    def _get_history_vf(self):
1611
 
        """Get a versionedfile whose history graph reflects all revisions.
1612
 
 
1613
 
        For weave repositories, this is the inventory weave.
1614
 
        """
1615
 
        return self.get_inventory_weave()
1616
 
 
1617
1611
    def iter_reverse_revision_history(self, revision_id):
1618
1612
        """Iterate backwards through revision ids in the lefthand history
1619
1613
 
1620
1614
        :param revision_id: The revision id to start with.  All its lefthand
1621
1615
            ancestors will be traversed.
1622
1616
        """
1623
 
        if revision_id in (None, _mod_revision.NULL_REVISION):
1624
 
            return
 
1617
        graph = self.get_graph()
1625
1618
        next_id = revision_id
1626
 
        versionedfile = self._get_history_vf()
1627
1619
        while True:
 
1620
            if next_id in (None, _mod_revision.NULL_REVISION):
 
1621
                return
1628
1622
            yield next_id
1629
 
            parents = versionedfile.get_parents(next_id)
 
1623
            # Note: The following line may raise KeyError in the event of
 
1624
            # truncated history. We decided not to have a try:except:raise
 
1625
            # RevisionNotPresent here until we see a use for it, because of the
 
1626
            # cost in an inner loop that is by its very nature O(history).
 
1627
            # Robert Collins 20080326
 
1628
            parents = graph.get_parent_map([next_id])[next_id]
1630
1629
            if len(parents) == 0:
1631
1630
                return
1632
1631
            else:
3124
3123
        """
3125
3124
        wrong_parents = {}
3126
3125
        unused_versions = set()
3127
 
        for num, revision_id in enumerate(weave.versions()):
 
3126
        versions = weave.versions()
 
3127
        parent_map = weave.get_parent_map(versions)
 
3128
        for num, revision_id in enumerate(versions):
3128
3129
            try:
3129
3130
                correct_parents = self.calculate_file_version_parents(
3130
3131
                    revision_id, file_id)
3133
3134
                unused_versions.add(revision_id)
3134
3135
            else:
3135
3136
                try:
3136
 
                    knit_parents = tuple(weave.get_parents(revision_id))
 
3137
                    knit_parents = tuple(parent_map[revision_id])
3137
3138
                except errors.RevisionNotPresent:
3138
3139
                    knit_parents = None
3139
3140
                if correct_parents != knit_parents:
3140
3141
                    wrong_parents[revision_id] = (knit_parents, correct_parents)
3141
3142
        return wrong_parents, unused_versions
 
3143
 
 
3144
 
 
3145
def _old_get_graph(repository, revision_id):
 
3146
    """DO NOT USE. That is all. I'm serious."""
 
3147
    graph = repository.get_graph()
 
3148
    revision_graph = dict(((key, value) for key, value in
 
3149
        graph.iter_ancestry([revision_id]) if value is not None))
 
3150
    return _strip_NULL_ghosts(revision_graph)
 
3151
 
 
3152
 
 
3153
def _strip_NULL_ghosts(revision_graph):
 
3154
    """Also don't use this. more compatibility code for unmigrated clients."""
 
3155
    # Filter ghosts, and null:
 
3156
    if _mod_revision.NULL_REVISION in revision_graph:
 
3157
        del revision_graph[_mod_revision.NULL_REVISION]
 
3158
    for key, parents in revision_graph.items():
 
3159
        revision_graph[key] = tuple(parent for parent in parents if parent
 
3160
            in revision_graph)
 
3161
    return revision_graph