~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_foreign.py

  • Committer: Jelmer Vernooij
  • Date: 2011-04-13 00:58:10 UTC
  • mto: (5777.7.2 bound-commit-lossy)
  • mto: This revision was merged to the branch mainline in revision 5791.
  • Revision ID: jelmer@samba.org-20110413005810-qc596vh42b0n3qdd
Add tests for lossy commit.

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 
98
101
            *args, **kwargs)
99
102
 
100
103
 
 
104
class DummyForeignCommitBuilder(repository.RootCommitBuilder):
 
105
 
 
106
    def _generate_revision_if_needed(self):
 
107
        self._new_revision_id = self.target.mapping.revision_id_foreign_to_bzr(
 
108
            (str(self._timestamp), str(self._timezone),
 
109
                str(self.target.revno())))
 
110
 
 
111
 
 
112
class DummyForeignVcsRepositoryFormat(groupcompress_repo.RepositoryFormat2a):
 
113
 
 
114
    def get_format_string(self):
 
115
        return "Dummy Foreign Vcs Repository"
 
116
 
 
117
    def get_format_description(self):
 
118
        return "Dummy Foreign Vcs Repository"
 
119
 
 
120
 
 
121
class DummyForeignVcsRepository(groupcompress_repo.CHKInventoryRepository,
 
122
    foreign.ForeignRepository):
 
123
 
 
124
    def __init__(self, _format, a_bzrdir, control_files):
 
125
        super(DummyForeignVcsRepository, self).__init__(_format, a_bzrdir,
 
126
            control_files, DummyForeignCommitBuilder, _format._serializer)
 
127
 
 
128
 
101
129
class InterToDummyVcsBranch(branch.GenericInterBranch,
102
130
                            foreign.InterToForeignBranch):
103
131
 
208
236
    def get_branch_format(self):
209
237
        return DummyForeignVcsBranchFormat()
210
238
 
 
239
    @property
 
240
    def repository_format(self):
 
241
        return DummyForeignVcsRepositoryFormat()
 
242
 
211
243
    def initialize_on_transport(self, transport):
212
244
        """Initialize a new bzrdir in the base directory of a Transport."""
213
245
        # Since we don't have a .bzr directory, inherit the
245
277
            raise errors.NoColocatedBranchSupport(self)
246
278
        return self._format.get_branch_format().open(self, _found=True)
247
279
 
 
280
    def open_repository(self, unsupported=False):
 
281
        return DummyForeignVcsRepository(DummyForeignVcsRepositoryFormat(),
 
282
            self, self._control_files)
 
283
 
 
284
    find_repository = open_repository
 
285
 
248
286
    def cloning_metadir(self, stacked=False):
249
287
        """Produce a metadir suitable for cloning with."""
250
288
        return bzrdir.format_registry.make_bzrdir("default")