~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: 2009-08-12 02:59:14 UTC
  • mfrom: (4593.3.3 403523-status-crash)
  • Revision ID: pqm@pqm.ubuntu.com-20090812025914-5k1krw3iyfjvow5u
(robertc) Fix selective status against historic revisions. (Martin
        Pool)

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
427
425
 
428
426
    def abort(self):
429
427
        """Cancel creating this pack."""
450
448
            self.signature_index.key_count() or
451
449
            (self.chk_index is not None and self.chk_index.key_count()))
452
450
 
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
 
 
461
451
    def finish(self, suspend=False):
462
452
        """Finish the new pack.
463
453
 
469
459
         - stores the index size tuple for the pack in the index_sizes
470
460
           attribute.
471
461
        """
472
 
        self.finish_content()
 
462
        self._writer.end()
 
463
        if self._buffer[1]:
 
464
            self._write_data('', flush=True)
 
465
        self.name = self._hash.hexdigest()
473
466
        if not suspend:
474
467
            self._check_references()
475
468
        # write indices
1574
1567
        # determine which packs need changing
1575
1568
        pack_operations = [[0, []]]
1576
1569
        for pack in self.all_packs():
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.
 
1570
            if not hint or pack.name in hint:
1580
1571
                pack_operations[-1][0] += pack.get_revision_count()
1581
1572
                pack_operations[-1][1].append(pack)
1582
1573
        self._execute_pack_operations(pack_operations, OptimisingPacker)
2102
2093
                # when autopack takes no steps, the names list is still
2103
2094
                # unsaved.
2104
2095
                return self._save_pack_names()
2105
 
        return []
2106
2096
 
2107
2097
    def _suspend_write_group(self):
2108
2098
        tokens = [pack.name for pack in self._resumed_packs]
2529
2519
        """See RepositoryFormat.get_format_description()."""
2530
2520
        return "Packs containing knits without subtree support"
2531
2521
 
 
2522
    def check_conversion_target(self, target_format):
 
2523
        pass
 
2524
 
2532
2525
 
2533
2526
class RepositoryFormatKnitPack3(RepositoryFormatPack):
2534
2527
    """A subtrees parameterized Pack repository.
2560
2553
 
2561
2554
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2562
2555
 
 
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
 
2563
2564
    def get_format_string(self):
2564
2565
        """See RepositoryFormat.get_format_string()."""
2565
2566
        return "Bazaar pack repository format 1 with subtree support (needs bzr 0.92)\n"
2598
2599
 
2599
2600
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2600
2601
 
 
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
 
2601
2607
    def get_format_string(self):
2602
2608
        """See RepositoryFormat.get_format_string()."""
2603
2609
        return ("Bazaar pack repository format 1 with rich root"
2644
2650
        """See RepositoryFormat.get_format_description()."""
2645
2651
        return "Packs 5 (adds stacking support, requires bzr 1.6)"
2646
2652
 
 
2653
    def check_conversion_target(self, target_format):
 
2654
        pass
 
2655
 
2647
2656
 
2648
2657
class RepositoryFormatKnitPack5RichRoot(RepositoryFormatPack):
2649
2658
    """A repository with rich roots and stacking.
2676
2685
 
2677
2686
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2678
2687
 
 
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
 
2679
2693
    def get_format_string(self):
2680
2694
        """See RepositoryFormat.get_format_string()."""
2681
2695
        return "Bazaar RepositoryFormatKnitPack5RichRoot (bzr 1.6.1)\n"
2722
2736
 
2723
2737
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2724
2738
 
 
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
 
2725
2744
    def get_format_string(self):
2726
2745
        """See RepositoryFormat.get_format_string()."""
2727
2746
        return "Bazaar RepositoryFormatKnitPack5RichRoot (bzr 1.6)\n"
2765
2784
        """See RepositoryFormat.get_format_description()."""
2766
2785
        return "Packs 6 (uses btree indexes, requires bzr 1.9)"
2767
2786
 
 
2787
    def check_conversion_target(self, target_format):
 
2788
        pass
 
2789
 
2768
2790
 
2769
2791
class RepositoryFormatKnitPack6RichRoot(RepositoryFormatPack):
2770
2792
    """A repository with rich roots, no subtrees, stacking and btree indexes.
2794
2816
 
2795
2817
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2796
2818
 
 
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
 
2797
2824
    def get_format_string(self):
2798
2825
        """See RepositoryFormat.get_format_string()."""
2799
2826
        return "Bazaar RepositoryFormatKnitPack6RichRoot (bzr 1.9)\n"
2835
2862
 
2836
2863
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2837
2864
 
 
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
 
2838
2873
    def get_format_string(self):
2839
2874
        """See RepositoryFormat.get_format_string()."""
2840
2875
        return ("Bazaar development format 2 with subtree support "