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

  • Committer: Martin Pool
  • Date: 2008-05-27 03:00:53 UTC
  • mfrom: (3452 +trunk)
  • mto: (3724.1.1 lock-hooks)
  • mto: This revision was merged to the branch mainline in revision 3730.
  • Revision ID: mbp@sourcefrog.net-20080527030053-0mct6dypek0ysjc3
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
""")
25
25
from bzrlib import (
26
26
    bzrdir,
27
 
    deprecated_graph,
28
27
    errors,
29
28
    knit,
30
29
    lockable_files,
69
68
        """See graph._StackedParentsProvider.get_parent_map"""
70
69
        parent_map = {}
71
70
        for revision_id in keys:
 
71
            if revision_id is None:
 
72
                raise ValueError('get_parent_map(None) is not valid')
72
73
            if revision_id == _mod_revision.NULL_REVISION:
73
74
                parent_map[revision_id] = ()
74
75
            else:
101
102
        self._commit_builder_class = _commit_builder_class
102
103
        self._serializer = _serializer
103
104
        self._reconcile_fixes_text_parents = True
 
105
        control_store.get_scope = self.get_transaction
 
106
        text_store.get_scope = self.get_transaction
 
107
        _revision_store.get_scope = self.get_transaction
104
108
 
105
109
    def _warn_if_deprecated(self):
106
110
        # This class isn't deprecated
158
162
            raise errors.NoSuchRevision(self, revision_id)
159
163
 
160
164
    @symbol_versioning.deprecated_method(symbol_versioning.one_two)
161
 
    @needs_read_lock
162
165
    def get_data_stream(self, revision_ids):
163
166
        """See Repository.get_data_stream.
164
167
        
167
170
        search_result = self.revision_ids_to_search_result(set(revision_ids))
168
171
        return self.get_data_stream_for_search(search_result)
169
172
 
170
 
    @needs_read_lock
171
173
    def get_data_stream_for_search(self, search):
172
174
        """See Repository.get_data_stream_for_search."""
173
175
        item_keys = self.item_keys_introduced_by(search.get_keys())
195
197
        revision_id = osutils.safe_revision_id(revision_id)
196
198
        return self.get_revision_reconcile(revision_id)
197
199
 
198
 
    @symbol_versioning.deprecated_method(symbol_versioning.one_four)
199
 
    @needs_read_lock
200
 
    def get_revision_graph(self, revision_id=None):
201
 
        """Return a dictionary containing the revision graph.
202
 
 
203
 
        :param revision_id: The revision_id to get a graph from. If None, then
204
 
        the entire revision graph is returned. This is a deprecated mode of
205
 
        operation and will be removed in the future.
206
 
        :return: a dictionary of revision_id->revision_parents_list.
207
 
        """
208
 
        if 'evil' in debug.debug_flags:
209
 
            mutter_callsite(3,
210
 
                "get_revision_graph scales with size of history.")
211
 
        # special case NULL_REVISION
212
 
        if revision_id == _mod_revision.NULL_REVISION:
213
 
            return {}
214
 
        a_weave = self._get_revision_vf()
215
 
        if revision_id is None:
216
 
            return a_weave.get_graph()
217
 
        if revision_id not in a_weave:
218
 
            raise errors.NoSuchRevision(self, revision_id)
219
 
        else:
220
 
            # add what can be reached from revision_id
221
 
            return a_weave.get_graph([revision_id])
222
 
 
223
 
    @needs_read_lock
224
 
    @symbol_versioning.deprecated_method(symbol_versioning.one_three)
225
 
    def get_revision_graph_with_ghosts(self, revision_ids=None):
226
 
        """Return a graph of the revisions with ghosts marked as applicable.
227
 
 
228
 
        :param revision_ids: an iterable of revisions to graph or None for all.
229
 
        :return: a Graph object with the graph reachable from revision_ids.
230
 
        """
231
 
        if 'evil' in debug.debug_flags:
232
 
            mutter_callsite(3,
233
 
                "get_revision_graph_with_ghosts scales with size of history.")
234
 
        result = deprecated_graph.Graph()
235
 
        vf = self._get_revision_vf()
236
 
        versions = set(vf.versions())
237
 
        if not revision_ids:
238
 
            pending = set(self.all_revision_ids())
239
 
            required = set([])
240
 
        else:
241
 
            pending = set(revision_ids)
242
 
            # special case NULL_REVISION
243
 
            if _mod_revision.NULL_REVISION in pending:
244
 
                pending.remove(_mod_revision.NULL_REVISION)
245
 
            required = set(pending)
246
 
        done = set([])
247
 
        while len(pending):
248
 
            revision_id = pending.pop()
249
 
            if not revision_id in versions:
250
 
                if revision_id in required:
251
 
                    raise errors.NoSuchRevision(self, revision_id)
252
 
                # a ghost
253
 
                result.add_ghost(revision_id)
254
 
                # mark it as done so we don't try for it again.
255
 
                done.add(revision_id)
256
 
                continue
257
 
            parent_ids = vf.get_parents_with_ghosts(revision_id)
258
 
            for parent_id in parent_ids:
259
 
                # is this queued or done ?
260
 
                if (parent_id not in pending and
261
 
                    parent_id not in done):
262
 
                    # no, queue it.
263
 
                    pending.add(parent_id)
264
 
            result.add_node(revision_id, parent_ids)
265
 
            done.add(revision_id)
266
 
        return result
267
 
 
268
200
    def _get_revision_vf(self):
269
201
        """:return: a versioned file containing the revisions."""
270
202
        vf = self._revision_store.get_revision_file(self.get_transaction())
287
219
        reconciler.reconcile()
288
220
        return reconciler
289
221
    
 
222
    @symbol_versioning.deprecated_method(symbol_versioning.one_five)
290
223
    def revision_parents(self, revision_id):
291
224
        return self._get_revision_vf().get_parents(revision_id)
292
225
 
300
233
        :returns: an iterator yielding tuples of (revison-id, parents-in-index,
301
234
            parents-in-revision).
302
235
        """
303
 
        assert self.is_locked()
 
236
        if not self.is_locked():
 
237
            raise AssertionError()
304
238
        vf = self._get_revision_vf()
305
239
        for index_version in vf.versions():
306
240
            parents_according_to_index = tuple(vf.get_parents_with_ghosts(
358
292
            repo_transport,
359
293
            prefixed=False,
360
294
            file_mode=control_files._file_mode,
361
 
            versionedfile_class=knit.KnitVersionedFile,
 
295
            versionedfile_class=knit.make_file_knit,
362
296
            versionedfile_kwargs={'factory':knit.KnitPlainFactory()},
363
297
            )
364
298
 
369
303
            file_mode=control_files._file_mode,
370
304
            prefixed=False,
371
305
            precious=True,
372
 
            versionedfile_class=knit.KnitVersionedFile,
 
306
            versionedfile_class=knit.make_file_knit,
373
307
            versionedfile_kwargs={'delta':False,
374
308
                                  'factory':knit.KnitPlainFactory(),
375
309
                                 },
382
316
        return self._get_versioned_file_store('knits',
383
317
                                  transport,
384
318
                                  control_files,
385
 
                                  versionedfile_class=knit.KnitVersionedFile,
 
319
                                  versionedfile_class=knit.make_file_knit,
386
320
                                  versionedfile_kwargs={
387
321
                                      'create_parent_dir':True,
388
322
                                      'delay_create':True,
427
361
        """
428
362
        if not _found:
429
363
            format = RepositoryFormat.find_format(a_bzrdir)
430
 
            assert format.__class__ ==  self.__class__
431
364
        if _override_transport is not None:
432
365
            repo_transport = _override_transport
433
366
        else: