~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/pack_repo.py

  • Committer: Alexander Belchenko
  • Date: 2008-02-06 15:33:12 UTC
  • mto: This revision was merged to the branch mainline in revision 3231.
  • Revision ID: bialix@ukr.net-20080206153312-qycs7u05d7fjtwqq
Ian's review

Show diffs side-by-side

added added

removed removed

Lines of Context:
642
642
        # at this point.
643
643
        self.pb.update("Copying inventory texts", 2)
644
644
        total_items, readv_group_iter = self._least_readv_node_readv(inv_nodes)
645
 
        # Only grab the output lines if we will be processing them
646
 
        output_lines = bool(self.revision_ids)
647
645
        inv_lines = self._copy_nodes_graph(inventory_index_map,
648
646
            self.new_pack._writer, self.new_pack.inventory_index,
649
 
            readv_group_iter, total_items, output_lines=output_lines)
 
647
            readv_group_iter, total_items, output_lines=True)
650
648
        if self.revision_ids:
651
649
            self._process_inventory_lines(inv_lines)
652
650
        else:
658
656
                time.ctime(), self._pack_collection._upload_transport.base,
659
657
                self.new_pack.random_name,
660
658
                self.new_pack.inventory_index.key_count(),
661
 
                time.time() - self.new_pack.start_time)
 
659
                time.time() - new_pack.start_time)
662
660
 
663
661
    def _copy_text_texts(self):
664
662
        # select text keys
1928
1926
            found_parents[key[0]] = parents
1929
1927
        return found_parents
1930
1928
 
1931
 
    @needs_read_lock
1932
 
    def get_revision_graph(self, revision_id=None):
1933
 
        """Return a dictionary containing the revision graph.
1934
 
 
1935
 
        :param revision_id: The revision_id to get a graph from. If None, then
1936
 
        the entire revision graph is returned. This is a deprecated mode of
1937
 
        operation and will be removed in the future.
1938
 
        :return: a dictionary of revision_id->revision_parents_list.
1939
 
        """
1940
 
        if 'evil' in debug.debug_flags:
1941
 
            mutter_callsite(3,
1942
 
                "get_revision_graph scales with size of history.")
1943
 
        # special case NULL_REVISION
1944
 
        if revision_id == _mod_revision.NULL_REVISION:
1945
 
            return {}
1946
 
        if revision_id is None:
1947
 
            revision_vf = self._get_revision_vf()
1948
 
            return revision_vf.get_graph()
1949
 
        g = self.get_graph()
1950
 
        first = g.get_parent_map([revision_id])
1951
 
        if revision_id not in first:
1952
 
            raise errors.NoSuchRevision(self, revision_id)
1953
 
        else:
1954
 
            ancestry = {}
1955
 
            children = {}
1956
 
            NULL_REVISION = _mod_revision.NULL_REVISION
1957
 
            ghosts = set([NULL_REVISION])
1958
 
            for rev_id, parent_ids in g.iter_ancestry([revision_id]):
1959
 
                if parent_ids is None: # This is a ghost
1960
 
                    ghosts.add(rev_id)
1961
 
                    continue
1962
 
                ancestry[rev_id] = parent_ids
1963
 
                for p in parent_ids:
1964
 
                    if p in children:
1965
 
                        children[p].append(rev_id)
1966
 
                    else:
1967
 
                        children[p] = [rev_id]
1968
 
 
1969
 
            if NULL_REVISION in ancestry:
1970
 
                del ancestry[NULL_REVISION]
1971
 
 
1972
 
            # Find all nodes that reference a ghost, and filter the ghosts out
1973
 
            # of their parent lists. To preserve the order of parents, and
1974
 
            # avoid double filtering nodes, we just find all children first,
1975
 
            # and then filter.
1976
 
            children_of_ghosts = set()
1977
 
            for ghost in ghosts:
1978
 
                children_of_ghosts.update(children[ghost])
1979
 
 
1980
 
            for child in children_of_ghosts:
1981
 
                ancestry[child] = tuple(p for p in ancestry[child]
1982
 
                                           if p not in ghosts)
1983
 
            return ancestry
1984
 
 
1985
1929
    def has_revisions(self, revision_ids):
1986
1930
        """See Repository.has_revisions()."""
1987
1931
        revision_ids = set(revision_ids)
2111
2055
    # Set this attribute in derived clases to control the _serializer that the
2112
2056
    # repository objects will have passed to their constructor.
2113
2057
    _serializer = None
2114
 
    # External references are not supported in pack repositories yet.
2115
 
    supports_external_lookups = False
2116
2058
 
2117
2059
    def _get_control_store(self, repo_transport, control_files):
2118
2060
        """Return the control store for this repository."""
2307
2249
    def get_format_description(self):
2308
2250
        """See RepositoryFormat.get_format_description()."""
2309
2251
        return "Packs containing knits with rich root support\n"
2310
 
 
2311
 
 
2312
 
class RepositoryFormatPackDevelopment0(RepositoryFormatPack):
2313
 
    """A no-subtrees development repository.
2314
 
 
2315
 
    This format should be retained until the second release after bzr 1.0.
2316
 
 
2317
 
    No changes to the disk behaviour from pack-0.92.
2318
 
    """
2319
 
 
2320
 
    repository_class = KnitPackRepository
2321
 
    _commit_builder_class = PackCommitBuilder
2322
 
    _serializer = xml5.serializer_v5
2323
 
 
2324
 
    def _get_matching_bzrdir(self):
2325
 
        return bzrdir.format_registry.make_bzrdir('development0')
2326
 
 
2327
 
    def _ignore_setting_bzrdir(self, format):
2328
 
        pass
2329
 
 
2330
 
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2331
 
 
2332
 
    def get_format_string(self):
2333
 
        """See RepositoryFormat.get_format_string()."""
2334
 
        return "Bazaar development format 0 (needs bzr.dev from before 1.3)\n"
2335
 
 
2336
 
    def get_format_description(self):
2337
 
        """See RepositoryFormat.get_format_description()."""
2338
 
        return ("Development repository format, currently the same as "
2339
 
            "pack-0.92\n")
2340
 
 
2341
 
    def check_conversion_target(self, target_format):
2342
 
        pass
2343
 
 
2344
 
 
2345
 
class RepositoryFormatPackDevelopment0Subtree(RepositoryFormatPack):
2346
 
    """A subtrees development repository.
2347
 
 
2348
 
    This format should be retained until the second release after bzr 1.0.
2349
 
 
2350
 
    No changes to the disk behaviour from pack-0.92-subtree.
2351
 
    """
2352
 
 
2353
 
    repository_class = KnitPackRepository
2354
 
    _commit_builder_class = PackRootCommitBuilder
2355
 
    rich_root_data = True
2356
 
    supports_tree_reference = True
2357
 
    _serializer = xml7.serializer_v7
2358
 
 
2359
 
    def _get_matching_bzrdir(self):
2360
 
        return bzrdir.format_registry.make_bzrdir(
2361
 
            'development0-subtree')
2362
 
 
2363
 
    def _ignore_setting_bzrdir(self, format):
2364
 
        pass
2365
 
 
2366
 
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2367
 
 
2368
 
    def check_conversion_target(self, target_format):
2369
 
        if not target_format.rich_root_data:
2370
 
            raise errors.BadConversionTarget(
2371
 
                'Does not support rich root data.', target_format)
2372
 
        if not getattr(target_format, 'supports_tree_reference', False):
2373
 
            raise errors.BadConversionTarget(
2374
 
                'Does not support nested trees', target_format)
2375
 
            
2376
 
    def get_format_string(self):
2377
 
        """See RepositoryFormat.get_format_string()."""
2378
 
        return ("Bazaar development format 0 with subtree support "
2379
 
            "(needs bzr.dev from before 1.3)\n")
2380
 
 
2381
 
    def get_format_description(self):
2382
 
        """See RepositoryFormat.get_format_description()."""
2383
 
        return ("Development repository format, currently the same as "
2384
 
            "pack-0.92-subtree\n")
2385
 
 
2386