##// 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 from __future__ import absolute_import
19 from __future__ import absolute_import
20
20
21 import os
22
23 from .i18n import _
21 from .i18n import _
24 from . import (
22 from . import (
25 error,
23 error,
26 mdiff,
24 mdiff,
27 pycompat,
25 pycompat,
28 util,
26 util,
29 vfs as vfsmod,
30 )
27 )
31
28
32 class CantReprocessAndShowBase(Exception):
29 class CantReprocessAndShowBase(Exception):
@@ -428,13 +425,8 b' def simplemerge(ui, localfile, basefile,'
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
@@ -466,20 +458,16 b' def simplemerge(ui, localfile, basefile,'
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 = {
General Comments 0
You need to be logged in to leave comments. Login now