D377: simplemerge: add `filtereddata=False` to simplemerge()
phillco (Phil Cohen)
phabricator at mercurial-scm.org
Mon Aug 14 06:15:51 UTC 2017
phillco created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
In the next patch we'll make this function only take contexts, and also make
contrib/simplemerge work by having it pass fake context-like objects.
In order for those fake objects to work, simplemerge needs to know not to run
the repo decoding filters on them -- the data will already be decoded, coming
off the filesystem, and we won't have the repo object -- hence this flag.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D377
AFFECTED FILES
mercurial/simplemerge.py
CHANGE DETAILS
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):
To: phillco, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list