changeset 34908:907ff34e1460

log: add an assertion about fctx not being None in patch.diff() As noted in the comment, this should not happen as removed files (the cause of fctx2 being None) are caught earlier.
author Denis Laxalde <denis.laxalde@logilab.fr>
date Thu, 19 Oct 2017 15:06:33 +0200
parents 0ccfc468423a
children a52e5604d864 3ce0e4b51f78
files mercurial/patch.py
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/patch.py	Thu Oct 19 14:55:10 2017 +0200
+++ b/mercurial/patch.py	Thu Oct 19 15:06:33 2017 +0200
@@ -2330,6 +2330,11 @@
             losedatafn=losedatafn, prefix=prefix, relroot=relroot, copy=copy,
     ):
         if hunksfilterfn is not None:
+            # If the file has been removed, fctx2 is None; but this should
+            # not occur here since we catch removed files early in
+            # cmdutil.getloglinerangerevs() for 'hg log -L'.
+            assert fctx2 is not None, \
+                'fctx2 unexpectly None in diff hunks filtering'
             hunks = hunksfilterfn(fctx2, hunks)
         text = ''.join(sum((list(hlines) for hrange, hlines in hunks), []))
         if hdr and (text or len(hdr) > 1):