~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/weaverepo.py

  • Committer: Frank Aspell
  • Date: 2009-02-22 16:54:02 UTC
  • mto: This revision was merged to the branch mainline in revision 4256.
  • Revision ID: frankaspell@googlemail.com-20090222165402-2myrucnu7er5w4ha
Fixing various typos

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,
83
82
 
84
83
        def get_store(name, compressed=True, prefixed=False):
85
84
            # FIXME: This approach of assuming stores are all entirely compressed
86
 
            # or entirely uncompressed is tidy, but breaks upgrade from
87
 
            # some existing branches where there's a mixture; we probably
 
85
            # or entirely uncompressed is tidy, but breaks upgrade from 
 
86
            # some existing branches where there's a mixture; we probably 
88
87
            # still want the option to look for both.
89
88
            relpath = self._escape(name)
90
89
            store = TextStore(a_bzrdir.transport.clone(relpath),
96
95
        # not broken out yet because the controlweaves|inventory_store
97
96
        # and texts bits are still different.
98
97
        if isinstance(_format, RepositoryFormat4):
99
 
            # cannot remove these - there is still no consistent api
 
98
            # cannot remove these - there is still no consistent api 
100
99
            # which allows access to this old info.
101
100
            self.inventory_store = get_store('inventory-store')
102
101
            self._text_store = get_store('text-store')
103
102
        super(AllInOneRepository, self).__init__(_format, a_bzrdir, a_bzrdir._control_files)
 
103
        self._fetch_order = 'topological'
 
104
        self._fetch_reconcile = True
104
105
 
105
106
    @needs_read_lock
106
107
    def _all_possible_ids(self):
107
108
        """Return all the possible revisions that we could find."""
108
109
        if 'evil' in debug.debug_flags:
109
 
            trace.mutter_callsite(
110
 
                3, "_all_possible_ids scales with size of history.")
 
110
            mutter_callsite(3, "_all_possible_ids scales with size of history.")
111
111
        return [key[-1] for key in self.inventories.keys()]
112
112
 
113
113
    @needs_read_lock
114
114
    def _all_revision_ids(self):
115
 
        """Returns a list of all the revision ids in the repository.
 
115
        """Returns a list of all the revision ids in the repository. 
116
116
 
117
 
        These are in as much topological order as the underlying store can
 
117
        These are in as much topological order as the underlying store can 
118
118
        present: for weaves ghosts may lead to a lack of correctness until
119
119
        the reweave updates the parents list.
120
120
        """
177
177
        :param new_value: True to restore the default, False to disable making
178
178
                          working trees.
179
179
        """
180
 
        raise errors.RepositoryUpgradeRequired(self.user_url)
 
180
        raise errors.RepositoryUpgradeRequired(self.bzrdir.root_transport.base)
181
181
 
182
182
    def make_working_trees(self):
183
183
        """Returns the policy for making working trees on new branches."""
194
194
 
195
195
    def __init__(self, _format, a_bzrdir, control_files):
196
196
        super(WeaveMetaDirRepository, self).__init__(_format, a_bzrdir, control_files)
 
197
        self._fetch_order = 'topological'
 
198
        self._fetch_reconcile = True
197
199
        self._serializer = _format._serializer
198
200
 
199
201
    @needs_read_lock
200
202
    def _all_possible_ids(self):
201
203
        """Return all the possible revisions that we could find."""
202
204
        if 'evil' in debug.debug_flags:
203
 
            trace.mutter_callsite(
204
 
                3, "_all_possible_ids scales with size of history.")
 
205
            mutter_callsite(3, "_all_possible_ids scales with size of history.")
205
206
        return [key[-1] for key in self.inventories.keys()]
206
207
 
207
208
    @needs_read_lock
208
209
    def _all_revision_ids(self):
209
 
        """Returns a list of all the revision ids in the repository.
 
210
        """Returns a list of all the revision ids in the repository. 
210
211
 
211
 
        These are in as much topological order as the underlying store can
 
212
        These are in as much topological order as the underlying store can 
212
213
        present: for weaves ghosts may lead to a lack of correctness until
213
214
        the reweave updates the parents list.
214
215
        """
269
270
    supports_tree_reference = False
270
271
    supports_ghosts = False
271
272
    supports_external_lookups = False
272
 
    supports_chks = False
273
 
    _fetch_order = 'topological'
274
 
    _fetch_reconcile = True
275
 
    fast_deltas = False
276
273
 
277
274
    def initialize(self, a_bzrdir, shared=False, _internal=False):
278
275
        """Create a weave repository."""
282
279
        if not _internal:
283
280
            # always initialized when the bzrdir is.
284
281
            return self.open(a_bzrdir, _found=True)
285
 
 
 
282
        
286
283
        # Create an empty weave
287
284
        sio = StringIO()
288
285
        weavefile.write_weave_v5(weave.Weave(), sio)
289
286
        empty_weave = sio.getvalue()
290
287
 
291
 
        trace.mutter('creating repository in %s.', a_bzrdir.transport.base)
292
 
 
 
288
        mutter('creating repository in %s.', a_bzrdir.transport.base)
 
289
        
293
290
        # FIXME: RBC 20060125 don't peek under the covers
294
291
        # NB: no need to escape relative paths that are url safe.
295
292
        control_files = lockable_files.LockableFiles(a_bzrdir.transport,
300
297
        try:
301
298
            transport.mkdir_multi(['revision-store', 'weaves'],
302
299
                mode=a_bzrdir._get_dir_mode())
303
 
            transport.put_bytes_non_atomic('inventory.weave', empty_weave,
304
 
                mode=a_bzrdir._get_file_mode())
 
300
            transport.put_bytes_non_atomic('inventory.weave', empty_weave)
305
301
        finally:
306
302
            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
 
303
        return self.open(a_bzrdir, _found=True)
310
304
 
311
305
    def open(self, a_bzrdir, _found=False):
312
306
        """See RepositoryFormat.open()."""
321
315
        result.signatures = self._get_signatures(repo_transport, result)
322
316
        result.inventories = self._get_inventories(repo_transport, result)
323
317
        result.texts = self._get_texts(repo_transport, result)
324
 
        result.chk_bytes = None
325
318
        return result
326
319
 
 
320
    def check_conversion_target(self, target_format):
 
321
        pass
 
322
 
327
323
 
328
324
class RepositoryFormat4(PreSplitOutRepositoryFormat):
329
325
    """Bzr repository format 4.
339
335
 
340
336
    _matchingbzrdir = bzrdir.BzrDirFormat4()
341
337
 
 
338
    def __init__(self):
 
339
        super(RepositoryFormat4, self).__init__()
 
340
        self._fetch_order = 'topological'
 
341
        self._fetch_reconcile = True
 
342
 
342
343
    def get_format_description(self):
343
344
        """See RepositoryFormat.get_format_description()."""
344
345
        return "Repository format 4"
351
352
        """Format 4 is not supported.
352
353
 
353
354
        It is not supported because the model changed from 4 to 5 and the
354
 
        conversion logic is expensive - so doing it on the fly was not
 
355
        conversion logic is expensive - so doing it on the fly was not 
355
356
        feasible.
356
357
        """
357
358
        return False
390
391
    def _serializer(self):
391
392
        return xml5.serializer_v5
392
393
 
 
394
    def __init__(self):
 
395
        super(RepositoryFormat5, self).__init__()
 
396
        self._fetch_order = 'topological'
 
397
        self._fetch_reconcile = True
 
398
 
393
399
    def get_format_description(self):
394
400
        """See RepositoryFormat.get_format_description()."""
395
401
        return "Weave repository format 5"
396
 
 
 
402
    
397
403
    def network_name(self):
398
404
        """The network name for this format is the control dirs disk label."""
399
405
        return self._matchingbzrdir.get_format_string()
435
441
    def _serializer(self):
436
442
        return xml5.serializer_v5
437
443
 
 
444
    def __init__(self):
 
445
        super(RepositoryFormat6, self).__init__()
 
446
        self._fetch_order = 'topological'
 
447
        self._fetch_reconcile = True
 
448
 
438
449
    def get_format_description(self):
439
450
        """See RepositoryFormat.get_format_description()."""
440
451
        return "Weave repository format 6"
479
490
 
480
491
    _versionedfile_class = weave.WeaveFile
481
492
    supports_ghosts = False
482
 
    supports_chks = False
483
 
 
484
 
    _fetch_order = 'topological'
485
 
    _fetch_reconcile = True
486
 
    fast_deltas = False
487
493
    @property
488
494
    def _serializer(self):
489
495
        return xml5.serializer_v5
496
502
        """See RepositoryFormat.get_format_description()."""
497
503
        return "Weave repository format 7"
498
504
 
 
505
    def check_conversion_target(self, target_format):
 
506
        pass
 
507
 
499
508
    def _get_inventories(self, repo_transport, repo, name='inventory'):
500
509
        mapper = versionedfile.ConstantMapper(name)
501
510
        return versionedfile.ThunkedVersionedFiles(repo_transport,
528
537
        weavefile.write_weave_v5(weave.Weave(), sio)
529
538
        empty_weave = sio.getvalue()
530
539
 
531
 
        trace.mutter('creating repository in %s.', a_bzrdir.transport.base)
 
540
        mutter('creating repository in %s.', a_bzrdir.transport.base)
532
541
        dirs = ['revision-store', 'weaves']
533
 
        files = [('inventory.weave', StringIO(empty_weave)),
 
542
        files = [('inventory.weave', StringIO(empty_weave)), 
534
543
                 ]
535
544
        utf8_files = [('format', self.get_format_string())]
536
 
 
 
545
 
537
546
        self._upload_blank_content(a_bzrdir, dirs, files, utf8_files, shared)
538
547
        return self.open(a_bzrdir=a_bzrdir, _found=True)
539
548
 
540
549
    def open(self, a_bzrdir, _found=False, _override_transport=None):
541
550
        """See RepositoryFormat.open().
542
 
 
 
551
        
543
552
        :param _override_transport: INTERNAL USE ONLY. Allows opening the
544
553
                                    repository at a slightly different url
545
554
                                    than normal. I.e. during 'upgrade'.
558
567
        result.signatures = self._get_signatures(repo_transport, result)
559
568
        result.inventories = self._get_inventories(repo_transport, result)
560
569
        result.texts = self._get_texts(repo_transport, result)
561
 
        result.chk_bytes = None
562
570
        result._transport = repo_transport
563
571
        return result
564
572
 
667
675
                continue
668
676
            result[key] = parents
669
677
        return result
670
 
 
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
    
678
679
    def get_record_stream(self, keys, sort_order, include_delta_closure):
679
680
        for key in keys:
680
681
            text, parents = self._load_text_parents(key)
692
693
            path, ext = os.path.splitext(relpath)
693
694
            if ext == '.gz':
694
695
                relpath = path
695
 
            if not relpath.endswith('.sig'):
 
696
            if '.sig' not in relpath:
696
697
                relpaths.add(relpath)
697
698
        paths = list(relpaths)
698
699
        return set([self._mapper.unmap(path) for path in paths])
714
715
                continue
715
716
            result[key] = None
716
717
        return result
717
 
 
 
718
    
718
719
    def get_record_stream(self, keys, sort_order, include_delta_closure):
719
720
        for key in keys:
720
721
            text = self._load_text(key)