mercurial/cmdutil.py
changeset 42933 7e9997041781
parent 42932 e4803231f538
child 43076 2372284d9457
--- a/mercurial/cmdutil.py	Sat Sep 14 15:13:16 2019 -0400
+++ b/mercurial/cmdutil.py	Sat Sep 14 18:44:18 2019 -0400
@@ -210,6 +210,18 @@
 
     return datemaydiffer
 
+def checknotesize(ui, opts):
+    """ make sure note is of valid format """
+
+    note = opts.get('note')
+    if not note:
+        return
+
+    if len(note) > 255:
+        raise error.Abort(_(b"cannot store a note of more than 255 bytes"))
+    if b'\n' in note:
+        raise error.Abort(_(b"note cannot contain a newline"))
+
 def ishunk(x):
     hunkclasses = (crecordmod.uihunk, patch.recordhunk)
     return isinstance(x, hunkclasses)