~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/weaverepo.py

  • Committer: John Arbash Meinel
  • Date: 2009-03-24 16:35:22 UTC
  • mto: This revision was merged to the branch mainline in revision 4198.
  • Revision ID: john@arbash-meinel.com-20090324163522-p0p9s5ahzsnem1oc
A few notes, some updates from ian.

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
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
"""Deprecated weave-based repository formats.
18
18
 
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
 
    fast_deltas = False
276
271
 
277
272
    def initialize(self, a_bzrdir, shared=False, _internal=False):
278
273
        """Create a weave repository."""
288
283
        weavefile.write_weave_v5(weave.Weave(), sio)
289
284
        empty_weave = sio.getvalue()
290
285
 
291
 
        trace.mutter('creating repository in %s.', a_bzrdir.transport.base)
 
286
        mutter('creating repository in %s.', a_bzrdir.transport.base)
292
287
 
293
288
        # FIXME: RBC 20060125 don't peek under the covers
294
289
        # NB: no need to escape relative paths that are url safe.
300
295
        try:
301
296
            transport.mkdir_multi(['revision-store', 'weaves'],
302
297
                mode=a_bzrdir._get_dir_mode())
303
 
            transport.put_bytes_non_atomic('inventory.weave', empty_weave,
304
 
                mode=a_bzrdir._get_file_mode())
 
298
            transport.put_bytes_non_atomic('inventory.weave', empty_weave)
305
299
        finally:
306
300
            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
 
301
        return self.open(a_bzrdir, _found=True)
310
302
 
311
303
    def open(self, a_bzrdir, _found=False):
312
304
        """See RepositoryFormat.open()."""
321
313
        result.signatures = self._get_signatures(repo_transport, result)
322
314
        result.inventories = self._get_inventories(repo_transport, result)
323
315
        result.texts = self._get_texts(repo_transport, result)
324
 
        result.chk_bytes = None
325
316
        return result
326
317
 
 
318
    def check_conversion_target(self, target_format):
 
319
        pass
 
320
 
327
321
 
328
322
class RepositoryFormat4(PreSplitOutRepositoryFormat):
329
323
    """Bzr repository format 4.
479
473
 
480
474
    _versionedfile_class = weave.WeaveFile
481
475
    supports_ghosts = False
482
 
    supports_chks = False
483
 
 
484
476
    _fetch_order = 'topological'
485
477
    _fetch_reconcile = True
486
 
    fast_deltas = False
487
478
    @property
488
479
    def _serializer(self):
489
480
        return xml5.serializer_v5
496
487
        """See RepositoryFormat.get_format_description()."""
497
488
        return "Weave repository format 7"
498
489
 
 
490
    def check_conversion_target(self, target_format):
 
491
        pass
 
492
 
499
493
    def _get_inventories(self, repo_transport, repo, name='inventory'):
500
494
        mapper = versionedfile.ConstantMapper(name)
501
495
        return versionedfile.ThunkedVersionedFiles(repo_transport,
528
522
        weavefile.write_weave_v5(weave.Weave(), sio)
529
523
        empty_weave = sio.getvalue()
530
524
 
531
 
        trace.mutter('creating repository in %s.', a_bzrdir.transport.base)
 
525
        mutter('creating repository in %s.', a_bzrdir.transport.base)
532
526
        dirs = ['revision-store', 'weaves']
533
527
        files = [('inventory.weave', StringIO(empty_weave)),
534
528
                 ]
558
552
        result.signatures = self._get_signatures(repo_transport, result)
559
553
        result.inventories = self._get_inventories(repo_transport, result)
560
554
        result.texts = self._get_texts(repo_transport, result)
561
 
        result.chk_bytes = None
562
555
        result._transport = repo_transport
563
556
        return result
564
557
 
668
661
            result[key] = parents
669
662
        return result
670
663
 
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
664
    def get_record_stream(self, keys, sort_order, include_delta_closure):
679
665
        for key in keys:
680
666
            text, parents = self._load_text_parents(key)
692
678
            path, ext = os.path.splitext(relpath)
693
679
            if ext == '.gz':
694
680
                relpath = path
695
 
            if not relpath.endswith('.sig'):
 
681
            if '.sig' not in relpath:
696
682
                relpaths.add(relpath)
697
683
        paths = list(relpaths)
698
684
        return set([self._mapper.unmap(path) for path in paths])