/breezy/unstable

To get this branch, use:
bzr branch https://code.breezy-vcs.org/breezy/unstable

« back to all changes in this revision

Viewing changes to breezy/plugins/weave_fmt/repository.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-24 01:39:33 UTC
  • mfrom: (3815.3776.6)
  • Revision ID: jelmer@jelmer.uk-20170524013933-ir4y4tqtrsiz2ka2
New upstream snapshot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
import gzip
26
26
import os
27
 
from cStringIO import StringIO
28
27
 
29
 
from bzrlib.lazy_import import lazy_import
 
28
from ...lazy_import import lazy_import
30
29
lazy_import(globals(), """
31
30
import itertools
32
31
 
33
 
from bzrlib import (
 
32
from breezy import (
34
33
    xml5,
35
34
    graph as _mod_graph,
36
35
    ui,
37
36
    )
38
37
""")
39
 
from bzrlib import (
 
38
from ... import (
40
39
    debug,
41
40
    errors,
42
41
    lockable_files,
50
49
    weave,
51
50
    weavefile,
52
51
    )
53
 
from bzrlib.decorators import needs_read_lock, needs_write_lock
54
 
from bzrlib.repository import (
 
52
from ...decorators import needs_read_lock, needs_write_lock
 
53
from ...repository import (
55
54
    InterRepository,
56
55
    RepositoryFormatMetaDir,
57
56
    )
58
 
from bzrlib.store.text import TextStore
59
 
from bzrlib.versionedfile import (
 
57
from ...sixish import (
 
58
    BytesIO,
 
59
    )
 
60
from ...store.text import TextStore
 
61
from ...versionedfile import (
60
62
    AbsentContentFactory,
61
63
    FulltextContentFactory,
62
64
    VersionedFiles,
63
65
    )
64
 
from bzrlib.vf_repository import (
 
66
from ...vf_repository import (
65
67
    InterSameDataRepository,
66
68
    VersionedFileCommitBuilder,
67
69
    VersionedFileRepository,
70
72
    MetaDirVersionedFileRepositoryFormat,
71
73
    )
72
74
 
73
 
from bzrlib.plugins.weave_fmt import bzrdir as weave_bzrdir
 
75
from . import bzrdir as weave_bzrdir
74
76
 
75
77
 
76
78
class AllInOneRepository(VersionedFileRepository):
292
294
            return self.open(a_bzrdir, _found=True)
293
295
 
294
296
        # Create an empty weave
295
 
        sio = StringIO()
 
297
        sio = BytesIO()
296
298
        weavefile.write_weave_v5(weave.Weave(), sio)
297
299
        empty_weave = sio.getvalue()
298
300
 
373
375
        return None
374
376
 
375
377
    def _get_revisions(self, repo_transport, repo):
376
 
        from bzrlib.plugins.weave_fmt.xml4 import serializer_v4
 
378
        from .xml4 import serializer_v4
377
379
        return RevisionTextStore(repo_transport.clone('revision-store'),
378
380
            serializer_v4, True, versionedfile.PrefixMapper(),
379
381
            repo.is_locked, repo.is_write_locked)
542
544
                       repository.
543
545
        """
544
546
        # Create an empty weave
545
 
        sio = StringIO()
 
547
        sio = BytesIO()
546
548
        weavefile.write_weave_v5(weave.Weave(), sio)
547
549
        empty_weave = sio.getvalue()
548
550
 
549
551
        trace.mutter('creating repository in %s.', a_bzrdir.transport.base)
550
552
        dirs = ['revision-store', 'weaves']
551
 
        files = [('inventory.weave', StringIO(empty_weave)),
 
553
        files = [('inventory.weave', BytesIO(empty_weave)),
552
554
                 ]
553
555
        utf8_files = [('format', self.get_format_string())]
554
556
 
656
658
            else:
657
659
                return None
658
660
        if compressed:
659
 
            text = gzip.GzipFile(mode='rb', fileobj=StringIO(text)).read()
 
661
            text = gzip.GzipFile(mode='rb', fileobj=BytesIO(text)).read()
660
662
        return text
661
663
 
662
664
    def _map(self, key):
716
718
            if not relpath.endswith('.sig'):
717
719
                relpaths.add(relpath)
718
720
        paths = list(relpaths)
719
 
        return set([self._mapper.unmap(path) for path in paths])
 
721
        return {self._mapper.unmap(path) for path in paths}
720
722
 
721
723
 
722
724
class SignatureTextStore(TextVersionedFiles):
757
759
                continue
758
760
            relpaths.add(relpath[:-4])
759
761
        paths = list(relpaths)
760
 
        return set([self._mapper.unmap(path) for path in paths])
 
762
        return {self._mapper.unmap(path) for path in paths}
761
763
 
762
764
 
763
765
class InterWeaveRepo(InterSameDataRepository):
878
880
 
879
881
 
880
882
def get_extra_interrepo_test_combinations():
881
 
    from bzrlib.repofmt import knitrepo
 
883
    from ...repofmt import knitrepo
882
884
    return [(InterRepository, RepositoryFormat5(),
883
885
        knitrepo.RepositoryFormatKnit3())]