~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_foreign.py

  • Committer: Vincent Ladeuil
  • Date: 2011-06-15 11:36:05 UTC
  • mto: This revision was merged to the branch mainline in revision 5975.
  • Revision ID: v.ladeuil+lp@free.fr-20110615113605-p7zyyfry9wy1hquc
Make ContentConflict resolution more robust

Show diffs side-by-side

added added

removed removed

Lines of Context:
101
101
        branch.BzrBranch6.__init__(self, _format, _control_files, a_bzrdir,
102
102
            *args, **kwargs)
103
103
 
104
 
    def _get_checkout_format(self, lightweight=False):
 
104
    def _get_checkout_format(self):
105
105
        """Return the most suitable metadir for a checkout of this branch.
106
106
        Weaves are used if this branch's repository uses weaves.
107
107
        """
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
170
163
        result.old_revno, result.old_revid = self.target.last_revision_info()
171
164
        self.source.lock_read()
172
165
        try:
173
 
            graph = self.source.repository.get_graph()
174
166
            # 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)
 
167
            my_history = self.target.revision_history()
177
168
            if stop_revision is None:
178
169
                stop_revision = self.source.last_revision()
179
 
            their_history = branch_history(graph, stop_revision)
 
170
            their_history = list(
 
171
                self.source.repository.iter_reverse_revision_history(stop_revision))
 
172
            their_history.reverse()
180
173
            if their_history[:min(len(my_history), len(their_history))] != my_history:
181
174
                raise errors.DivergedBranches(self.target, self.source)
182
175
            todo = their_history[len(my_history):]
188
181
                    return (tree.get_file(file_id), None)
189
182
                tree.get_file_with_stat = get_file_with_stat
190
183
                new_revid = self.target.mapping.revision_id_foreign_to_bzr(
191
 
                    (str(rev.timestamp), str(rev.timezone),
 
184
                    (str(rev.timestamp), str(rev.timezone), 
192
185
                        str(self.target.revno())))
193
186
                parent_revno, parent_revid= self.target.last_revision_info()
194
187
                if parent_revid == revision.NULL_REVISION:
228
221
    def get_format_string(self):
229
222
        return "Branch for Testing"
230
223
 
231
 
    @property
232
 
    def _matchingbzrdir(self):
233
 
        return DummyForeignVcsDirFormat()
 
224
    def __init__(self):
 
225
        super(DummyForeignVcsBranchFormat, self).__init__()
 
226
        self._matchingbzrdir = DummyForeignVcsDirFormat()
234
227
 
235
228
    def open(self, a_bzrdir, name=None, _found=False, ignore_fallbacks=False,
236
229
            found_repository=None):
471
464
            format=DummyForeignVcsDirFormat())
472
465
        target_tree.branch.lock_write()
473
466
        try:
474
 
            pushresult = source_tree.branch.push(
475
 
                target_tree.branch, lossy=True)
 
467
            pushresult = source_tree.branch.push(target_tree.branch, lossy=True)
476
468
        finally:
477
469
            target_tree.branch.unlock()
478
470
        self.assertEquals(revision.NULL_REVISION, pushresult.old_revid)