diff --git a/mercurial/simplemerge.py b/mercurial/simplemerge.py --- a/mercurial/simplemerge.py +++ b/mercurial/simplemerge.py @@ -423,12 +423,17 @@ return [name_a, name_b, name_base] def simplemerge(ui, localfile, basefile, otherfile, - localctx=None, basectx=None, otherctx=None, repo=None, **opts): + localctx=None, basectx=None, otherctx=None, repo=None, + filtereddata=False, **opts): """Performs the simplemerge algorithm. {local|base|other}ctx are optional. If passed, they (local/base/other) will be read from and the merge result written to (local). You should pass - explicit labels in this mode since the default is to use the file paths.""" + explicit labels in this mode since the default is to use the file paths. + + filtereddata should only be True if the data() in your context returns + decoded data. + """ def readfile(filename): f = open(filename, "rb") text = f.read() @@ -438,15 +443,19 @@ def readctx(ctx): if not ctx: return None - if not repo: - raise error.ProgrammingError('simplemerge: repo must be passed if ' - 'using contexts') - # `wwritedata` is used to get the post-filter data from `ctx` (i.e., - # what would have been in the working copy). Since merges were run in - # the working copy, and thus used post-filter data, we do the same to - # maintain behavior. - return repo.wwritedata(ctx.path(), - _verifytext(ctx.data(), ctx.path(), ui, opts)) + if filtereddata: + return _verifytext(ctx.data(), ctx.path(), ui, opts) + else: + if not repo: + raise error.ProgrammingError('simplemerge: repo must be passed ' + 'if using contexts and ' + 'filtereddata is False.') + # `wwritedata` is used to get the post-filter data from `ctx` (i.e., + # what would have been in the working copy). Since merges were run + # in the working copy, and thus used post-filter data, we do the + # same to maintain behavior. + text = _verifytext(ctx.data(), ctx.path(), ui, opts) + return repo.wwritedata(ctx.path(), text) class ctxwriter(object): def __init__(self, ctx):