diff options
Diffstat (limited to 'project.py')
-rw-r--r-- | project.py | 32 |
1 files changed, 31 insertions, 1 deletions
@@ -727,12 +727,34 @@ class Project: | |||
727 | return None | 727 | return None |
728 | 728 | ||
729 | def IsRebaseInProgress(self): | 729 | def IsRebaseInProgress(self): |
730 | """Returns true if a rebase or "am" is in progress""" | ||
731 | # "rebase-apply" is used for "git rebase". | ||
732 | # "rebase-merge" is used for "git am". | ||
730 | return ( | 733 | return ( |
731 | os.path.exists(self.work_git.GetDotgitPath("rebase-apply")) | 734 | os.path.exists(self.work_git.GetDotgitPath("rebase-apply")) |
732 | or os.path.exists(self.work_git.GetDotgitPath("rebase-merge")) | 735 | or os.path.exists(self.work_git.GetDotgitPath("rebase-merge")) |
733 | or os.path.exists(os.path.join(self.worktree, ".dotest")) | 736 | or os.path.exists(os.path.join(self.worktree, ".dotest")) |
734 | ) | 737 | ) |
735 | 738 | ||
739 | def IsCherryPickInProgress(self): | ||
740 | """Returns True if a cherry-pick is in progress.""" | ||
741 | return os.path.exists(self.work_git.GetDotgitPath("CHERRY_PICK_HEAD")) | ||
742 | |||
743 | def _AbortRebase(self): | ||
744 | """Abort ongoing rebase, cherry-pick or patch apply (am). | ||
745 | |||
746 | If no rebase, cherry-pick or patch apply was in progress, this method | ||
747 | ignores the status and continues. | ||
748 | """ | ||
749 | |||
750 | def _git(*args): | ||
751 | # Ignore return code, in case there was no rebase in progress. | ||
752 | GitCommand(self, *args, log_as_error=False).Wait() | ||
753 | |||
754 | _git("cherry-pick", "--abort") | ||
755 | _git("rebase", "--abort") | ||
756 | _git("am", "--abort") | ||
757 | |||
736 | def IsDirty(self, consider_untracked=True): | 758 | def IsDirty(self, consider_untracked=True): |
737 | """Is the working directory modified in some way?""" | 759 | """Is the working directory modified in some way?""" |
738 | self.work_git.update_index( | 760 | self.work_git.update_index( |
@@ -1583,7 +1605,15 @@ class Project: | |||
1583 | if branch is None or syncbuf.detach_head: | 1605 | if branch is None or syncbuf.detach_head: |
1584 | # Currently on a detached HEAD. The user is assumed to | 1606 | # Currently on a detached HEAD. The user is assumed to |
1585 | # not have any local modifications worth worrying about. | 1607 | # not have any local modifications worth worrying about. |
1586 | if self.IsRebaseInProgress(): | 1608 | rebase_in_progress = ( |
1609 | self.IsRebaseInProgress() or self.IsCherryPickInProgress() | ||
1610 | ) | ||
1611 | if rebase_in_progress and force_checkout: | ||
1612 | self._AbortRebase() | ||
1613 | rebase_in_progress = ( | ||
1614 | self.IsRebaseInProgress() or self.IsCherryPickInProgress() | ||
1615 | ) | ||
1616 | if rebase_in_progress: | ||
1587 | fail(_PriorSyncFailedError(project=self.name)) | 1617 | fail(_PriorSyncFailedError(project=self.name)) |
1588 | return | 1618 | return |
1589 | 1619 | ||