426 localctx=None, basectx=None, otherctx=None, repo=None, **opts): |
423 localctx=None, basectx=None, otherctx=None, repo=None, **opts): |
427 """Performs the simplemerge algorithm. |
424 """Performs the simplemerge algorithm. |
428 |
425 |
429 {local|base|other}ctx are optional. If passed, they (local/base/other) will |
426 {local|base|other}ctx are optional. If passed, they (local/base/other) will |
430 be read from and the merge result written to (local). You should pass |
427 be read from and the merge result written to (local). You should pass |
431 explicit labels in this mode since the default is to use the file paths.""" |
428 explicit labels in this mode since the default is to use the file paths. |
432 def readfile(filename): |
429 """ |
433 f = open(filename, "rb") |
|
434 text = f.read() |
|
435 f.close() |
|
436 return _verifytext(text, filename, ui, opts) |
|
437 |
|
438 def readctx(ctx): |
430 def readctx(ctx): |
439 if not ctx: |
431 if not ctx: |
440 return None |
432 return None |
441 # Merges were always run in the working copy before, which means |
433 # Merges were always run in the working copy before, which means |
442 # they used decoded data, if the user defined any repository |
434 # they used decoded data, if the user defined any repository |
464 name_a, name_b, name_base = _picklabels([localctx.path(), |
456 name_a, name_b, name_base = _picklabels([localctx.path(), |
465 otherctx.path(), None], |
457 otherctx.path(), None], |
466 opts.get('label', [])) |
458 opts.get('label', [])) |
467 |
459 |
468 try: |
460 try: |
469 localtext = readctx(localctx) if localctx else readfile(localfile) |
461 localtext = readctx(localctx) |
470 basetext = readctx(basectx) if basectx else readfile(basefile) |
462 basetext = readctx(basectx) |
471 othertext = readctx(otherctx) if otherctx else readfile(otherfile) |
463 othertext = readctx(otherctx) |
472 except error.Abort: |
464 except error.Abort: |
473 return 1 |
465 return 1 |
474 |
466 |
475 if opts.get('print'): |
467 if opts.get('print'): |
476 out = ui.fout |
468 out = ui.fout |
477 elif localctx: |
469 else: |
478 out = ctxwriter(localctx) |
470 out = ctxwriter(localctx) |
479 else: |
|
480 localfile = os.path.realpath(localfile) |
|
481 opener = vfsmod.vfs(os.path.dirname(localfile)) |
|
482 out = opener(os.path.basename(localfile), "w", atomictemp=True) |
|
483 |
471 |
484 m3 = Merge3Text(basetext, localtext, othertext) |
472 m3 = Merge3Text(basetext, localtext, othertext) |
485 extrakwargs = { |
473 extrakwargs = { |
486 "localorother": opts.get("localorother", None), |
474 "localorother": opts.get("localorother", None), |
487 'minimize': True, |
475 'minimize': True, |