~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-18 23:21:01 UTC
  • mfrom: (5799 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5800.
  • Revision ID: jelmer@samba.org-20110418232101-utgj6599ow9ny9nh
merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
100
100
        branch.BzrBranch6.__init__(self, _format, _control_files, a_bzrdir,
101
101
            *args, **kwargs)
102
102
 
 
103
    def _get_checkout_format(self):
 
104
        """Return the most suitable metadir for a checkout of this branch.
 
105
        Weaves are used if this branch's repository uses weaves.
 
106
        """
 
107
        return self.bzrdir.checkout_metadir()
 
108
 
 
109
    def import_last_revision_info_and_tags(self, source, revno, revid,
 
110
                                           lossy=False):
 
111
        interbranch = InterToDummyVcsBranch(source, self)
 
112
        if lossy:
 
113
            result = interbranch.lossy_push(revid)
 
114
            revid = result.revidmap[revid]
 
115
        else:
 
116
            interbranch.push(revid)
 
117
        return (revno, revid)
 
118
 
103
119
 
104
120
class DummyForeignCommitBuilder(repository.RootCommitBuilder):
105
121
 
109
125
            self._new_revision_id = mapping.revision_id_foreign_to_bzr(
110
126
                (str(self._timestamp), str(self._timezone), "UNKNOWN"))
111
127
            self.random_revid = False
 
128
        elif self._new_revision_id is not None:
 
129
            self.random_revid = False
112
130
        else:
113
131
            self._new_revision_id = self._gen_revision_id()
114
132
            self.random_revid = True
150
168
        try:
151
169
            # This just handles simple cases, but that's good enough for tests
152
170
            my_history = self.target.revision_history()
153
 
            their_history = self.source.revision_history()
 
171
            if stop_revision is None:
 
172
                stop_revision = self.source.last_revision()
 
173
            their_history = list(self.source.repository.iter_reverse_revision_history(stop_revision))
 
174
            their_history.reverse()
154
175
            if their_history[:min(len(my_history), len(their_history))] != my_history:
155
176
                raise errors.DivergedBranches(self.target, self.source)
156
177
            todo = their_history[len(my_history):]
206
227
        super(DummyForeignVcsBranchFormat, self).__init__()
207
228
        self._matchingbzrdir = DummyForeignVcsDirFormat()
208
229
 
209
 
    def open(self, a_bzrdir, name=None, _found=False, found_repository=None):
 
230
    def open(self, a_bzrdir, name=None, _found=False, ignore_fallbacks=False,
 
231
            found_repository=None):
210
232
        if not _found:
211
233
            raise NotImplementedError
212
234
        try:
291
313
        """Produce a metadir suitable for cloning with."""
292
314
        return bzrdir.format_registry.make_bzrdir("default")
293
315
 
 
316
    def checkout_metadir(self):
 
317
        return self.cloning_metadir()
 
318
 
294
319
    def sprout(self, url, revision_id=None, force_new_repo=False,
295
320
               recurse='down', possible_transports=None,
296
321
               accelerator_tree=None, hardlink=False, stacked=False,
310
335
    repository.format_registry.register(DummyForeignVcsRepositoryFormat())
311
336
    testcase.addCleanup(repository.format_registry.remove,
312
337
            DummyForeignVcsRepositoryFormat())
 
338
    branch.format_registry.register(DummyForeignVcsBranchFormat())
 
339
    testcase.addCleanup(branch.format_registry.remove,
 
340
            DummyForeignVcsBranchFormat())
313
341
    # We need to register the optimiser to make the dummy appears really
314
342
    # different from a regular bzr repository.
315
343
    branch.InterBranch.register_optimiser(InterToDummyVcsBranch)