~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_foreign.py

  • Committer: Patch Queue Manager
  • Date: 2011-10-06 08:34:03 UTC
  • mfrom: (6191.2.1 843900-url-nameerror)
  • Revision ID: pqm@pqm.ubuntu.com-20111006083403-jnsw0exlirg01aed
(mbp) error message without traceback on invalid ubuntu/debian url (bug
 843900) (Martin Pool)

Show diffs side-by-side

added added

removed removed

Lines of Context:
148
148
        return "Dummy Foreign Vcs Repository"
149
149
 
150
150
 
151
 
def branch_history(graph, revid):
152
 
    ret = list(graph.iter_lefthand_ancestry(revid,
153
 
        (revision.NULL_REVISION,)))
154
 
    ret.reverse()
155
 
    return ret
156
 
 
157
 
 
158
151
class InterToDummyVcsBranch(branch.GenericInterBranch):
159
152
 
160
153
    @staticmethod
172
165
        try:
173
166
            graph = self.source.repository.get_graph()
174
167
            # This just handles simple cases, but that's good enough for tests
175
 
            my_history = branch_history(self.target.repository.get_graph(),
176
 
                result.old_revid)
 
168
            my_history = self.target.revision_history()
177
169
            if stop_revision is None:
178
170
                stop_revision = self.source.last_revision()
179
 
            their_history = branch_history(graph, stop_revision)
 
171
            their_history = list(graph.iter_lefthand_ancestry(stop_revision,
 
172
                (revision.NULL_REVISION,)))
 
173
            their_history.reverse()
180
174
            if their_history[:min(len(my_history), len(their_history))] != my_history:
181
175
                raise errors.DivergedBranches(self.target, self.source)
182
176
            todo = their_history[len(my_history):]
228
222
    def get_format_string(self):
229
223
        return "Branch for Testing"
230
224
 
231
 
    @property
232
 
    def _matchingbzrdir(self):
233
 
        return DummyForeignVcsDirFormat()
 
225
    def __init__(self):
 
226
        super(DummyForeignVcsBranchFormat, self).__init__()
 
227
        self._matchingbzrdir = DummyForeignVcsDirFormat()
234
228
 
235
229
    def open(self, a_bzrdir, name=None, _found=False, ignore_fallbacks=False,
236
230
            found_repository=None):
471
465
            format=DummyForeignVcsDirFormat())
472
466
        target_tree.branch.lock_write()
473
467
        try:
474
 
            pushresult = source_tree.branch.push(
475
 
                target_tree.branch, lossy=True)
 
468
            pushresult = source_tree.branch.push(target_tree.branch, lossy=True)
476
469
        finally:
477
470
            target_tree.branch.unlock()
478
471
        self.assertEquals(revision.NULL_REVISION, pushresult.old_revid)