/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: John Arbash Meinel
  • Date: 2008-06-05 16:27:16 UTC
  • mfrom: (3475 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3476.
  • Revision ID: john@arbash-meinel.com-20080605162716-a3hn238tnctbfd8j
merge bzr.dev, resolve NEWS

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
 
    @needs_read_lock
199
 
    def get_revision_graph(self, revision_id=None):
200
 
        """Return a dictionary containing the revision graph.
201
 
 
202
 
        :param revision_id: The revision_id to get a graph from. If None, then
203
 
        the entire revision graph is returned. This is a deprecated mode of
204
 
        operation and will be removed in the future.
205
 
        :return: a dictionary of revision_id->revision_parents_list.
206
 
        """
207
 
        if 'evil' in debug.debug_flags:
208
 
            mutter_callsite(3,
209
 
                "get_revision_graph scales with size of history.")
210
 
        # special case NULL_REVISION
211
 
        if revision_id == _mod_revision.NULL_REVISION:
212
 
            return {}
213
 
        a_weave = self._get_revision_vf()
214
 
        if revision_id is None:
215
 
            return a_weave.get_graph()
216
 
        if revision_id not in a_weave:
217
 
            raise errors.NoSuchRevision(self, revision_id)
218
 
        else:
219
 
            # add what can be reached from revision_id
220
 
            return a_weave.get_graph([revision_id])
221
 
 
222
 
    @needs_read_lock
223
 
    def get_revision_graph_with_ghosts(self, revision_ids=None):
224
 
        """Return a graph of the revisions with ghosts marked as applicable.
225
 
 
226
 
        :param revision_ids: an iterable of revisions to graph or None for all.
227
 
        :return: a Graph object with the graph reachable from revision_ids.
228
 
        """
229
 
        if 'evil' in debug.debug_flags:
230
 
            mutter_callsite(3,
231
 
                "get_revision_graph_with_ghosts scales with size of history.")
232
 
        result = deprecated_graph.Graph()
233
 
        vf = self._get_revision_vf()
234
 
        versions = set(vf.versions())
235
 
        if not revision_ids:
236
 
            pending = set(self.all_revision_ids())
237
 
            required = set([])
238
 
        else:
239
 
            pending = set(revision_ids)
240
 
            # special case NULL_REVISION
241
 
            if _mod_revision.NULL_REVISION in pending:
242
 
                pending.remove(_mod_revision.NULL_REVISION)
243
 
            required = set(pending)
244
 
        done = set([])
245
 
        while len(pending):
246
 
            revision_id = pending.pop()
247
 
            if not revision_id in versions:
248
 
                if revision_id in required:
249
 
                    raise errors.NoSuchRevision(self, revision_id)
250
 
                # a ghost
251
 
                result.add_ghost(revision_id)
252
 
                # mark it as done so we don't try for it again.
253
 
                done.add(revision_id)
254
 
                continue
255
 
            parent_ids = vf.get_parents_with_ghosts(revision_id)
256
 
            for parent_id in parent_ids:
257
 
                # is this queued or done ?
258
 
                if (parent_id not in pending and
259
 
                    parent_id not in done):
260
 
                    # no, queue it.
261
 
                    pending.add(parent_id)
262
 
            result.add_node(revision_id, parent_ids)
263
 
            done.add(revision_id)
264
 
        return result
265
 
 
266
200
    def _get_revision_vf(self):
267
201
        """:return: a versioned file containing the revisions."""
268
202
        vf = self._revision_store.get_revision_file(self.get_transaction())
269
203
        return vf
270
204
 
271
 
    def _get_history_vf(self):
272
 
        """Get a versionedfile whose history graph reflects all revisions.
273
 
 
274
 
        For knit repositories, this is the revision knit.
275
 
        """
276
 
        return self._get_revision_vf()
277
 
 
278
205
    def has_revisions(self, revision_ids):
279
206
        """See Repository.has_revisions()."""
280
207
        result = set()
292
219
        reconciler.reconcile()
293
220
        return reconciler
294
221
    
295
 
    def revision_parents(self, revision_id):
296
 
        return self._get_revision_vf().get_parents(revision_id)
297
 
 
298
222
    def _make_parents_provider(self):
299
223
        return _KnitParentsProvider(self._get_revision_vf())
300
224
 
305
229
        :returns: an iterator yielding tuples of (revison-id, parents-in-index,
306
230
            parents-in-revision).
307
231
        """
308
 
        assert self.is_locked()
 
232
        if not self.is_locked():
 
233
            raise AssertionError()
309
234
        vf = self._get_revision_vf()
310
235
        for index_version in vf.versions():
311
236
            parents_according_to_index = tuple(vf.get_parents_with_ghosts(
363
288
            repo_transport,
364
289
            prefixed=False,
365
290
            file_mode=control_files._file_mode,
366
 
            versionedfile_class=knit.KnitVersionedFile,
 
291
            versionedfile_class=knit.make_file_knit,
367
292
            versionedfile_kwargs={'factory':knit.KnitPlainFactory()},
368
293
            )
369
294
 
374
299
            file_mode=control_files._file_mode,
375
300
            prefixed=False,
376
301
            precious=True,
377
 
            versionedfile_class=knit.KnitVersionedFile,
 
302
            versionedfile_class=knit.make_file_knit,
378
303
            versionedfile_kwargs={'delta':False,
379
304
                                  'factory':knit.KnitPlainFactory(),
380
305
                                 },
387
312
        return self._get_versioned_file_store('knits',
388
313
                                  transport,
389
314
                                  control_files,
390
 
                                  versionedfile_class=knit.KnitVersionedFile,
 
315
                                  versionedfile_class=knit.make_file_knit,
391
316
                                  versionedfile_kwargs={
392
317
                                      'create_parent_dir':True,
393
318
                                      'delay_create':True,
432
357
        """
433
358
        if not _found:
434
359
            format = RepositoryFormat.find_format(a_bzrdir)
435
 
            assert format.__class__ ==  self.__class__
436
360
        if _override_transport is not None:
437
361
            repo_transport = _override_transport
438
362
        else: