diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -848,7 +848,7 @@ def _populate_label_detail(input, templa
 
     props = {b'ctx': ctx}
     templateresult = template.renderdefault(props)
-    input.label_detail = templateresult.splitlines()[0]  # split for safety
+    input.label_detail = stringutil.firstline(templateresult)  # avoid '\n'
 
 
 def _populate_label_details(repo, inputs, tool=None):