~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_foreign.py

  • Committer: Martin Packman
  • Date: 2012-01-05 09:50:04 UTC
  • mfrom: (6424 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6426.
  • Revision ID: martin.packman@canonical.com-20120105095004-mia9xb7y0efmto0v
Merge bzr.dev to resolve conflicts in bzrlib.builtins

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
101
105
        branch.BzrBranch6.__init__(self, _format, _control_files, a_bzrdir,
102
106
            *args, **kwargs)
103
107
 
104
 
    def _get_checkout_format(self):
 
108
    def _get_checkout_format(self, lightweight=False):
105
109
        """Return the most suitable metadir for a checkout of this branch.
106
110
        Weaves are used if this branch's repository uses weaves.
107
111
        """
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):
303
315
        self.root_transport.put_bytes(".bzr", "foo")
304
316
        return super(DummyForeignVcsDir, self).create_workingtree()
305
317
 
306
 
    def open_branch(self, name=None, unsupported=False, ignore_fallbacks=True):
 
318
    def open_branch(self, name=None, unsupported=False, ignore_fallbacks=True,
 
319
            possible_transports=None):
307
320
        if name is not None:
308
321
            raise errors.NoColocatedBranchSupport(self)
309
322
        return self._format.get_branch_format().open(self, _found=True)
465
478
            format=DummyForeignVcsDirFormat())
466
479
        target_tree.branch.lock_write()
467
480
        try:
468
 
            pushresult = source_tree.branch.push(target_tree.branch, lossy=True)
 
481
            pushresult = source_tree.branch.push(
 
482
                target_tree.branch, lossy=True)
469
483
        finally:
470
484
            target_tree.branch.unlock()
471
485
        self.assertEquals(revision.NULL_REVISION, pushresult.old_revid)