mercurial/utils/stringutil.py
changeset 49021 51aed118f9dc
parent 48946 642e31cb55f0
child 49030 75794847ef62
--- a/mercurial/utils/stringutil.py	Thu Mar 24 15:41:29 2022 -0700
+++ b/mercurial/utils/stringutil.py	Thu Mar 24 16:09:12 2022 -0700
@@ -685,6 +685,14 @@
     return _correctauthorformat.match(author) is not None
 
 
+def firstline(text):
+    """Return the first line of the input"""
+    try:
+        return text.splitlines()[0]
+    except IndexError:
+        return b''
+
+
 def ellipsis(text, maxlength=400):
     """Trim string to at most maxlength (default: 400) columns in display."""
     return encoding.trim(text, maxlength, ellipsis=b'...')