~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/weaverepo.py

  • Committer: Aaron Bentley
  • Date: 2009-03-24 15:47:32 UTC
  • mto: This revision was merged to the branch mainline in revision 4241.
  • Revision ID: aaron@aaronbentley.com-20090324154732-bwkvi4dx3o90a7dq
Add output, emit minimal inventory delta.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007-2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007, 2008 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
28
28
lazy_import(globals(), """
29
29
from bzrlib import (
30
30
    xml5,
31
 
    graph as _mod_graph,
32
31
    )
33
32
""")
34
33
from bzrlib import (
39
38
    lockdir,
40
39
    osutils,
41
40
    revision as _mod_revision,
42
 
    trace,
43
41
    urlutils,
44
42
    versionedfile,
45
43
    weave,
54
52
    RepositoryFormat,
55
53
    )
56
54
from bzrlib.store.text import TextStore
 
55
from bzrlib.trace import mutter
57
56
from bzrlib.tuned_gzip import GzipFile, bytes_to_gzip
58
57
from bzrlib.versionedfile import (
59
58
    AbsentContentFactory,
106
105
    def _all_possible_ids(self):
107
106
        """Return all the possible revisions that we could find."""
108
107
        if 'evil' in debug.debug_flags:
109
 
            trace.mutter_callsite(
110
 
                3, "_all_possible_ids scales with size of history.")
 
108
            mutter_callsite(3, "_all_possible_ids scales with size of history.")
111
109
        return [key[-1] for key in self.inventories.keys()]
112
110
 
113
111
    @needs_read_lock
177
175
        :param new_value: True to restore the default, False to disable making
178
176
                          working trees.
179
177
        """
180
 
        raise errors.RepositoryUpgradeRequired(self.user_url)
 
178
        raise errors.RepositoryUpgradeRequired(self.bzrdir.root_transport.base)
181
179
 
182
180
    def make_working_trees(self):
183
181
        """Returns the policy for making working trees on new branches."""
200
198
    def _all_possible_ids(self):
201
199
        """Return all the possible revisions that we could find."""
202
200
        if 'evil' in debug.debug_flags:
203
 
            trace.mutter_callsite(
204
 
                3, "_all_possible_ids scales with size of history.")
 
201
            mutter_callsite(3, "_all_possible_ids scales with size of history.")
205
202
        return [key[-1] for key in self.inventories.keys()]
206
203
 
207
204
    @needs_read_lock
269
266
    supports_tree_reference = False
270
267
    supports_ghosts = False
271
268
    supports_external_lookups = False
272
 
    supports_chks = False
273
269
    _fetch_order = 'topological'
274
270
    _fetch_reconcile = True
275
271
    fast_deltas = False
288
284
        weavefile.write_weave_v5(weave.Weave(), sio)
289
285
        empty_weave = sio.getvalue()
290
286
 
291
 
        trace.mutter('creating repository in %s.', a_bzrdir.transport.base)
 
287
        mutter('creating repository in %s.', a_bzrdir.transport.base)
292
288
 
293
289
        # FIXME: RBC 20060125 don't peek under the covers
294
290
        # NB: no need to escape relative paths that are url safe.
300
296
        try:
301
297
            transport.mkdir_multi(['revision-store', 'weaves'],
302
298
                mode=a_bzrdir._get_dir_mode())
303
 
            transport.put_bytes_non_atomic('inventory.weave', empty_weave,
304
 
                mode=a_bzrdir._get_file_mode())
 
299
            transport.put_bytes_non_atomic('inventory.weave', empty_weave)
305
300
        finally:
306
301
            control_files.unlock()
307
 
        repository = self.open(a_bzrdir, _found=True)
308
 
        self._run_post_repo_init_hooks(repository, a_bzrdir, shared)
309
 
        return repository
 
302
        return self.open(a_bzrdir, _found=True)
310
303
 
311
304
    def open(self, a_bzrdir, _found=False):
312
305
        """See RepositoryFormat.open()."""
321
314
        result.signatures = self._get_signatures(repo_transport, result)
322
315
        result.inventories = self._get_inventories(repo_transport, result)
323
316
        result.texts = self._get_texts(repo_transport, result)
324
 
        result.chk_bytes = None
325
317
        return result
326
318
 
 
319
    def check_conversion_target(self, target_format):
 
320
        pass
 
321
 
327
322
 
328
323
class RepositoryFormat4(PreSplitOutRepositoryFormat):
329
324
    """Bzr repository format 4.
479
474
 
480
475
    _versionedfile_class = weave.WeaveFile
481
476
    supports_ghosts = False
482
 
    supports_chks = False
483
 
 
484
477
    _fetch_order = 'topological'
485
478
    _fetch_reconcile = True
486
479
    fast_deltas = False
496
489
        """See RepositoryFormat.get_format_description()."""
497
490
        return "Weave repository format 7"
498
491
 
 
492
    def check_conversion_target(self, target_format):
 
493
        pass
 
494
 
499
495
    def _get_inventories(self, repo_transport, repo, name='inventory'):
500
496
        mapper = versionedfile.ConstantMapper(name)
501
497
        return versionedfile.ThunkedVersionedFiles(repo_transport,
528
524
        weavefile.write_weave_v5(weave.Weave(), sio)
529
525
        empty_weave = sio.getvalue()
530
526
 
531
 
        trace.mutter('creating repository in %s.', a_bzrdir.transport.base)
 
527
        mutter('creating repository in %s.', a_bzrdir.transport.base)
532
528
        dirs = ['revision-store', 'weaves']
533
529
        files = [('inventory.weave', StringIO(empty_weave)),
534
530
                 ]
558
554
        result.signatures = self._get_signatures(repo_transport, result)
559
555
        result.inventories = self._get_inventories(repo_transport, result)
560
556
        result.texts = self._get_texts(repo_transport, result)
561
 
        result.chk_bytes = None
562
557
        result._transport = repo_transport
563
558
        return result
564
559
 
668
663
            result[key] = parents
669
664
        return result
670
665
 
671
 
    def get_known_graph_ancestry(self, keys):
672
 
        """Get a KnownGraph instance with the ancestry of keys."""
673
 
        keys = self.keys()
674
 
        parent_map = self.get_parent_map(keys)
675
 
        kg = _mod_graph.KnownGraph(parent_map)
676
 
        return kg
677
 
 
678
666
    def get_record_stream(self, keys, sort_order, include_delta_closure):
679
667
        for key in keys:
680
668
            text, parents = self._load_text_parents(key)
692
680
            path, ext = os.path.splitext(relpath)
693
681
            if ext == '.gz':
694
682
                relpath = path
695
 
            if not relpath.endswith('.sig'):
 
683
            if '.sig' not in relpath:
696
684
                relpaths.add(relpath)
697
685
        paths = list(relpaths)
698
686
        return set([self._mapper.unmap(path) for path in paths])