/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 branch.py

Move dpush logic onto InterBranch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
152
152
        return "%s(%r, %r)" % (self.__class__.__name__, self.repository.base, self.name)
153
153
 
154
154
    def dpull(self, source, stop_revision=None):
155
 
        if stop_revision is None:
156
 
            stop_revision = source.last_revision()
157
 
        # FIXME: Check for diverged branches
158
 
        refs = { "refs/heads/master": stop_revision }
159
 
        for name, revid in source.tags.get_tag_dict().iteritems():
160
 
            if source.repository.has_revision(revid):
161
 
                refs["refs/tags/%s" % name] = revid
162
 
        revidmap, new_refs = self.repository.dfetch_refs(source.repository, 
163
 
                refs)
164
 
        if revidmap != {}:
165
 
            self.generate_revision_history(revidmap[stop_revision])
166
 
        return revidmap
 
155
        return branch.InterBranch.get(source, self).lossy_push()
167
156
 
168
157
    def generate_revision_history(self, revid, old_revid=None):
169
158
        # FIXME: Check that old_revid is in the ancestry of revid
298
287
        self._show_tag_conficts(to_file)
299
288
 
300
289
 
301
 
class InterGitGenericBranch(branch.InterBranch):
 
290
class InterFromGitBranch(branch.InterBranch):
302
291
    """InterBranch implementation that pulls from Git into bzr."""
303
292
 
304
293
    @classmethod
383
372
        return result
384
373
 
385
374
 
386
 
 
387
 
 
388
 
branch.InterBranch.register_optimiser(InterGitGenericBranch)
389
 
 
390
 
 
391
375
class InterGitRemoteLocalBranch(branch.InterBranch):
392
376
    """InterBranch implementation that pulls between Git branches."""
393
377
 
419
403
        result.new_revid = self.target.last_revision()
420
404
        return result
421
405
 
 
406
    
 
407
class InterToGitBranch(branch.InterBranch):
 
408
    """InterBranch implementation that pulls from Git into bzr."""
 
409
 
 
410
    @classmethod
 
411
    def is_compatible(self, source, target):
 
412
        return (not isinstance(source, GitBranch) and 
 
413
                isinstance(target, GitBranch))
 
414
 
 
415
    def lossy_push(self, stop_revision=None):
 
416
        if stop_revision is None:
 
417
            stop_revision = self.source.last_revision()
 
418
        # FIXME: Check for diverged branches
 
419
        refs = { "refs/heads/master": stop_revision }
 
420
        for name, revid in self.source.tags.get_tag_dict().iteritems():
 
421
            if self.source.repository.has_revision(revid):
 
422
                refs["refs/tags/%s" % name] = revid
 
423
        revidmap, new_refs = self.target.repository.dfetch_refs(
 
424
            self.source.repository, refs)
 
425
        if revidmap != {}:
 
426
            self.target.generate_revision_history(revidmap[stop_revision])
 
427
        return revidmap
 
428
 
422
429
 
423
430
branch.InterBranch.register_optimiser(InterGitRemoteLocalBranch)
 
431
branch.InterBranch.register_optimiser(InterFromGitBranch)
 
432
branch.InterBranch.register_optimiser(InterToGitBranch)