~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-05-26 20:30:53 UTC
  • mfrom: (5920 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5924.
  • Revision ID: v.ladeuil+lp@free.fr-20110526203053-hbjn6yuzwg03wnuv
MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
110
110
    def import_last_revision_info_and_tags(self, source, revno, revid,
111
111
                                           lossy=False):
112
112
        interbranch = InterToDummyVcsBranch(source, self)
 
113
        result = interbranch.push(stop_revision=revid, lossy=True)
113
114
        if lossy:
114
 
            result = interbranch.lossy_push(revid)
115
115
            revid = result.revidmap[revid]
116
 
        else:
117
 
            interbranch.push(revid)
118
116
        return (revno, revid)
119
117
 
120
118
 
150
148
        return "Dummy Foreign Vcs Repository"
151
149
 
152
150
 
153
 
class InterToDummyVcsBranch(branch.GenericInterBranch,
154
 
                            foreign.InterToForeignBranch):
 
151
class InterToDummyVcsBranch(branch.GenericInterBranch):
155
152
 
156
153
    @staticmethod
157
154
    def is_compatible(source, target):
158
155
        return isinstance(target, DummyForeignVcsBranch)
159
156
 
160
 
    def push(self, overwrite=False, stop_revision=None):
161
 
        raise errors.NoRoundtrippingSupport(self.source, self.target)
162
 
 
163
 
    def lossy_push(self, stop_revision=None):
 
157
    def push(self, overwrite=False, stop_revision=None, lossy=False):
 
158
        if not lossy:
 
159
            raise errors.NoRoundtrippingSupport(self.source, self.target)
164
160
        result = branch.BranchPushResult()
165
161
        result.source_branch = self.source
166
162
        result.target_branch = self.target
171
167
            my_history = self.target.revision_history()
172
168
            if stop_revision is None:
173
169
                stop_revision = self.source.last_revision()
174
 
            their_history = list(self.source.repository.iter_reverse_revision_history(stop_revision))
 
170
            their_history = list(
 
171
                self.source.repository.iter_reverse_revision_history(stop_revision))
175
172
            their_history.reverse()
176
173
            if their_history[:min(len(my_history), len(their_history))] != my_history:
177
174
                raise errors.DivergedBranches(self.target, self.source)
453
450
        source_tree = self.make_branch_and_tree("source")
454
451
        target_tree = self.make_branch_and_tree("target", 
455
452
            format=DummyForeignVcsDirFormat())
456
 
        pushresult = source_tree.branch.lossy_push(target_tree.branch)
 
453
        pushresult = source_tree.branch.push(target_tree.branch, lossy=True)
457
454
        self.assertEquals(revision.NULL_REVISION, pushresult.old_revid)
458
455
        self.assertEquals(revision.NULL_REVISION, pushresult.new_revid)
459
456
        self.assertEquals({}, pushresult.revidmap)
467
464
            format=DummyForeignVcsDirFormat())
468
465
        target_tree.branch.lock_write()
469
466
        try:
470
 
            pushresult = source_tree.branch.lossy_push(target_tree.branch)
 
467
            pushresult = source_tree.branch.push(target_tree.branch, lossy=True)
471
468
        finally:
472
469
            target_tree.branch.unlock()
473
470
        self.assertEquals(revision.NULL_REVISION, pushresult.old_revid)