~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to multiparent.py

  • Committer: Aaron Bentley
  • Date: 2007-04-14 07:23:54 UTC
  • mto: (2520.4.1 bzr.mpbundle)
  • mto: This revision was merged to the branch mainline in revision 2631.
  • Revision ID: aaron.bentley@utoronto.ca-20070414072354-8g2awkl9xgkdkx3h
merge changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
290
290
 
291
291
    def make_snapshot(self, version_id):
292
292
        snapdiff = MultiParent([NewText(self.cache_version(version_id))])
 
293
        self.add_diff(snapdiff, version_id, self._parents[version_id])
293
294
        self._snapshots.add(version_id)
294
295
 
295
296
    def import_versionedfile(self, vf, snapshots, no_cache=True,
358
359
    def select_by_size(self, num):
359
360
        """Select snapshots for minimum output size"""
360
361
        num -= len(self._snapshots)
361
 
        return get_size_ranking()[:num]
 
362
        new_snapshots = self.get_size_ranking()[-num:]
 
363
        return [v for n, v in new_snapshots]
362
364
 
363
365
    def get_size_ranking(self):
364
366
        versions = []
369
371
            diff_len = self.get_diff(version_id).patch_len()
370
372
            snapshot_len = MultiParent([NewText(
371
373
                self.cache_version(version_id))]).patch_len()
372
 
            versions.append((diff_len - snapshot_len, version_id))
 
374
            versions.append((snapshot_len - diff_len, version_id))
373
375
        versions.sort()
374
 
        return [v for n, v in versions[:num]]
 
376
        return versions
 
377
        return [v for n, v in versions]
 
378
 
 
379
    def import_diffs(self, vf):
 
380
        for version_id in vf.versions():
 
381
            self.add_diff(vf.get_diff(version_id), version_id,
 
382
                          vf._parents[version_id])
375
383
 
376
384
    def get_build_ranking(self):
377
385
        could_avoid = {}