/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: 2012-01-30 14:12:36 UTC
  • mfrom: (6437.3.28 2.5)
  • mto: This revision was merged to the branch mainline in revision 6522.
  • Revision ID: jelmer@samba.org-20120130141236-66k8qj1he6q2nq3r
Merge 2.5 branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
91
91
class DummyForeignVcsBranch(branch.BzrBranch6,foreign.ForeignBranch):
92
92
    """A Dummy VCS Branch."""
93
93
 
 
94
    @property
 
95
    def user_transport(self):
 
96
        return self.bzrdir.user_transport
 
97
 
94
98
    def __init__(self, _format, _control_files, a_bzrdir, *args, **kwargs):
95
99
        self._format = _format
96
100
        self._base = a_bzrdir.transport.base
141
145
    repository_class = DummyForeignVcsRepository
142
146
    _commit_builder_class = DummyForeignCommitBuilder
143
147
 
144
 
    def get_format_string(self):
 
148
    @classmethod
 
149
    def get_format_string(cls):
145
150
        return "Dummy Foreign Vcs Repository"
146
151
 
147
152
    def get_format_description(self):
148
153
        return "Dummy Foreign Vcs Repository"
149
154
 
150
155
 
 
156
def branch_history(graph, revid):
 
157
    ret = list(graph.iter_lefthand_ancestry(revid,
 
158
        (revision.NULL_REVISION,)))
 
159
    ret.reverse()
 
160
    return ret
 
161
 
 
162
 
151
163
class InterToDummyVcsBranch(branch.GenericInterBranch):
152
164
 
153
165
    @staticmethod
165
177
        try:
166
178
            graph = self.source.repository.get_graph()
167
179
            # This just handles simple cases, but that's good enough for tests
168
 
            my_history = self.target.revision_history()
 
180
            my_history = branch_history(self.target.repository.get_graph(),
 
181
                result.old_revid)
169
182
            if stop_revision is None:
170
183
                stop_revision = self.source.last_revision()
171
 
            their_history = list(graph.iter_lefthand_ancestry(stop_revision,
172
 
                (revision.NULL_REVISION,)))
173
 
            their_history.reverse()
 
184
            their_history = branch_history(graph, stop_revision)
174
185
            if their_history[:min(len(my_history), len(their_history))] != my_history:
175
186
                raise errors.DivergedBranches(self.target, self.source)
176
187
            todo = their_history[len(my_history):]
190
201
                else:
191
202
                    parent_revids = [parent_revid]
192
203
                builder = self.target.get_commit_builder(parent_revids, 
193
 
                        self.target.get_config(), rev.timestamp,
 
204
                        self.target.get_config_stack(), rev.timestamp,
194
205
                        rev.timezone, rev.committer, rev.properties,
195
206
                        new_revid)
196
207
                try:
219
230
 
220
231
class DummyForeignVcsBranchFormat(branch.BzrBranchFormat6):
221
232
 
222
 
    def get_format_string(self):
 
233
    @classmethod
 
234
    def get_format_string(cls):
223
235
        return "Branch for Testing"
224
236
 
225
 
    def __init__(self):
226
 
        super(DummyForeignVcsBranchFormat, self).__init__()
227
 
        self._matchingbzrdir = DummyForeignVcsDirFormat()
 
237
    @property
 
238
    def _matchingbzrdir(self):
 
239
        return DummyForeignVcsDirFormat()
228
240
 
229
241
    def open(self, a_bzrdir, name=None, _found=False, ignore_fallbacks=False,
230
242
            found_repository=None):
 
243
        if name is None:
 
244
            name = a_bzrdir._get_selected_branch()
231
245
        if not _found:
232
246
            raise NotImplementedError
233
247
        try:
239
253
            return DummyForeignVcsBranch(_format=self,
240
254
                              _control_files=control_files,
241
255
                              a_bzrdir=a_bzrdir,
242
 
                              _repository=found_repository)
 
256
                              _repository=found_repository,
 
257
                              name=name)
243
258
        except errors.NoSuchFile:
244
259
            raise errors.NotBranchError(path=transport.base)
245
260
 
303
318
        self.root_transport.put_bytes(".bzr", "foo")
304
319
        return super(DummyForeignVcsDir, self).create_workingtree()
305
320
 
306
 
    def open_branch(self, name=None, unsupported=False, ignore_fallbacks=True):
307
 
        if name is not None:
 
321
    def open_branch(self, name=None, unsupported=False, ignore_fallbacks=True,
 
322
            possible_transports=None):
 
323
        if name is None:
 
324
            name = self._get_selected_branch()
 
325
        if name != "":
308
326
            raise errors.NoColocatedBranchSupport(self)
309
327
        return self._format.get_branch_format().open(self, _found=True)
310
328
 
465
483
            format=DummyForeignVcsDirFormat())
466
484
        target_tree.branch.lock_write()
467
485
        try:
468
 
            pushresult = source_tree.branch.push(target_tree.branch, lossy=True)
 
486
            pushresult = source_tree.branch.push(
 
487
                target_tree.branch, lossy=True)
469
488
        finally:
470
489
            target_tree.branch.unlock()
471
490
        self.assertEquals(revision.NULL_REVISION, pushresult.old_revid)