##// END OF EJS Templates
simplemerge: stop reading from, and writing to, files...
Phil Cohen -
r33906:61b267a9 default
parent child Browse files
Show More
@@ -18,15 +18,12 b''
18 18
19 19 from __future__ import absolute_import
20 20
21 import os
22
23 21 from .i18n import _
24 22 from . import (
25 23 error,
26 24 mdiff,
27 25 pycompat,
28 26 util,
29 vfs as vfsmod,
30 27 )
31 28
32 29 class CantReprocessAndShowBase(Exception):
@@ -428,13 +425,8 b' def simplemerge(ui, localfile, basefile,'
428 425
429 426 {local|base|other}ctx are optional. If passed, they (local/base/other) will
430 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."""
432 def readfile(filename):
433 f = open(filename, "rb")
434 text = f.read()
435 f.close()
436 return _verifytext(text, filename, ui, opts)
437
428 explicit labels in this mode since the default is to use the file paths.
429 """
438 430 def readctx(ctx):
439 431 if not ctx:
440 432 return None
@@ -466,20 +458,16 b' def simplemerge(ui, localfile, basefile,'
466 458 opts.get('label', []))
467 459
468 460 try:
469 localtext = readctx(localctx) if localctx else readfile(localfile)
470 basetext = readctx(basectx) if basectx else readfile(basefile)
471 othertext = readctx(otherctx) if otherctx else readfile(otherfile)
461 localtext = readctx(localctx)
462 basetext = readctx(basectx)
463 othertext = readctx(otherctx)
472 464 except error.Abort:
473 465 return 1
474 466
475 467 if opts.get('print'):
476 468 out = ui.fout
477 elif localctx:
469 else:
478 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 472 m3 = Merge3Text(basetext, localtext, othertext)
485 473 extrakwargs = {
General Comments 0
You need to be logged in to leave comments. Login now