summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
350bcba)
merge-recursive already has useful information about what the conflicts
were, so we reuse that when pushing.
Signed-off-by: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: Karl Hasselström <kha@treskal.com>
"""
Run.__init__(self, 'git', *cmd)
"""
Run.__init__(self, 'git', *cmd)
+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)
local tree
"""
refresh_index()
local tree
"""
refresh_index()
-
- # use _output() to mask the verbose prints of the tool
- try:
- # discard output to mask the verbose prints of the tool
- GRun('merge-recursive', base, '--', head1, head2).discard_output()
- except GitRunException, ex:
- raise GitException, 'GIT index merging failed (possible conflicts)'
+ p = GRun('merge-recursive', base, '--', head1, head2).returns([0, 1])
+ output = p.output_lines()
+ if p.exitcode == 0:
+ # No problems
+ return
+ else: # exitcode == 1
+ # There were conflicts
+ conflicts = [l.strip() for l in output if l.startswith('CONFLICT')]
+ raise GitConflictException(conflicts)
def merge(base, head1, head2):
"""Perform a 3-way merge between base, head1 and head2 into the
def merge(base, head1, head2):
"""Perform a 3-way merge between base, head1 and head2 into the
# merge can fail but the patch needs to be pushed
try:
git.merge_recursive(bottom, head, top)
# 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'
except git.GitException, ex:
out.error('The merge failed during "push".',
'Use "refresh" after fixing the conflicts or'