Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for selection of merge base if not unique #56

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion git-imerge
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,13 @@ def get_boundaries(tip1, tip2):
if not merge_base:
raise Failure('%r and %r do not have a common merge base' % (tip1, tip2))
if len(merge_base) > 1:
raise Failure('%r and %r do not have a unique merge base' % (tip1, tip2))
print ("There are multiple merge bases:")
for i, b in enumerate(merge_base):
print (i, b)

merge_base = get_index_for_merge(merge_base)
print ("Selected merge base:")
print (merge_base)

[merge_base] = merge_base

Expand Down Expand Up @@ -458,6 +464,25 @@ def get_boundaries(tip1, tip2):
return (merge_base, commits1, commits2)


def get_index_for_merge(merge_base):
"""Ask user to select one of the merge bases."""

finished = 0
while finished == 0:
merge_index = raw_input('Enter the merge base index to use: ')
if int(merge_index) > len(merge_base) - 1:
print ("Invalid merge index")
elif int(merge_index) < 0:
print ("Invalid merge index")
else:
selected_base = merge_base[int(merge_index)]
merge_base = []
merge_base.append(selected_base)
finished = 1

return merge_base


class TemporaryHead(object):
"""A context manager that records the current HEAD state then restores it.

Expand Down