~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/pack_repo.py

  • Committer: John Arbash Meinel
  • Date: 2010-01-13 16:23:07 UTC
  • mto: (4634.119.7 2.0)
  • mto: This revision was merged to the branch mainline in revision 4959.
  • Revision ID: john@arbash-meinel.com-20100113162307-0bs82td16gzih827
Update the MANIFEST.in file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
224
224
        return self.index_name('text', name)
225
225
 
226
226
    def _replace_index_with_readonly(self, index_type):
 
227
        unlimited_cache = False
 
228
        if index_type == 'chk':
 
229
            unlimited_cache = True
227
230
        setattr(self, index_type + '_index',
228
231
            self.index_class(self.index_transport,
229
232
                self.index_name(index_type, self.name),
230
 
                self.index_sizes[self.index_offset(index_type)]))
 
233
                self.index_sizes[self.index_offset(index_type)],
 
234
                unlimited_cache=unlimited_cache))
231
235
 
232
236
 
233
237
class ExistingPack(Pack):
422
426
        self._writer.begin()
423
427
        # what state is the pack in? (open, finished, aborted)
424
428
        self._state = 'open'
 
429
        # no name until we finish writing the content
 
430
        self.name = None
425
431
 
426
432
    def abort(self):
427
433
        """Cancel creating this pack."""
448
454
            self.signature_index.key_count() or
449
455
            (self.chk_index is not None and self.chk_index.key_count()))
450
456
 
 
457
    def finish_content(self):
 
458
        if self.name is not None:
 
459
            return
 
460
        self._writer.end()
 
461
        if self._buffer[1]:
 
462
            self._write_data('', flush=True)
 
463
        self.name = self._hash.hexdigest()
 
464
 
451
465
    def finish(self, suspend=False):
452
466
        """Finish the new pack.
453
467
 
459
473
         - stores the index size tuple for the pack in the index_sizes
460
474
           attribute.
461
475
        """
462
 
        self._writer.end()
463
 
        if self._buffer[1]:
464
 
            self._write_data('', flush=True)
465
 
        self.name = self._hash.hexdigest()
 
476
        self.finish_content()
466
477
        if not suspend:
467
478
            self._check_references()
468
479
        # write indices
1567
1578
        # determine which packs need changing
1568
1579
        pack_operations = [[0, []]]
1569
1580
        for pack in self.all_packs():
1570
 
            if not hint or pack.name in hint:
 
1581
            if hint is None or pack.name in hint:
 
1582
                # Either no hint was provided (so we are packing everything),
 
1583
                # or this pack was included in the hint.
1571
1584
                pack_operations[-1][0] += pack.get_revision_count()
1572
1585
                pack_operations[-1][1].append(pack)
1573
1586
        self._execute_pack_operations(pack_operations, OptimisingPacker)
1665
1678
            txt_index = self._make_index(name, '.tix')
1666
1679
            sig_index = self._make_index(name, '.six')
1667
1680
            if self.chk_index is not None:
1668
 
                chk_index = self._make_index(name, '.cix')
 
1681
                chk_index = self._make_index(name, '.cix', unlimited_cache=True)
1669
1682
            else:
1670
1683
                chk_index = None
1671
1684
            result = ExistingPack(self._pack_transport, name, rev_index,
1690
1703
            txt_index = self._make_index(name, '.tix', resume=True)
1691
1704
            sig_index = self._make_index(name, '.six', resume=True)
1692
1705
            if self.chk_index is not None:
1693
 
                chk_index = self._make_index(name, '.cix', resume=True)
 
1706
                chk_index = self._make_index(name, '.cix', resume=True,
 
1707
                                             unlimited_cache=True)
1694
1708
            else:
1695
1709
                chk_index = None
1696
1710
            result = self.resumed_pack_factory(name, rev_index, inv_index,
1726
1740
        return self._index_class(self.transport, 'pack-names', None
1727
1741
                ).iter_all_entries()
1728
1742
 
1729
 
    def _make_index(self, name, suffix, resume=False):
 
1743
    def _make_index(self, name, suffix, resume=False, unlimited_cache=False):
1730
1744
        size_offset = self._suffix_offsets[suffix]
1731
1745
        index_name = name + suffix
1732
1746
        if resume:
1735
1749
        else:
1736
1750
            transport = self._index_transport
1737
1751
            index_size = self._names[name][size_offset]
1738
 
        return self._index_class(transport, index_name, index_size)
 
1752
        return self._index_class(transport, index_name, index_size,
 
1753
                                 unlimited_cache=unlimited_cache)
1739
1754
 
1740
1755
    def _max_pack_count(self, total_revisions):
1741
1756
        """Return the maximum number of packs to use for total revisions.
2054
2069
            self._remove_pack_indices(resumed_pack)
2055
2070
        del self._resumed_packs[:]
2056
2071
 
 
2072
    def _check_new_inventories(self):
 
2073
        """Detect missing inventories in this write group.
 
2074
 
 
2075
        :returns: list of strs, summarising any problems found.  If the list is
 
2076
            empty no problems were found.
 
2077
        """
 
2078
        # The base implementation does no checks.  GCRepositoryPackCollection
 
2079
        # overrides this.
 
2080
        return []
 
2081
        
2057
2082
    def _commit_write_group(self):
2058
2083
        all_missing = set()
2059
2084
        for prefix, versioned_file in (
2068
2093
            raise errors.BzrCheckError(
2069
2094
                "Repository %s has missing compression parent(s) %r "
2070
2095
                 % (self.repo, sorted(all_missing)))
 
2096
        problems = self._check_new_inventories()
 
2097
        if problems:
 
2098
            problems_summary = '\n'.join(problems)
 
2099
            raise errors.BzrCheckError(
 
2100
                "Cannot add revision(s) to repository: " + problems_summary)
2071
2101
        self._remove_pack_indices(self._new_pack)
2072
 
        should_autopack = False
 
2102
        any_new_content = False
2073
2103
        if self._new_pack.data_inserted():
2074
2104
            # get all the data to disk and read to use
2075
2105
            self._new_pack.finish()
2076
2106
            self.allocate(self._new_pack)
2077
2107
            self._new_pack = None
2078
 
            should_autopack = True
 
2108
            any_new_content = True
2079
2109
        else:
2080
2110
            self._new_pack.abort()
2081
2111
            self._new_pack = None
2086
2116
            self._remove_pack_from_memory(resumed_pack)
2087
2117
            resumed_pack.finish()
2088
2118
            self.allocate(resumed_pack)
2089
 
            should_autopack = True
 
2119
            any_new_content = True
2090
2120
        del self._resumed_packs[:]
2091
 
        if should_autopack:
2092
 
            if not self.autopack():
 
2121
        if any_new_content:
 
2122
            result = self.autopack()
 
2123
            if not result:
2093
2124
                # when autopack takes no steps, the names list is still
2094
2125
                # unsaved.
2095
2126
                return self._save_pack_names()
 
2127
            return result
 
2128
        return []
2096
2129
 
2097
2130
    def _suspend_write_group(self):
2098
2131
        tokens = [pack.name for pack in self._resumed_packs]
2212
2245
                    % (self._format, self.bzrdir.transport.base))
2213
2246
 
2214
2247
    def _abort_write_group(self):
2215
 
        self.revisions._index._key_dependencies.refs.clear()
 
2248
        self.revisions._index._key_dependencies.clear()
2216
2249
        self._pack_collection._abort_write_group()
2217
2250
 
2218
2251
    def _get_source(self, to_format):
2232
2265
        self._pack_collection._start_write_group()
2233
2266
 
2234
2267
    def _commit_write_group(self):
2235
 
        self.revisions._index._key_dependencies.refs.clear()
2236
 
        return self._pack_collection._commit_write_group()
 
2268
        hint = self._pack_collection._commit_write_group()
 
2269
        self.revisions._index._key_dependencies.clear()
 
2270
        return hint
2237
2271
 
2238
2272
    def suspend_write_group(self):
2239
2273
        # XXX check self._write_group is self.get_transaction()?
2240
2274
        tokens = self._pack_collection._suspend_write_group()
2241
 
        self.revisions._index._key_dependencies.refs.clear()
 
2275
        self.revisions._index._key_dependencies.clear()
2242
2276
        self._write_group = None
2243
2277
        return tokens
2244
2278
 
2519
2553
        """See RepositoryFormat.get_format_description()."""
2520
2554
        return "Packs containing knits without subtree support"
2521
2555
 
2522
 
    def check_conversion_target(self, target_format):
2523
 
        pass
2524
 
 
2525
2556
 
2526
2557
class RepositoryFormatKnitPack3(RepositoryFormatPack):
2527
2558
    """A subtrees parameterized Pack repository.
2553
2584
 
2554
2585
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2555
2586
 
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
2587
    def get_format_string(self):
2565
2588
        """See RepositoryFormat.get_format_string()."""
2566
2589
        return "Bazaar pack repository format 1 with subtree support (needs bzr 0.92)\n"
2599
2622
 
2600
2623
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2601
2624
 
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
2625
    def get_format_string(self):
2608
2626
        """See RepositoryFormat.get_format_string()."""
2609
2627
        return ("Bazaar pack repository format 1 with rich root"
2650
2668
        """See RepositoryFormat.get_format_description()."""
2651
2669
        return "Packs 5 (adds stacking support, requires bzr 1.6)"
2652
2670
 
2653
 
    def check_conversion_target(self, target_format):
2654
 
        pass
2655
 
 
2656
2671
 
2657
2672
class RepositoryFormatKnitPack5RichRoot(RepositoryFormatPack):
2658
2673
    """A repository with rich roots and stacking.
2685
2700
 
2686
2701
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2687
2702
 
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
2703
    def get_format_string(self):
2694
2704
        """See RepositoryFormat.get_format_string()."""
2695
2705
        return "Bazaar RepositoryFormatKnitPack5RichRoot (bzr 1.6.1)\n"
2736
2746
 
2737
2747
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2738
2748
 
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
2749
    def get_format_string(self):
2745
2750
        """See RepositoryFormat.get_format_string()."""
2746
2751
        return "Bazaar RepositoryFormatKnitPack5RichRoot (bzr 1.6)\n"
2784
2789
        """See RepositoryFormat.get_format_description()."""
2785
2790
        return "Packs 6 (uses btree indexes, requires bzr 1.9)"
2786
2791
 
2787
 
    def check_conversion_target(self, target_format):
2788
 
        pass
2789
 
 
2790
2792
 
2791
2793
class RepositoryFormatKnitPack6RichRoot(RepositoryFormatPack):
2792
2794
    """A repository with rich roots, no subtrees, stacking and btree indexes.
2816
2818
 
2817
2819
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2818
2820
 
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
2821
    def get_format_string(self):
2825
2822
        """See RepositoryFormat.get_format_string()."""
2826
2823
        return "Bazaar RepositoryFormatKnitPack6RichRoot (bzr 1.9)\n"
2862
2859
 
2863
2860
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2864
2861
 
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
2862
    def get_format_string(self):
2874
2863
        """See RepositoryFormat.get_format_string()."""
2875
2864
        return ("Bazaar development format 2 with subtree support "