changeset 44427:4ce2330f2d0b

phabricator: also check parent fctx for binary where it is checked for UTF-8 I don't know that this is necessary, but it seems obvious from the code checking both the current and parent file for UTF-8 content that this was the intent. Differential Revision: https://phab.mercurial-scm.org/D8221
author Matt Harbison <matt_harbison@yahoo.com>
date Thu, 20 Feb 2020 10:56:40 -0500
parents 66a05dbb8b4c
children f82d2d4e71db
files hgext/phabricator.py
diffstat 1 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/phabricator.py	Thu Feb 20 10:46:43 2020 -0500
+++ b/hgext/phabricator.py	Thu Feb 20 10:56:40 2020 -0500
@@ -831,7 +831,12 @@
             pchange.addoldmode(originalmode)
             pchange.addnewmode(filemode)
 
-        if fctx.isbinary() or notutf8(fctx) or notutf8(oldfctx):
+        if (
+            fctx.isbinary()
+            or notutf8(fctx)
+            or oldfctx.isbinary()
+            or notutf8(oldfctx)
+        ):
             makebinary(pchange, fctx)
             addoldbinary(pchange, fctx.p1(), fctx)
         else:
@@ -892,7 +897,11 @@
             pchange.addnewmode(gitmode[fctx.flags()])
             pchange.type = DiffChangeType.ADD
 
-        if fctx.isbinary() or notutf8(fctx) or (oldfctx and notutf8(oldfctx)):
+        if (
+            fctx.isbinary()
+            or notutf8(fctx)
+            or (oldfctx and (oldfctx.isbinary() or notutf8(oldfctx)))
+        ):
             makebinary(pchange, fctx)
             if renamed:
                 addoldbinary(pchange, oldfctx, fctx)