/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/repofmt/pack_repo.py

  • Committer: Martin Pool
  • Date: 2009-08-26 05:38:16 UTC
  • mfrom: (4634.6.2 2.0)
  • mto: (4634.6.4 2.0)
  • mto: This revision was merged to the branch mainline in revision 4660.
  • Revision ID: mbp@sourcefrog.net-20090826053816-ht6jpktdm77vi6t5
MergeĀ 2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
422
422
        self._writer.begin()
423
423
        # what state is the pack in? (open, finished, aborted)
424
424
        self._state = 'open'
 
425
        # no name until we finish writing the content
 
426
        self.name = None
425
427
 
426
428
    def abort(self):
427
429
        """Cancel creating this pack."""
448
450
            self.signature_index.key_count() or
449
451
            (self.chk_index is not None and self.chk_index.key_count()))
450
452
 
 
453
    def finish_content(self):
 
454
        if self.name is not None:
 
455
            return
 
456
        self._writer.end()
 
457
        if self._buffer[1]:
 
458
            self._write_data('', flush=True)
 
459
        self.name = self._hash.hexdigest()
 
460
 
451
461
    def finish(self, suspend=False):
452
462
        """Finish the new pack.
453
463
 
459
469
         - stores the index size tuple for the pack in the index_sizes
460
470
           attribute.
461
471
        """
462
 
        self._writer.end()
463
 
        if self._buffer[1]:
464
 
            self._write_data('', flush=True)
465
 
        self.name = self._hash.hexdigest()
 
472
        self.finish_content()
466
473
        if not suspend:
467
474
            self._check_references()
468
475
        # write indices
1567
1574
        # determine which packs need changing
1568
1575
        pack_operations = [[0, []]]
1569
1576
        for pack in self.all_packs():
1570
 
            if not hint or pack.name in hint:
 
1577
            if hint is None or pack.name in hint:
 
1578
                # Either no hint was provided (so we are packing everything),
 
1579
                # or this pack was included in the hint.
1571
1580
                pack_operations[-1][0] += pack.get_revision_count()
1572
1581
                pack_operations[-1][1].append(pack)
1573
1582
        self._execute_pack_operations(pack_operations, OptimisingPacker)
2093
2102
                # when autopack takes no steps, the names list is still
2094
2103
                # unsaved.
2095
2104
                return self._save_pack_names()
 
2105
        return []
2096
2106
 
2097
2107
    def _suspend_write_group(self):
2098
2108
        tokens = [pack.name for pack in self._resumed_packs]
2519
2529
        """See RepositoryFormat.get_format_description()."""
2520
2530
        return "Packs containing knits without subtree support"
2521
2531
 
2522
 
    def check_conversion_target(self, target_format):
2523
 
        pass
2524
 
 
2525
2532
 
2526
2533
class RepositoryFormatKnitPack3(RepositoryFormatPack):
2527
2534
    """A subtrees parameterized Pack repository.
2553
2560
 
2554
2561
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2555
2562
 
2556
 
    def check_conversion_target(self, target_format):
2557
 
        if not target_format.rich_root_data:
2558
 
            raise errors.BadConversionTarget(
2559
 
                'Does not support rich root data.', target_format)
2560
 
        if not getattr(target_format, 'supports_tree_reference', False):
2561
 
            raise errors.BadConversionTarget(
2562
 
                'Does not support nested trees', target_format)
2563
 
 
2564
2563
    def get_format_string(self):
2565
2564
        """See RepositoryFormat.get_format_string()."""
2566
2565
        return "Bazaar pack repository format 1 with subtree support (needs bzr 0.92)\n"
2599
2598
 
2600
2599
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2601
2600
 
2602
 
    def check_conversion_target(self, target_format):
2603
 
        if not target_format.rich_root_data:
2604
 
            raise errors.BadConversionTarget(
2605
 
                'Does not support rich root data.', target_format)
2606
 
 
2607
2601
    def get_format_string(self):
2608
2602
        """See RepositoryFormat.get_format_string()."""
2609
2603
        return ("Bazaar pack repository format 1 with rich root"
2650
2644
        """See RepositoryFormat.get_format_description()."""
2651
2645
        return "Packs 5 (adds stacking support, requires bzr 1.6)"
2652
2646
 
2653
 
    def check_conversion_target(self, target_format):
2654
 
        pass
2655
 
 
2656
2647
 
2657
2648
class RepositoryFormatKnitPack5RichRoot(RepositoryFormatPack):
2658
2649
    """A repository with rich roots and stacking.
2685
2676
 
2686
2677
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2687
2678
 
2688
 
    def check_conversion_target(self, target_format):
2689
 
        if not target_format.rich_root_data:
2690
 
            raise errors.BadConversionTarget(
2691
 
                'Does not support rich root data.', target_format)
2692
 
 
2693
2679
    def get_format_string(self):
2694
2680
        """See RepositoryFormat.get_format_string()."""
2695
2681
        return "Bazaar RepositoryFormatKnitPack5RichRoot (bzr 1.6.1)\n"
2736
2722
 
2737
2723
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2738
2724
 
2739
 
    def check_conversion_target(self, target_format):
2740
 
        if not target_format.rich_root_data:
2741
 
            raise errors.BadConversionTarget(
2742
 
                'Does not support rich root data.', target_format)
2743
 
 
2744
2725
    def get_format_string(self):
2745
2726
        """See RepositoryFormat.get_format_string()."""
2746
2727
        return "Bazaar RepositoryFormatKnitPack5RichRoot (bzr 1.6)\n"
2784
2765
        """See RepositoryFormat.get_format_description()."""
2785
2766
        return "Packs 6 (uses btree indexes, requires bzr 1.9)"
2786
2767
 
2787
 
    def check_conversion_target(self, target_format):
2788
 
        pass
2789
 
 
2790
2768
 
2791
2769
class RepositoryFormatKnitPack6RichRoot(RepositoryFormatPack):
2792
2770
    """A repository with rich roots, no subtrees, stacking and btree indexes.
2816
2794
 
2817
2795
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2818
2796
 
2819
 
    def check_conversion_target(self, target_format):
2820
 
        if not target_format.rich_root_data:
2821
 
            raise errors.BadConversionTarget(
2822
 
                'Does not support rich root data.', target_format)
2823
 
 
2824
2797
    def get_format_string(self):
2825
2798
        """See RepositoryFormat.get_format_string()."""
2826
2799
        return "Bazaar RepositoryFormatKnitPack6RichRoot (bzr 1.9)\n"
2862
2835
 
2863
2836
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2864
2837
 
2865
 
    def check_conversion_target(self, target_format):
2866
 
        if not target_format.rich_root_data:
2867
 
            raise errors.BadConversionTarget(
2868
 
                'Does not support rich root data.', target_format)
2869
 
        if not getattr(target_format, 'supports_tree_reference', False):
2870
 
            raise errors.BadConversionTarget(
2871
 
                'Does not support nested trees', target_format)
2872
 
 
2873
2838
    def get_format_string(self):
2874
2839
        """See RepositoryFormat.get_format_string()."""
2875
2840
        return ("Bazaar development format 2 with subtree support "