Show More
@@ -413,8 +413,8 b' def simplemerge(ui, localfile, basefile,' | |||||
413 | """Performs the simplemerge algorithm. |
|
413 | """Performs the simplemerge algorithm. | |
414 |
|
414 | |||
415 | {local|base|other}ctx are optional. If passed, they (local/base/other) will |
|
415 | {local|base|other}ctx are optional. If passed, they (local/base/other) will | |
416 | be read from. You should pass explicit labels in this mode since the default |
|
416 | be read from and the merge result written to (local). You should pass | |
417 | is to use the file paths.""" |
|
417 | explicit labels in this mode since the default is to use the file paths.""" | |
418 | def readfile(filename): |
|
418 | def readfile(filename): | |
419 | f = open(filename, "rb") |
|
419 | f = open(filename, "rb") | |
420 | text = f.read() |
|
420 | text = f.read() | |
@@ -434,6 +434,17 b' def simplemerge(ui, localfile, basefile,' | |||||
434 | return repo.wwritedata(ctx.path(), |
|
434 | return repo.wwritedata(ctx.path(), | |
435 | _verifytext(ctx.data(), ctx.path(), ui, opts)) |
|
435 | _verifytext(ctx.data(), ctx.path(), ui, opts)) | |
436 |
|
436 | |||
|
437 | class ctxwriter(object): | |||
|
438 | def __init__(self, ctx): | |||
|
439 | self.ctx = ctx | |||
|
440 | self.text = "" | |||
|
441 | ||||
|
442 | def write(self, text): | |||
|
443 | self.text += text | |||
|
444 | ||||
|
445 | def close(self): | |||
|
446 | self.ctx.write(self.text, self.ctx.flags()) | |||
|
447 | ||||
437 | mode = opts.get('mode','merge') |
|
448 | mode = opts.get('mode','merge') | |
438 | if mode == 'union': |
|
449 | if mode == 'union': | |
439 | name_a = None |
|
450 | name_a = None | |
@@ -460,12 +471,14 b' def simplemerge(ui, localfile, basefile,' | |||||
460 | except error.Abort: |
|
471 | except error.Abort: | |
461 | return 1 |
|
472 | return 1 | |
462 |
|
473 | |||
463 | localfile = os.path.realpath(localfile) |
|
474 | if opts.get('print'): | |
464 | if not opts.get('print'): |
|
475 | out = ui.fout | |
|
476 | elif localctx: | |||
|
477 | out = ctxwriter(localctx) | |||
|
478 | else: | |||
|
479 | localfile = os.path.realpath(localfile) | |||
465 | opener = vfsmod.vfs(os.path.dirname(localfile)) |
|
480 | opener = vfsmod.vfs(os.path.dirname(localfile)) | |
466 | out = opener(os.path.basename(localfile), "w", atomictemp=True) |
|
481 | out = opener(os.path.basename(localfile), "w", atomictemp=True) | |
467 | else: |
|
|||
468 | out = ui.fout |
|
|||
469 |
|
482 | |||
470 | m3 = Merge3Text(basetext, localtext, othertext) |
|
483 | m3 = Merge3Text(basetext, localtext, othertext) | |
471 | extrakwargs = { |
|
484 | extrakwargs = { |
General Comments 0
You need to be logged in to leave comments.
Login now