/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/bundle/serializer/v08.py

  • Committer: John Arbash Meinel
  • Date: 2006-08-15 20:43:59 UTC
  • mto: This revision was merged to the branch mainline in revision 1941.
  • Revision ID: john@arbash-meinel.com-20060815204359-eadc1cffce520dd1
Get 10% savings by just fixing a bug

Show diffs side-by-side

added added

removed removed

Lines of Context:
108
108
        self.to_file = f
109
109
        source.lock_read()
110
110
        try:
111
 
            # Extract the list of Revision objects
112
 
            self.revisions = source.get_revisions(revision_ids)
113
111
            self._write_main_header()
114
112
            pb = DummyProgress()
115
113
            try:
149
147
    def _write_revisions(self, pb):
150
148
        """Write the information for all of the revisions."""
151
149
 
152
 
        i_max = len(self.revision_ids)
153
 
        # Taken from Repository.get_deltas_for_revisions, and modified for our
154
 
        # case of manually specified base trees, and prefering deltas against
155
 
        # last parent, rather than first parent
156
 
        required_trees = set(self.forced_bases.values())
157
 
        for rev in self.revisions:
158
 
            required_trees.add(rev.revision_id)
159
 
            required_trees.update(rev.parent_ids[-1:])
 
150
        # Optimize for the case of revisions in order
 
151
        last_rev_id = None
 
152
        last_rev_tree = None
160
153
 
161
 
        # TODO: jam 20060815 handle ghosts
162
 
        # TODO: jam 20060815 This can potentially grow without bound
163
 
        #       It keeps a full RevisionTree for every entry being bundled
164
 
        #       We really should have a convenience function for only extracting
165
 
        #       a portion, while still allowing the optimization of reading
166
 
        #       many at once.
167
 
        trees = dict((t.get_revision_id(), t) for 
168
 
                     t in self.source.revision_trees(required_trees))
169
 
        trees[NULL_REVISION] = self.source.revision_tree(NULL_REVISION)
170
 
        for i, rev in enumerate(self.revisions):
 
154
        i_max = len(self.revision_ids) 
 
155
        for i, rev_id in enumerate(self.revision_ids):
171
156
            pb.update("Generating revsion data", i, i_max)
172
 
            if rev.revision_id in self.forced_bases:
 
157
            rev = self.source.get_revision(rev_id)
 
158
            if rev_id == last_rev_id:
 
159
                rev_tree = last_rev_tree
 
160
            else:
 
161
                rev_tree = self.source.revision_tree(rev_id)
 
162
            if rev_id in self.forced_bases:
173
163
                explicit_base = True
174
 
                base_id = self.forced_bases[rev.revision_id]
 
164
                base_id = self.forced_bases[rev_id]
175
165
                if base_id is None:
176
166
                    base_id = NULL_REVISION
177
167
            else:
180
170
                    base_id = rev.parent_ids[-1]
181
171
                else:
182
172
                    base_id = NULL_REVISION
183
 
            base_tree = trees[base_id]
184
 
            rev_tree = trees[rev.revision_id]
 
173
 
 
174
            if base_id == last_rev_id:
 
175
                base_tree = last_rev_tree
 
176
            else:
 
177
                base_tree = self.source.revision_tree(base_id)
185
178
            force_binary = (i != 0)
186
 
            self._write_revision(rev, rev_tree, base_id, base_tree,
 
179
            self._write_revision(rev, rev_tree, base_id, base_tree, 
187
180
                                 explicit_base, force_binary)
188
181
 
189
 
    def _write_revision(self, rev, rev_tree, base_rev, base_tree,
 
182
            last_rev_id = base_id
 
183
            last_rev_tree = base_tree
 
184
 
 
185
    def _write_revision(self, rev, rev_tree, base_rev, base_tree, 
190
186
                        explicit_base, force_binary):
191
187
        """Write out the information for a revision."""
192
188
        def w(key, value):