~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

`bzr remove` now just backs up changed files instead of annoying you

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
    check,
26
26
    chk_map,
27
27
    config,
28
 
    controldir,
29
28
    debug,
30
29
    fetch as _mod_fetch,
31
30
    fifo_cache,
892
891
# Repositories
893
892
 
894
893
 
895
 
class Repository(_RelockDebugMixin, controldir.ControlComponent):
 
894
class Repository(_RelockDebugMixin, bzrdir.ControlComponent):
896
895
    """Repository holding history for one or more branches.
897
896
 
898
897
    The repository holds and retrieves historical information including
2511
2510
            ancestors will be traversed.
2512
2511
        """
2513
2512
        graph = self.get_graph()
2514
 
        stop_revisions = (None, _mod_revision.NULL_REVISION)
2515
 
        return graph.iter_lefthand_ancestry(revision_id, stop_revisions)
 
2513
        next_id = revision_id
 
2514
        while True:
 
2515
            if next_id in (None, _mod_revision.NULL_REVISION):
 
2516
                return
 
2517
            try:
 
2518
                parents = graph.get_parent_map([next_id])[next_id]
 
2519
            except KeyError:
 
2520
                raise errors.RevisionNotPresent(next_id, self)
 
2521
            yield next_id
 
2522
            if len(parents) == 0:
 
2523
                return
 
2524
            else:
 
2525
                next_id = parents[0]
2516
2526
 
2517
2527
    def is_shared(self):
2518
2528
        """Return True if this repository is flagged as a shared repository."""
3378
3388
    'bzrlib.repofmt.groupcompress_repo',
3379
3389
    'RepositoryFormat2a',
3380
3390
    )
3381
 
format_registry.register_lazy(
3382
 
    'Bazaar development format 8\n',
3383
 
    'bzrlib.repofmt.groupcompress_repo',
3384
 
    'RepositoryFormat2aSubtree',
3385
 
    )
3386
3391
 
3387
3392
 
3388
3393
class InterRepository(InterObject):
3842
3847
                basis_id, delta, current_revision_id, parents_parents)
3843
3848
            cache[current_revision_id] = parent_tree
3844
3849
 
3845
 
    def _fetch_batch(self, revision_ids, basis_id, cache):
 
3850
    def _fetch_batch(self, revision_ids, basis_id, cache, a_graph=None):
3846
3851
        """Fetch across a few revisions.
3847
3852
 
3848
3853
        :param revision_ids: The revisions to copy
3849
3854
        :param basis_id: The revision_id of a tree that must be in cache, used
3850
3855
            as a basis for delta when no other base is available
3851
3856
        :param cache: A cache of RevisionTrees that we can use.
 
3857
        :param a_graph: A Graph object to determine the heads() of the
 
3858
            rich-root data stream.
3852
3859
        :return: The revision_id of the last converted tree. The RevisionTree
3853
3860
            for it will be in cache
3854
3861
        """
3922
3929
        if root_keys_to_create:
3923
3930
            root_stream = _mod_fetch._new_root_data_stream(
3924
3931
                root_keys_to_create, self._revision_id_to_root_id, parent_map,
3925
 
                self.source)
 
3932
                self.source, graph=a_graph)
3926
3933
            to_texts.insert_record_stream(root_stream)
3927
3934
        to_texts.insert_record_stream(from_texts.get_record_stream(
3928
3935
            text_keys, self.target._format._fetch_order,
3985
3992
        cache[basis_id] = basis_tree
3986
3993
        del basis_tree # We don't want to hang on to it here
3987
3994
        hints = []
3988
 
        a_graph = None
 
3995
        if self._converting_to_rich_root and len(revision_ids) > 100:
 
3996
            a_graph = _mod_fetch._get_rich_root_heads_graph(self.source,
 
3997
                                                            revision_ids)
 
3998
        else:
 
3999
            a_graph = None
3989
4000
 
3990
4001
        for offset in range(0, len(revision_ids), batch_size):
3991
4002
            self.target.start_write_group()
3993
4004
                pb.update('Transferring revisions', offset,
3994
4005
                          len(revision_ids))
3995
4006
                batch = revision_ids[offset:offset+batch_size]
3996
 
                basis_id = self._fetch_batch(batch, basis_id, cache)
 
4007
                basis_id = self._fetch_batch(batch, basis_id, cache,
 
4008
                                             a_graph=a_graph)
3997
4009
            except:
3998
4010
                self.source._safe_to_return_from_cache = False
3999
4011
                self.target.abort_write_group()