mercurial/utils/stringutil.py
changeset 49030 75794847ef62
parent 49021 51aed118f9dc
child 49284 d44e3c45f0e4
equal deleted inserted replaced
49029:eb8aed493a56 49030:75794847ef62
   685     return _correctauthorformat.match(author) is not None
   685     return _correctauthorformat.match(author) is not None
   686 
   686 
   687 
   687 
   688 def firstline(text):
   688 def firstline(text):
   689     """Return the first line of the input"""
   689     """Return the first line of the input"""
       
   690     # Try to avoid running splitlines() on the whole string
       
   691     i = text.find(b'\n')
       
   692     if i != -1:
       
   693         text = text[:i]
   690     try:
   694     try:
   691         return text.splitlines()[0]
   695         return text.splitlines()[0]
   692     except IndexError:
   696     except IndexError:
   693         return b''
   697         return b''
   694 
   698