~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/pack_repo.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-11-28 00:59:30 UTC
  • mfrom: (2979.2.5 commit.merge-speed)
  • Revision ID: pqm@pqm.ubuntu.com-20071128005930-4wb5pl12fyq8ek13
(robertc) Change commit on pack repositories to use the per-file
        graph for heads() calculations. (Robert Collins, 165306)

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
        pack,
27
27
        ui,
28
28
        )
 
29
from bzrlib.graph import Graph
29
30
from bzrlib.index import (
30
31
    GraphIndex,
31
32
    GraphIndexBuilder,
73
74
    added text, reducing memory and object pressure.
74
75
    """
75
76
 
 
77
    def __init__(self, repository, parents, config, timestamp=None,
 
78
                 timezone=None, committer=None, revprops=None,
 
79
                 revision_id=None):
 
80
        CommitBuilder.__init__(self, repository, parents, config,
 
81
            timestamp=timestamp, timezone=timezone, committer=committer,
 
82
            revprops=revprops, revision_id=revision_id)
 
83
        self._file_graph = Graph(
 
84
            repository._pack_collection.text_index.combined_index)
 
85
 
76
86
    def _add_text_to_weave(self, file_id, new_lines, parents, nostore_sha):
77
87
        return self.repository._pack_collection._add_text_to_weave(file_id,
78
88
            self._new_revision_id, new_lines, parents, nostore_sha,
79
89
            self.random_revid)
80
90
 
 
91
    def _heads(self, file_id, revision_ids):
 
92
        keys = [(file_id, revision_id) for revision_id in revision_ids]
 
93
        return set([key[1] for key in self._file_graph.heads(keys)])
 
94
 
81
95
 
82
96
class PackRootCommitBuilder(RootCommitBuilder):
83
97
    """A subclass of RootCommitBuilder to add texts with pack semantics.
86
100
    added text, reducing memory and object pressure.
87
101
    """
88
102
 
 
103
    def __init__(self, repository, parents, config, timestamp=None,
 
104
                 timezone=None, committer=None, revprops=None,
 
105
                 revision_id=None):
 
106
        CommitBuilder.__init__(self, repository, parents, config,
 
107
            timestamp=timestamp, timezone=timezone, committer=committer,
 
108
            revprops=revprops, revision_id=revision_id)
 
109
        self._file_graph = Graph(
 
110
            repository._pack_collection.text_index.combined_index)
 
111
 
89
112
    def _add_text_to_weave(self, file_id, new_lines, parents, nostore_sha):
90
113
        return self.repository._pack_collection._add_text_to_weave(file_id,
91
114
            self._new_revision_id, new_lines, parents, nostore_sha,
92
115
            self.random_revid)
93
116
 
 
117
    def _heads(self, file_id, revision_ids):
 
118
        keys = [(file_id, revision_id) for revision_id in revision_ids]
 
119
        return set([key[1] for key in self._file_graph.heads(keys)])
 
120
 
94
121
 
95
122
class Pack(object):
96
123
    """An in memory proxy for a pack and its indices.