mirror of
https://github.com/mhagger/git-imerge.git
synced 2024-09-21 04:28:11 +03:00
Disallow --goal=rebase if any branch commits are merges.
Later should either implement this functionality or, alternatively, offer a --force option or a --goal=rebase-discarding-merges.
This commit is contained in:
parent
bc241e1786
commit
75ddb1174e
24
git-imerge
24
git-imerge
@ -1257,6 +1257,21 @@ class MergeState(Block):
|
||||
except CalledProcessError:
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def _check_no_merges(commits):
|
||||
multiparent_commits = [
|
||||
commit
|
||||
for commit in commits
|
||||
if len(get_commit_parents(commit)) > 1
|
||||
]
|
||||
if multiparent_commits:
|
||||
raise Failure(
|
||||
'The following commits on the to-be-merged branch are merge commits:\n'
|
||||
' %s\n'
|
||||
'--goal=\'rebase\' is not yet supported for branches that include merges.\n'
|
||||
% ('\n '.join(multiparent_commits),)
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def initialize(name, goal, tip1, tip2):
|
||||
"""Create and return a new MergeState object."""
|
||||
@ -1289,6 +1304,9 @@ class MergeState(Block):
|
||||
'There are no commits on %r that are not already in %r' % (tip2, tip1)
|
||||
)
|
||||
|
||||
if goal == 'rebase':
|
||||
MergeState._check_no_merges(commits2)
|
||||
|
||||
return MergeState(name, goal, merge_base, commits1, commits2, MergeRecord.NEW_MANUAL)
|
||||
|
||||
@staticmethod
|
||||
@ -1444,6 +1462,12 @@ class MergeState(Block):
|
||||
def set_goal(self, goal):
|
||||
if goal not in ALLOWED_GOALS:
|
||||
raise ValueError('%r is not an allowed goal' % (goal,))
|
||||
|
||||
if goal == 'rebase':
|
||||
self._check_no_merges(
|
||||
[self[0,i2].sha1 for i2 in range(1,self.len2)]
|
||||
)
|
||||
|
||||
self.goal = goal
|
||||
|
||||
def get_scratch_refname(self):
|
||||
|
Loading…
Reference in New Issue
Block a user