##// END OF EJS Templates
simplemerge: simplify code now that we always write to a context...
Phil Cohen -
r33909:4074de97 default
parent child Browse files
Show More
@@ -436,17 +436,6 b' def simplemerge(ui, localctx, basectx, o'
436 # repository usually sees) might be more useful.
436 # repository usually sees) might be more useful.
437 return _verifytext(ctx.decodeddata(), ctx.path(), ui, opts)
437 return _verifytext(ctx.decodeddata(), ctx.path(), ui, opts)
438
438
439 class ctxwriter(object):
440 def __init__(self, ctx):
441 self.ctx = ctx
442 self.text = ""
443
444 def write(self, text):
445 self.text += text
446
447 def close(self):
448 self.ctx.write(self.text, self.ctx.flags())
449
450 mode = opts.get('mode','merge')
439 mode = opts.get('mode','merge')
451 name_a, name_b, name_base = None, None, None
440 name_a, name_b, name_base = None, None, None
452 if mode != 'union':
441 if mode != 'union':
@@ -461,11 +450,6 b' def simplemerge(ui, localctx, basectx, o'
461 except error.Abort:
450 except error.Abort:
462 return 1
451 return 1
463
452
464 if opts.get('print'):
465 out = ui.fout
466 else:
467 out = ctxwriter(localctx)
468
469 m3 = Merge3Text(basetext, localtext, othertext)
453 m3 = Merge3Text(basetext, localtext, othertext)
470 extrakwargs = {
454 extrakwargs = {
471 "localorother": opts.get("localorother", None),
455 "localorother": opts.get("localorother", None),
@@ -479,12 +463,17 b' def simplemerge(ui, localctx, basectx, o'
479 extrakwargs['base_marker'] = '|||||||'
463 extrakwargs['base_marker'] = '|||||||'
480 extrakwargs['name_base'] = name_base
464 extrakwargs['name_base'] = name_base
481 extrakwargs['minimize'] = False
465 extrakwargs['minimize'] = False
466
467 mergedtext = ""
482 for line in m3.merge_lines(name_a=name_a, name_b=name_b,
468 for line in m3.merge_lines(name_a=name_a, name_b=name_b,
483 **pycompat.strkwargs(extrakwargs)):
469 **pycompat.strkwargs(extrakwargs)):
484 out.write(line)
470 if opts.get('print'):
471 ui.fout.write(line)
472 else:
473 mergedtext += line
485
474
486 if not opts.get('print'):
475 if not opts.get('print'):
487 out.close()
476 localctx.write(mergedtext, localctx.flags())
488
477
489 if m3.conflicts and not mode == 'union':
478 if m3.conflicts and not mode == 'union':
490 return 1
479 return 1
General Comments 0
You need to be logged in to leave comments. Login now