diff -r eb8aed493a56 -r 75794847ef62 mercurial/utils/stringutil.py --- a/mercurial/utils/stringutil.py Thu Mar 24 22:05:49 2022 -0700 +++ b/mercurial/utils/stringutil.py Fri Mar 25 08:33:03 2022 -0700 @@ -687,6 +687,10 @@ def firstline(text): """Return the first line of the input""" + # Try to avoid running splitlines() on the whole string + i = text.find(b'\n') + if i != -1: + text = text[:i] try: return text.splitlines()[0] except IndexError: