Show More
@@ -675,35 +675,25 b' class gitsubrepo(abstractsubrepo):' | |||
|
675 | 675 | a map from revision to branches''' |
|
676 | 676 | branch2rev = {} |
|
677 | 677 | rev2branch = {} |
|
678 | tracking = {} | |
|
678 | 679 | current, err = self._gitdir(['symbolic-ref', 'HEAD', '--quiet']) |
|
679 | 680 | if err: |
|
680 | 681 | current = None |
|
681 | 682 | |
|
682 | 683 | out = self._gitcommand(['for-each-ref', '--format', |
|
683 | '%(objectname) %(refname)']) | |
|
684 | '%(objectname) %(refname) %(upstream) end']) | |
|
684 | 685 | for line in out.split('\n'): |
|
685 | revision, ref = line.split(' ') | |
|
686 | revision, ref, upstream = line.split(' ')[:3] | |
|
686 | 687 | if ref.startswith('refs/tags/'): |
|
687 | 688 | continue |
|
688 | 689 | if ref.startswith('refs/remotes/') and ref.endswith('/HEAD'): |
|
689 | 690 | continue # ignore remote/HEAD redirects |
|
690 | 691 | branch2rev[ref] = revision |
|
691 | 692 | rev2branch.setdefault(revision, []).append(ref) |
|
692 | return current, branch2rev, rev2branch | |
|
693 | ||
|
694 | def _gittracking(self, branches): | |
|
695 |
|
|
|
696 | # assumes no more than one local tracking branch for each remote | |
|
697 | tracking = {} | |
|
698 | for b in branches: | |
|
699 | if b.startswith('refs/remotes/'): | |
|
700 | continue | |
|
701 | remote = self._gitcommand(['config', 'branch.%s.remote' % b]) | |
|
702 | if remote: | |
|
703 | ref = self._gitcommand(['config', 'branch.%s.merge' % b]) | |
|
704 | tracking['refs/remotes/%s/%s' % | |
|
705 | (remote, ref.split('/', 2)[2])] = b | |
|
706 | return tracking | |
|
693 | if upstream: | |
|
694 | # assumes no more than one local tracking branch for a remote | |
|
695 | tracking[upstream] = ref | |
|
696 | return current, branch2rev, rev2branch, tracking | |
|
707 | 697 | |
|
708 | 698 | def _fetch(self, source, revision): |
|
709 | 699 | if not os.path.exists('%s/.git' % self._path): |
@@ -741,7 +731,7 b' class gitsubrepo(abstractsubrepo):' | |||
|
741 | 731 | return |
|
742 | 732 | elif self._gitstate() == revision: |
|
743 | 733 | return |
|
744 | current, branch2rev, rev2branch = self._gitbranchmap() | |
|
734 | current, branch2rev, rev2branch, tracking = self._gitbranchmap() | |
|
745 | 735 | |
|
746 | 736 | def rawcheckout(): |
|
747 | 737 | # no branch to checkout, check it out with no branch |
@@ -767,7 +757,6 b' class gitsubrepo(abstractsubrepo):' | |||
|
767 | 757 | self._gitcommand(['checkout', firstlocalbranch]) |
|
768 | 758 | return |
|
769 | 759 | |
|
770 | tracking = self._gittracking(branch2rev.keys()) | |
|
771 | 760 | # choose a remote branch already tracked if possible |
|
772 | 761 | remote = branches[0] |
|
773 | 762 | if remote not in tracking: |
@@ -820,7 +809,7 b' class gitsubrepo(abstractsubrepo):' | |||
|
820 | 809 | |
|
821 | 810 | def push(self, force): |
|
822 | 811 | # if a branch in origin contains the revision, nothing to do |
|
823 | current, branch2rev, rev2branch = self._gitbranchmap() | |
|
812 | current, branch2rev, rev2branch, tracking = self._gitbranchmap() | |
|
824 | 813 | if self._state[1] in rev2branch: |
|
825 | 814 | for b in rev2branch[self._state[1]]: |
|
826 | 815 | if b.startswith('refs/remotes/origin/'): |
General Comments 0
You need to be logged in to leave comments.
Login now