diff options
Diffstat (limited to 'project.py')
-rw-r--r-- | project.py | 43 |
1 files changed, 32 insertions, 11 deletions
@@ -779,9 +779,8 @@ class Project(object): | |||
779 | 779 | ||
780 | all = self.bare_ref.all | 780 | all = self.bare_ref.all |
781 | if (R_HEADS + name) in all: | 781 | if (R_HEADS + name) in all: |
782 | cmd = ['checkout', name, '--'] | ||
783 | return GitCommand(self, | 782 | return GitCommand(self, |
784 | cmd, | 783 | ['checkout', name, '--'], |
785 | capture_stdout = True, | 784 | capture_stdout = True, |
786 | capture_stderr = True).Wait() == 0 | 785 | capture_stderr = True).Wait() == 0 |
787 | 786 | ||
@@ -815,9 +814,8 @@ class Project(object): | |||
815 | branch.Save() | 814 | branch.Save() |
816 | return True | 815 | return True |
817 | 816 | ||
818 | cmd = ['checkout', '-b', branch.name, rev] | ||
819 | if GitCommand(self, | 817 | if GitCommand(self, |
820 | cmd, | 818 | ['checkout', '-b', branch.name, rev], |
821 | capture_stdout = True, | 819 | capture_stdout = True, |
822 | capture_stderr = True).Wait() == 0: | 820 | capture_stderr = True).Wait() == 0: |
823 | branch.Save() | 821 | branch.Save() |
@@ -827,16 +825,39 @@ class Project(object): | |||
827 | def CheckoutBranch(self, name): | 825 | def CheckoutBranch(self, name): |
828 | """Checkout a local topic branch. | 826 | """Checkout a local topic branch. |
829 | """ | 827 | """ |
828 | rev = R_HEADS + name | ||
829 | head = self.work_git.GetHead() | ||
830 | if head == rev: | ||
831 | # Already on the branch | ||
832 | # | ||
833 | return True | ||
830 | 834 | ||
831 | # Be sure the branch exists | 835 | all = self.bare_ref.all |
832 | try: | 836 | try: |
833 | tip_rev = self.bare_git.rev_parse(R_HEADS + name) | 837 | revid = all[rev] |
834 | except GitError: | 838 | except KeyError: |
835 | return False; | 839 | # Branch does not exist in this project |
840 | # | ||
841 | return False | ||
842 | |||
843 | if head.startswith(R_HEADS): | ||
844 | try: | ||
845 | head = all[head] | ||
846 | except KeyError: | ||
847 | head = None | ||
848 | |||
849 | if head == revid: | ||
850 | # Same revision; just update HEAD to point to the new | ||
851 | # target branch, but otherwise take no other action. | ||
852 | # | ||
853 | _lwrite(os.path.join(self.worktree, '.git', HEAD), | ||
854 | 'ref: %s%s\n' % (R_HEADS, name)) | ||
855 | return True | ||
836 | 856 | ||
837 | # Do the checkout | 857 | return GitCommand(self, |
838 | cmd = ['checkout', name, '--'] | 858 | ['checkout', name, '--'], |
839 | return GitCommand(self, cmd).Wait() == 0 | 859 | capture_stdout = True, |
860 | capture_stderr = True).Wait() == 0 | ||
840 | 861 | ||
841 | def AbandonBranch(self, name): | 862 | def AbandonBranch(self, name): |
842 | """Destroy a local topic branch. | 863 | """Destroy a local topic branch. |