~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: Andrew Bennetts
  • Date: 2009-12-03 05:57:41 UTC
  • mfrom: (4857 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4869.
  • Revision ID: andrew.bennetts@canonical.com-20091203055741-vmmg0fmjgjw2pwvu
MergeĀ lp:bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
    chk_map,
27
27
    debug,
28
28
    errors,
 
29
    fetch as _mod_fetch,
29
30
    fifo_cache,
30
31
    generate_ids,
31
32
    gpg,
2668
2669
        for ((revision_id,), parent_keys) in \
2669
2670
                self.revisions.get_parent_map(query_keys).iteritems():
2670
2671
            if parent_keys:
2671
 
                result[revision_id] = tuple(parent_revid
2672
 
                    for (parent_revid,) in parent_keys)
 
2672
                result[revision_id] = tuple([parent_revid
 
2673
                    for (parent_revid,) in parent_keys])
2673
2674
            else:
2674
2675
                result[revision_id] = (_mod_revision.NULL_REVISION,)
2675
2676
        return result
3093
3094
        """
3094
3095
        try:
3095
3096
            transport = a_bzrdir.get_repository_transport(None)
3096
 
            format_string = transport.get("format").read()
 
3097
            format_string = transport.get_bytes("format")
3097
3098
            return format_registry.get(format_string)
3098
3099
        except errors.NoSuchFile:
3099
3100
            raise errors.NoRepositoryPresent(a_bzrdir)
3412
3413
                   provided a default one will be created.
3413
3414
        :return: None.
3414
3415
        """
3415
 
        from bzrlib.fetch import RepoFetcher
3416
 
        f = RepoFetcher(to_repository=self.target,
 
3416
        f = _mod_fetch.RepoFetcher(to_repository=self.target,
3417
3417
                               from_repository=self.source,
3418
3418
                               last_revision=revision_id,
3419
3419
                               fetch_spec=fetch_spec,
3819
3819
                basis_id, delta, current_revision_id, parents_parents)
3820
3820
            cache[current_revision_id] = parent_tree
3821
3821
 
3822
 
    def _fetch_batch(self, revision_ids, basis_id, cache):
 
3822
    def _fetch_batch(self, revision_ids, basis_id, cache, a_graph=None):
3823
3823
        """Fetch across a few revisions.
3824
3824
 
3825
3825
        :param revision_ids: The revisions to copy
3826
3826
        :param basis_id: The revision_id of a tree that must be in cache, used
3827
3827
            as a basis for delta when no other base is available
3828
3828
        :param cache: A cache of RevisionTrees that we can use.
 
3829
        :param a_graph: A Graph object to determine the heads() of the
 
3830
            rich-root data stream.
3829
3831
        :return: The revision_id of the last converted tree. The RevisionTree
3830
3832
            for it will be in cache
3831
3833
        """
3895
3897
        from_texts = self.source.texts
3896
3898
        to_texts = self.target.texts
3897
3899
        if root_keys_to_create:
3898
 
            from bzrlib.fetch import _new_root_data_stream
3899
 
            root_stream = _new_root_data_stream(
 
3900
            root_stream = _mod_fetch._new_root_data_stream(
3900
3901
                root_keys_to_create, self._revision_id_to_root_id, parent_map,
3901
 
                self.source)
 
3902
                self.source, graph=a_graph)
3902
3903
            to_texts.insert_record_stream(root_stream)
3903
3904
        to_texts.insert_record_stream(from_texts.get_record_stream(
3904
3905
            text_keys, self.target._format._fetch_order,
3961
3962
        cache[basis_id] = basis_tree
3962
3963
        del basis_tree # We don't want to hang on to it here
3963
3964
        hints = []
 
3965
        if self._converting_to_rich_root and len(revision_ids) > 100:
 
3966
            a_graph = _mod_fetch._get_rich_root_heads_graph(self.source,
 
3967
                                                            revision_ids)
 
3968
        else:
 
3969
            a_graph = None
 
3970
 
3964
3971
        for offset in range(0, len(revision_ids), batch_size):
3965
3972
            self.target.start_write_group()
3966
3973
            try:
3967
3974
                pb.update('Transferring revisions', offset,
3968
3975
                          len(revision_ids))
3969
3976
                batch = revision_ids[offset:offset+batch_size]
3970
 
                basis_id = self._fetch_batch(batch, basis_id, cache)
 
3977
                basis_id = self._fetch_batch(batch, basis_id, cache,
 
3978
                                             a_graph=a_graph)
3971
3979
            except:
3972
3980
                self.target.abort_write_group()
3973
3981
                raise
4446
4454
        fetching the inventory weave.
4447
4455
        """
4448
4456
        if self._rich_root_upgrade():
4449
 
            import bzrlib.fetch
4450
 
            return bzrlib.fetch.Inter1and2Helper(
 
4457
            return _mod_fetch.Inter1and2Helper(
4451
4458
                self.from_repository).generate_root_texts(revs)
4452
4459
        else:
4453
4460
            return []