~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to tools/history2weaves.py

  • Committer: Martin Pool
  • Date: 2005-09-19 11:36:40 UTC
  • Revision ID: mbp@sourcefrog.net-20050919113639-d20df30be797b37b
- clean up code that writes out weave results

- track and show how many file versions were converted

Show diffs side-by-side

added added

removed removed

Lines of Context:
137
137
                and rev_id not in self.absent_revisions):
138
138
                self._load_one_rev(rev_id)
139
139
        self.pb.clear()
140
 
        to_import = self._make_order()[:500]
 
140
        to_import = self._make_order()
141
141
        for i, rev_id in enumerate(to_import):
142
142
            self.pb.update('converting revision', i, len(to_import))
143
143
            self._convert_one_rev(rev_id)
144
144
        self.pb.clear()
145
 
        print '(not really) upgraded to weaves:'
 
145
        print 'upgraded to weaves:'
146
146
        print '  %6d revisions and inventories' % len(self.revisions)
147
147
        print '  %6d absent revisions removed' % len(self.absent_revisions)
148
148
        print '  %6d texts' % self.text_count
152
152
 
153
153
    def _write_all_weaves(self):
154
154
        i = 0
155
 
        write_atomic_weave(self.inv_weave, 'weaves/inventory.weave')
 
155
        write_a_weave(self.inv_weave, 'weaves/inventory.weave')
156
156
        try:
157
157
            for file_id, file_weave in self.text_weaves.items():
158
158
                self.pb.update('writing weave', i, len(self.text_weaves))
159
 
                write_atomic_weave(file_weave, 'weaves/%s.weave' % file_id)
 
159
                write_a_weave(file_weave, 'weaves/%s.weave' % file_id)
160
160
                i += 1
161
161
        finally:
162
162
            self.pb.clear()
175
175
                    f.close()
176
176
        finally:
177
177
            self.pb.clear()
 
178
 
178
179
            
179
180
    def _load_one_rev(self, rev_id):
180
181
        """Load a revision object into memory.
228
229
        rev_id = rev.revision_id
229
230
        mutter('converting texts of revision {%s}',
230
231
               rev_id)
231
 
        for path, ie in inv.iter_entries():
 
232
        for file_id in inv:
 
233
            ie = inv[file_id]
232
234
            if ie.kind != 'file':
233
235
                continue
234
236
            self._convert_file_version(rev, ie)
268
270
        if len(file_parents) != 1 or text_changed:
269
271
            w.add(rev_id, file_parents, file_lines, ie.text_sha1)
270
272
            ie.name_version = ie.text_version = rev_id
 
273
            self.text_count += 1
271
274
            ##mutter('import text {%s} of {%s}',
272
275
            ##       ie.text_id, file_id)
273
276
        else:
301
304
        return o
302
305
                
303
306
 
304
 
def write_atomic_weave(weave, filename):
305
 
    inv_wf = AtomicFile(filename)
 
307
def write_a_weave(weave, filename):
 
308
    inv_wf = file(filename, 'wb')
306
309
    try:
307
310
        write_weave(weave, inv_wf)
308
 
        inv_wf.commit()
309
311
    finally:
310
312
        inv_wf.close()
311
313