diff -r ff7697b436ab -r 3e3f2201bbdf mercurial/context.py --- a/mercurial/context.py Sun Oct 02 05:29:17 2016 +0530 +++ b/mercurial/context.py Sat Oct 01 14:18:58 2016 +0100 @@ -930,7 +930,7 @@ def lines(text): if text.endswith("\n"): return text.count("\n") - return text.count("\n") + 1 + return text.count("\n") + int(bool(text)) if linenumber: def decorate(text, rev):