Mercurial > hg > crecord
changeset 105:565f0bc50257
core: only parse whitespace-related diffopts
A few months ago, I introduced a config to disable the a/ and b/ prefixes,
called diff.noprefix. Enabling this config caused problems with a variety of
core extensions such as mq and record, and when I dug in I found that they
really were doing the wrong thing -- that they should really be disabling all
format-changing diffopts even if they're enabled in ui. In order to do that I
introduced the difffeatureopts API, that lets extensions opt into features
they're interested in.
Make crecord use this API. The only options it is interested in are the
whitespace ones. nodates and git need to be explicitly enabled, so do that as
well.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Fri, 27 Feb 2015 15:00:53 -0800 |
parents | e1567c94274f |
children | 71f7fa103401 |
files | crecord/crecord_core.py |
diffstat | 1 files changed, 7 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/crecord/crecord_core.py +++ b/crecord/crecord_core.py @@ -51,10 +51,13 @@ # we take only the first 3 of these changes = repo.status(match=match)[:3] modified, added, removed = changes - diffopts = opts.copy() - diffopts['nodates'] = True - diffopts['git'] = True - diffopts = patch.diffopts(ui, opts=diffopts) + try: + # Mercurial >= 3.3 allow disabling format-changing diffopts + diffopts = patch.difffeatureopts(ui, opts=opts, whitespace=True) + except AttributeError: + diffopts = patch.diffopts(ui, opts=opts) + diffopts.nodates = True + diffopts.git = True chunks = patch.diff(repo, changes=changes, opts=diffopts) fp = cStringIO.StringIO() fp.write(''.join(chunks))