/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_foreign.py

  • Committer: Jelmer Vernooij
  • Date: 2011-04-16 15:01:57 UTC
  • mfrom: (5791 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5800.
  • Revision ID: jelmer@samba.org-20110416150157-5rgye9nnc8tic098
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
    foreign,
27
27
    lockable_files,
28
28
    lockdir,
 
29
    repository,
29
30
    revision,
30
31
    tests,
31
32
    trace,
32
33
    )
33
34
 
 
35
from bzrlib.repofmt import groupcompress_repo
 
36
 
34
37
# This is the dummy foreign revision control system, used 
35
38
# mainly here in the testsuite to test the foreign VCS infrastructure.
36
39
# It is basically standard Bazaar with some minor modifications to 
92
95
        self._base = a_bzrdir.transport.base
93
96
        self._ignore_fallbacks = False
94
97
        self.bzrdir = a_bzrdir
95
 
        foreign.ForeignBranch.__init__(self, 
 
98
        foreign.ForeignBranch.__init__(self,
96
99
            DummyForeignVcsMapping(DummyForeignVcs()))
97
 
        branch.BzrBranch6.__init__(self, _format, _control_files, a_bzrdir, 
 
100
        branch.BzrBranch6.__init__(self, _format, _control_files, a_bzrdir,
98
101
            *args, **kwargs)
99
102
 
100
103
 
 
104
class DummyForeignCommitBuilder(repository.RootCommitBuilder):
 
105
 
 
106
    def _generate_revision_if_needed(self):
 
107
        mapping = DummyForeignVcsMapping(DummyForeignVcs())
 
108
        if self._lossy:
 
109
            self._new_revision_id = mapping.revision_id_foreign_to_bzr(
 
110
                (str(self._timestamp), str(self._timezone), "UNKNOWN"))
 
111
            self.random_revid = False
 
112
        else:
 
113
            self._new_revision_id = self._gen_revision_id()
 
114
            self.random_revid = True
 
115
 
 
116
 
 
117
class DummyForeignVcsRepository(groupcompress_repo.CHKInventoryRepository,
 
118
    foreign.ForeignRepository):
 
119
    """Dummy foreign vcs repository."""
 
120
 
 
121
 
 
122
class DummyForeignVcsRepositoryFormat(groupcompress_repo.RepositoryFormat2a):
 
123
 
 
124
    repository_class = DummyForeignVcsRepository
 
125
    _commit_builder_class = DummyForeignCommitBuilder
 
126
 
 
127
    def get_format_string(self):
 
128
        return "Dummy Foreign Vcs Repository"
 
129
 
 
130
    def get_format_description(self):
 
131
        return "Dummy Foreign Vcs Repository"
 
132
 
 
133
 
101
134
class InterToDummyVcsBranch(branch.GenericInterBranch,
102
135
                            foreign.InterToForeignBranch):
103
136
 
208
241
    def get_branch_format(self):
209
242
        return DummyForeignVcsBranchFormat()
210
243
 
 
244
    @property
 
245
    def repository_format(self):
 
246
        return DummyForeignVcsRepositoryFormat()
 
247
 
211
248
    def initialize_on_transport(self, transport):
212
249
        """Initialize a new bzrdir in the base directory of a Transport."""
213
250
        # Since we don't have a .bzr directory, inherit the
240
277
        self._control_files = lockable_files.LockableFiles(self.transport,
241
278
            "lock", lockable_files.TransportLock)
242
279
 
 
280
    def create_workingtree(self):
 
281
        # dirstate requires a ".bzr" entry to exist
 
282
        self.root_transport.put_bytes(".bzr", "foo")
 
283
        return super(DummyForeignVcsDir, self).create_workingtree()
 
284
 
243
285
    def open_branch(self, name=None, unsupported=False, ignore_fallbacks=True):
244
286
        if name is not None:
245
287
            raise errors.NoColocatedBranchSupport(self)
265
307
    controldir.ControlDirFormat.register_prober(DummyForeignProber)
266
308
    testcase.addCleanup(controldir.ControlDirFormat.unregister_prober,
267
309
        DummyForeignProber)
 
310
    repository.format_registry.register(DummyForeignVcsRepositoryFormat())
 
311
    testcase.addCleanup(repository.format_registry.remove,
 
312
            DummyForeignVcsRepositoryFormat())
268
313
    # We need to register the optimiser to make the dummy appears really
269
314
    # different from a regular bzr repository.
270
315
    branch.InterBranch.register_optimiser(InterToDummyVcsBranch)
303
348
        reg = foreign.ForeignVcsRegistry()
304
349
        vcs = DummyForeignVcs()
305
350
        reg.register("dummy", vcs, "Dummy VCS")
306
 
        self.assertEquals((("some", "foreign", "revid"), DummyForeignVcsMapping(vcs)),
307
 
                          reg.parse_revision_id("dummy-v1:some-foreign-revid"))
 
351
        self.assertEquals((
 
352
            ("some", "foreign", "revid"), DummyForeignVcsMapping(vcs)),
 
353
            reg.parse_revision_id("dummy-v1:some-foreign-revid"))
308
354
 
309
355
 
310
356
class ForeignRevisionTests(tests.TestCase):