plain: add a diff exception

Summary:
Oculus wants to preserve the "do not show binary diff" config while running
`hg export` in automation, since printing the binary diff might just OOM the
container. Let's add a plain exception for it.

Reviewed By: zhh95

Differential Revision: D13111212

fbshipit-source-id: 34af58ac0917de3b3231e637774896d882585e26
This commit is contained in:
Jun Wu 2018-12-05 19:21:43 -08:00 committed by Facebook Github Bot
parent 1a18688d9f
commit c92e6755d7
2 changed files with 25 additions and 2 deletions

View File

@ -2365,7 +2365,7 @@ def difffeatureopts(
# True, or False.
if v or isinstance(v, bool):
return v
if forceplain is not None and ui.plain():
if forceplain is not None and ui.plain("diffopts"):
return forceplain
return getter(section, name or key, untrusted=untrusted)
@ -2377,7 +2377,7 @@ def difffeatureopts(
}
buildopts["worddiff"] = (
ui.configbool("experimental", "worddiff")
and not ui.plain()
and not ui.plain("diffopts")
and ui._colormode is not None
)

23
tests/test-diff-binary.t Normal file
View File

@ -0,0 +1,23 @@
$ newrepo
$ setconfig diff.git=1 diff.nobinary=1
>>> open('a.bin', 'wb').write(b'\0\1')
$ hg commit -m A -A a.bin
>>> open('a.bin', 'wb').write(b'\0\2')
$ hg diff
diff --git a/a.bin b/a.bin
Binary file a.bin has changed
$ HGPLAIN=1 hg diff
diff --git a/a.bin b/a.bin
index bdc955b7b2e610ad5a72302b139a2e6cb325519a..8835708590a9afa236e1bbad18df9d23de82ccd3
GIT binary patch
literal 2
Jc${Nk0ssI600RI3
$ HGPLAIN=1 HGPLAINEXCEPT=diffopts hg diff
diff --git a/a.bin b/a.bin
Binary file a.bin has changed