~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_foreign.py

  • Committer: Jelmer Vernooij
  • Date: 2011-05-16 13:39:39 UTC
  • mto: (5923.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 5925.
  • Revision ID: jelmer@samba.org-20110516133939-8u1pc9utas3uw1lt
Require a unicode prompt to be passed into all methods that prompt.

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)
114
113
        if lossy:
 
114
            result = interbranch.lossy_push(revid)
115
115
            revid = result.revidmap[revid]
 
116
        else:
 
117
            interbranch.push(revid)
116
118
        return (revno, revid)
117
119
 
118
120
 
148
150
        return "Dummy Foreign Vcs Repository"
149
151
 
150
152
 
151
 
class InterToDummyVcsBranch(branch.GenericInterBranch):
 
153
class InterToDummyVcsBranch(branch.GenericInterBranch,
 
154
                            foreign.InterToForeignBranch):
152
155
 
153
156
    @staticmethod
154
157
    def is_compatible(source, target):
155
158
        return isinstance(target, DummyForeignVcsBranch)
156
159
 
157
 
    def push(self, overwrite=False, stop_revision=None, lossy=False):
158
 
        if not lossy:
159
 
            raise errors.NoRoundtrippingSupport(self.source, self.target)
 
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):
160
164
        result = branch.BranchPushResult()
161
165
        result.source_branch = self.source
162
166
        result.target_branch = self.target
163
167
        result.old_revno, result.old_revid = self.target.last_revision_info()
164
168
        self.source.lock_read()
165
169
        try:
166
 
            graph = self.source.repository.get_graph()
167
170
            # This just handles simple cases, but that's good enough for tests
168
171
            my_history = self.target.revision_history()
169
172
            if stop_revision is None:
170
173
                stop_revision = self.source.last_revision()
171
 
            their_history = list(graph.iter_lefthand_ancestry(stop_revision,
172
 
                (revision.NULL_REVISION,)))
 
174
            their_history = list(self.source.repository.iter_reverse_revision_history(stop_revision))
173
175
            their_history.reverse()
174
176
            if their_history[:min(len(my_history), len(their_history))] != my_history:
175
177
                raise errors.DivergedBranches(self.target, self.source)
182
184
                    return (tree.get_file(file_id), None)
183
185
                tree.get_file_with_stat = get_file_with_stat
184
186
                new_revid = self.target.mapping.revision_id_foreign_to_bzr(
185
 
                    (str(rev.timestamp), str(rev.timezone),
 
187
                    (str(rev.timestamp), str(rev.timezone), 
186
188
                        str(self.target.revno())))
187
189
                parent_revno, parent_revid= self.target.last_revision_info()
188
190
                if parent_revid == revision.NULL_REVISION:
451
453
        source_tree = self.make_branch_and_tree("source")
452
454
        target_tree = self.make_branch_and_tree("target", 
453
455
            format=DummyForeignVcsDirFormat())
454
 
        pushresult = source_tree.branch.push(target_tree.branch, lossy=True)
 
456
        pushresult = source_tree.branch.lossy_push(target_tree.branch)
455
457
        self.assertEquals(revision.NULL_REVISION, pushresult.old_revid)
456
458
        self.assertEquals(revision.NULL_REVISION, pushresult.new_revid)
457
459
        self.assertEquals({}, pushresult.revidmap)
465
467
            format=DummyForeignVcsDirFormat())
466
468
        target_tree.branch.lock_write()
467
469
        try:
468
 
            pushresult = source_tree.branch.push(target_tree.branch, lossy=True)
 
470
            pushresult = source_tree.branch.lossy_push(target_tree.branch)
469
471
        finally:
470
472
            target_tree.branch.unlock()
471
473
        self.assertEquals(revision.NULL_REVISION, pushresult.old_revid)