~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_versionedfile.py

  • Committer: Andrew Bennetts
  • Date: 2011-02-07 04:14:29 UTC
  • mfrom: (5535.4.26 fetch-all-tags-309682)
  • mto: This revision was merged to the branch mainline in revision 5648.
  • Revision ID: andrew.bennetts@canonical.com-20110207041429-3kc1blj34rvvxod9
Merge fetch-all-tags-309682.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006-2011 Canonical Ltd
2
2
#
3
3
# Authors:
4
4
#   Johan Rydberg <jrydberg@gnu.org>
21
21
# TODO: might be nice to create a versionedfile with some type of corruption
22
22
# considered typical and check that it can be detected/corrected.
23
23
 
 
24
from gzip import GzipFile
24
25
from itertools import chain, izip
25
26
from StringIO import StringIO
26
27
 
37
38
from bzrlib.errors import (
38
39
                           RevisionNotPresent,
39
40
                           RevisionAlreadyPresent,
40
 
                           WeaveParentMismatch
41
41
                           )
42
42
from bzrlib.knit import (
43
43
    cleanup_pack_knit,
44
44
    make_file_factory,
45
45
    make_pack_factory,
46
 
    KnitAnnotateFactory,
47
 
    KnitPlainFactory,
48
46
    )
49
47
from bzrlib.tests import (
50
48
    TestCase,
53
51
    TestSkipped,
54
52
    )
55
53
from bzrlib.tests.http_utils import TestCaseWithWebserver
56
 
from bzrlib.trace import mutter
57
54
from bzrlib.transport.memory import MemoryTransport
58
 
from bzrlib.tsort import topo_sort
59
 
from bzrlib.tuned_gzip import GzipFile
60
55
import bzrlib.versionedfile as versionedfile
61
56
from bzrlib.versionedfile import (
62
57
    ConstantMapper,
66
61
    make_versioned_files_factory,
67
62
    )
68
63
from bzrlib.weave import WeaveFile
69
 
from bzrlib.weavefile import read_weave, write_weave
 
64
from bzrlib.weavefile import write_weave
70
65
from bzrlib.tests.scenarios import load_tests_apply_scenarios
71
66
 
72
67
 
756
751
        self.assertEquals(('references_ghost', 'line_c\n'), origins[2])
757
752
 
758
753
    def test_readonly_mode(self):
759
 
        t = transport.get_transport(self.get_url('.'))
 
754
        t = self.get_transport()
760
755
        factory = self.get_factory()
761
756
        vf = factory('id', t, 0777, create=True, access_mode='w')
762
757
        vf = factory('id', t, access_mode='r')
787
782
class TestWeave(TestCaseWithMemoryTransport, VersionedFileTestMixIn):
788
783
 
789
784
    def get_file(self, name='foo'):
790
 
        return WeaveFile(name, transport.get_transport(self.get_url('.')),
 
785
        return WeaveFile(name, self.get_transport(),
791
786
                         create=True,
792
787
                         get_scope=self.get_transaction)
793
788
 
794
789
    def get_file_corrupted_text(self):
795
 
        w = WeaveFile('foo', transport.get_transport(self.get_url('.')),
 
790
        w = WeaveFile('foo', self.get_transport(),
796
791
                      create=True,
797
792
                      get_scope=self.get_transaction)
798
793
        w.add_lines('v1', [], ['hello\n'])
828
823
        return w
829
824
 
830
825
    def reopen_file(self, name='foo', create=False):
831
 
        return WeaveFile(name, transport.get_transport(self.get_url('.')),
 
826
        return WeaveFile(name, self.get_transport(),
832
827
                         create=create,
833
828
                         get_scope=self.get_transaction)
834
829
 
836
831
        self.assertRaises(errors.NoSuchFile,
837
832
                          WeaveFile,
838
833
                          'foo',
839
 
                          transport.get_transport(self.get_url('.')),
 
834
                          self.get_transport(),
840
835
                          get_scope=self.get_transaction)
841
836
 
842
837
    def get_factory(self):
930
925
class TestWeaveHTTP(TestCaseWithWebserver, TestReadonlyHttpMixin):
931
926
 
932
927
    def get_file(self):
933
 
        return WeaveFile('foo', transport.get_transport(self.get_url('.')),
 
928
        return WeaveFile('foo', self.get_transport(),
934
929
                         create=True,
935
930
                         get_scope=self.get_transaction)
936
931
 
1182
1177
class TestWeaveMerge(TestCaseWithMemoryTransport, MergeCasesMixin):
1183
1178
 
1184
1179
    def get_file(self, name='foo'):
1185
 
        return WeaveFile(name, transport.get_transport(self.get_url('.')),
 
1180
        return WeaveFile(name, self.get_transport(),
1186
1181
                         create=True)
1187
1182
 
1188
1183
    def log_contents(self, w):