/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

Set refs/heads/master if no ref is set yet.

Show diffs side-by-side

added added

removed removed

Lines of Context:
637
637
    def _get_new_refs(self, stop_revision=None):
638
638
        if stop_revision is None:
639
639
            stop_revision = self.source.last_revision()
640
 
        refs = {
641
 
            branch_name_to_ref(self.target.name, "refs/heads/master"): stop_revision }
 
640
        main_ref = self.target.ref or "refs/heads/master"
 
641
        refs = { main_ref: stop_revision }
642
642
        for name, revid in self.source.tags.get_tag_dict().iteritems():
643
643
            if self.source.repository.has_revision(revid):
644
644
                refs[tag_name_to_ref(name)] = revid
645
 
        return refs
 
645
        return refs, main_ref
646
646
 
647
647
    def pull(self, overwrite=False, stop_revision=None, local=False,
648
648
             possible_transports=None):
653
653
        # FIXME: Check for diverged branches
654
654
        old_refs = self.target.repository._git.get_refs()
655
655
        refs = dict(old_refs)
656
 
        refs.update(self._get_new_refs(stop_revision))
 
656
        new_refs, main_ref = self._get_new_refs(stop_revision)
 
657
        refs.update(new_refs)
657
658
        self.target.repository.fetch_refs(self.source.repository, refs)
658
659
        result.old_revid = self.target.lookup_foreign_revision_id(
659
 
            old_refs.get(self.target.ref, ZERO_SHA))
660
 
        result.new_revid = refs[self.target.ref]
 
660
            old_refs.get(main_ref, ZERO_SHA))
 
661
        result.new_revid = refs[main_ref]
661
662
        return result
662
663
 
663
664
    def push(self, overwrite=False, stop_revision=None,
669
670
        # FIXME: Check for diverged branches
670
671
        old_refs = self.target.repository._git.get_refs()
671
672
        refs = dict(old_refs)
672
 
        refs.update(self._get_new_refs(stop_revision))
 
673
        new_refs, main_ref = self._get_new_refs(stop_revision)
 
674
        refs.update(new_refs)
673
675
        self.target.repository.fetch_refs(self.source.repository, refs)
674
676
        result.old_revid = self.target.lookup_foreign_revision_id(
675
 
            old_refs.get(self.target.ref, ZERO_SHA))
676
 
        result.new_revid = refs[self.target.ref]
 
677
            old_refs.get(main_ref, ZERO_SHA))
 
678
        result.new_revid = refs[main_ref]
677
679
        return result
678
680
 
679
681
    def lossy_push(self, stop_revision=None):
682
684
        result.source_branch = self.source
683
685
        result.target_branch = self.target
684
686
        # FIXME: Check for diverged branches
685
 
        refs = self._get_new_refs(stop_revision)
 
687
        refs, main_ref = self._get_new_refs(stop_revision)
686
688
        result.revidmap, old_refs, new_refs = self.target.repository.dfetch_refs(
687
689
            self.source.repository, refs)
688
690
        result.old_revid = self.target.lookup_foreign_revision_id(
689
691
            old_refs.get(self.target.ref, ZERO_SHA))
690
692
        result.new_revid = self.target.lookup_foreign_revision_id(
691
 
            new_refs[self.target.ref])
 
693
            new_refs[main_ref])
692
694
        return result
693
695
 
694
696