From: David KÃ¥gedal <davidk@xxxxxxxxxxxxxx> merge-recursive already has useful information about what the conflicts were, so we reuse that when pushing. Signed-off-by: David KÃ¥gedal <davidk@xxxxxxxxxxxxxx> --- stgit/git.py | 27 +++++++++++++++++++++------ stgit/stack.py | 2 ++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/stgit/git.py b/stgit/git.py index 63798bd..59423ab 100644 --- a/stgit/git.py +++ b/stgit/git.py @@ -30,7 +30,14 @@ from sets import Set class GitException(Exception): pass - +class GitConflictException(GitException): + def __init__(self, conflicts): + GitException.__init__(self) + self.conflicts = conflicts + def __str__(self): + return "%d conflicts" % len(self.conflicts) + def list(self): + out.info(*self.conflicts) # # Classes @@ -675,11 +682,19 @@ def merge_recursive(base, head1, head2): """ refresh_index() - # use _output() to mask the verbose prints of the tool - try: - _output(['git-merge-recursive', base, '--', head1, head2]) - except GitException: - raise GitException, 'GIT index merging failed (possible conflicts)' + # Duplicate _output(), since we need the exit status + p=popen2.Popen3(['git-merge-recursive', base, '--', head1, head2], True) + output = p.fromchild.readlines() + st = p.wait() >> 8 + if st == 0: + # No problems + return + elif st == 1: + # There were conflicts + conflicts = [l.strip() for l in output if l.startswith('CONFLICT')] + raise GitConflictException(conflicts) + else: + raise GitException, 'git-merge-recursive failed (%s)' % (p.childerr.read().strip()) def merge(base, head1, head2): """Perform a 3-way merge between base, head1 and head2 into the diff --git a/stgit/stack.py b/stgit/stack.py index 0e43f75..3b06ca5 100644 --- a/stgit/stack.py +++ b/stgit/stack.py @@ -1070,6 +1070,8 @@ class Series(PatchSet): # merge can fail but the patch needs to be pushed try: git.merge_recursive(bottom, head, top) + except git.GitConflictException, ex: + ex.list() except git.GitException, ex: out.error('The merge failed during "push".', 'Use "refresh" after fixing the conflicts or' -- 1.5.3.rc3.119.g1812 - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html