/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: Vincent Ladeuil
  • Date: 2011-11-24 15:48:29 UTC
  • mfrom: (6289 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6337.
  • Revision ID: v.ladeuil+lp@free.fr-20111124154829-avowjpsxdl8yp2vz
merge trunk resolving conflicts

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