/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/repository.py

  • Committer: John Arbash Meinel
  • Date: 2007-12-04 18:11:51 UTC
  • mfrom: (3074 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3075.
  • Revision ID: john@arbash-meinel.com-20071204181151-br85qwsgshso16q5
[merge] bzr.dev 3074

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
    # the default CommitBuilder does not manage trees whose root is versioned.
77
77
    _versioned_root = False
78
78
 
79
 
    def __init__(self, repository, parents, config, timestamp=None, 
80
 
                 timezone=None, committer=None, revprops=None, 
 
79
    def __init__(self, repository, parents, config, timestamp=None,
 
80
                 timezone=None, committer=None, revprops=None,
81
81
                 revision_id=None):
82
82
        """Initiate a CommitBuilder.
83
83
 
118
118
            self._timezone = int(timezone)
119
119
 
120
120
        self._generate_revision_if_needed()
121
 
        self._heads = graph.HeadsCache(repository.get_graph()).heads
 
121
        self.__heads = graph.HeadsCache(repository.get_graph()).heads
122
122
 
123
123
    def commit(self, message):
124
124
        """Make the actual commit.
190
190
        else:
191
191
            self.random_revid = False
192
192
 
 
193
    def _heads(self, file_id, revision_ids):
 
194
        """Calculate the graph heads for revision_ids in the graph of file_id.
 
195
 
 
196
        This can use either a per-file graph or a global revision graph as we
 
197
        have an identity relationship between the two graphs.
 
198
        """
 
199
        return self.__heads(revision_ids)
 
200
 
193
201
    def _check_root(self, ie, parent_invs, tree):
194
202
        """Helper for record_entry_contents.
195
203
 
287
295
        # XXX: Friction: parent_candidates should return a list not a dict
288
296
        #      so that we don't have to walk the inventories again.
289
297
        parent_candiate_entries = ie.parent_candidates(parent_invs)
290
 
        head_set = self._heads(parent_candiate_entries.keys())
 
298
        head_set = self._heads(ie.file_id, parent_candiate_entries.keys())
291
299
        heads = []
292
300
        for inv in parent_invs:
293
301
            if ie.file_id in inv:
1234
1242
                raise errors.NoSuchIdInRepository(self, file_id)
1235
1243
            yield callable_data, weave.get_lines(revision_id)
1236
1244
 
1237
 
    def _generate_text_key_index(self):
 
1245
    def _generate_text_key_index(self, text_key_references=None,
 
1246
        ancestors=None):
1238
1247
        """Generate a new text key index for the repository.
1239
1248
 
1240
1249
        This is an expensive function that will take considerable time to run.
1244
1253
            the parents list will be [NULL_REVISION].
1245
1254
        """
1246
1255
        # All revisions, to find inventory parents.
1247
 
        revision_graph = self.get_revision_graph_with_ghosts()
1248
 
        ancestors = revision_graph.get_ancestors()
1249
 
        text_key_references = self.find_text_key_references()
 
1256
        if ancestors is None:
 
1257
            revision_graph = self.get_revision_graph_with_ghosts()
 
1258
            ancestors = revision_graph.get_ancestors()
 
1259
        if text_key_references is None:
 
1260
            text_key_references = self.find_text_key_references()
1250
1261
        pb = ui.ui_factory.nested_progress_bar()
1251
1262
        try:
1252
1263
            return self._do_generate_text_key_index(ancestors,
1662
1673
                [parents_provider, other_repository._make_parents_provider()])
1663
1674
        return graph.Graph(parents_provider)
1664
1675
 
1665
 
    def get_versioned_file_checker(self):
 
1676
    def _get_versioned_file_checker(self):
1666
1677
        """Return an object suitable for checking versioned files."""
1667
 
        return VersionedFileChecker(self)
 
1678
        return _VersionedFileChecker(self)
1668
1679
 
1669
1680
    @needs_write_lock
1670
1681
    def set_make_working_trees(self, new_value):
2141
2152
    'RepositoryFormat7'
2142
2153
    )
2143
2154
 
2144
 
# KEEP in sync with bzrdir.format_registry default, which controls the overall
2145
 
# default control directory format
2146
2155
format_registry.register_lazy(
2147
2156
    'Bazaar-NG Knit Repository Format 1',
2148
2157
    'bzrlib.repofmt.knitrepo',
2149
2158
    'RepositoryFormatKnit1',
2150
2159
    )
2151
 
format_registry.default_key = 'Bazaar-NG Knit Repository Format 1'
2152
2160
 
2153
2161
format_registry.register_lazy(
2154
2162
    'Bazaar Knit Repository Format 3 (bzr 0.15)\n',
2884
2892
    return _unescape_re.sub(_unescaper, data)
2885
2893
 
2886
2894
 
2887
 
class VersionedFileChecker(object):
 
2895
class _VersionedFileChecker(object):
2888
2896
 
2889
2897
    def __init__(self, repository):
2890
2898
        self.repository = repository
2900
2908
        # strip the file_id, for the weave api
2901
2909
        return tuple([revision_id for file_id, revision_id in parent_keys])
2902
2910
 
2903
 
    def check_file_version_parents(self, weave, file_id, planned_revisions):
 
2911
    def check_file_version_parents(self, weave, file_id):
2904
2912
        """Check the parents stored in a versioned file are correct.
2905
2913
 
2906
2914
        It also detects file versions that are not referenced by their
2915
2923
        """
2916
2924
        wrong_parents = {}
2917
2925
        unused_versions = set()
2918
 
        for num, revision_id in enumerate(planned_revisions):
 
2926
        for num, revision_id in enumerate(weave.versions()):
2919
2927
            try:
2920
2928
                correct_parents = self.calculate_file_version_parents(
2921
2929
                    revision_id, file_id)
2922
2930
            except KeyError:
2923
 
                # we were asked to investigate a non-existant version.
 
2931
                # The version is not part of the used keys.
2924
2932
                unused_versions.add(revision_id)
2925
2933
            else:
2926
2934
                try: