cmdrewrite: add a utility function to make sure note is of valid format
Upcoming patches will add support to store a note on various evolution related
commands by storing that in obsmarker. Since the obsmarker metadata field can't
store things above 255 bytes, this patch introduces a function which will be
used to make sure note is under 255 bytes and does not contain newlines. We
don't want notes to be multilines.
--- a/hgext3rd/evolve/cmdrewrite.py Thu Nov 30 12:14:36 2017 -0500
+++ b/hgext3rd/evolve/cmdrewrite.py Sun Nov 12 01:26:30 2017 +0530
@@ -49,6 +49,18 @@
# option added by evolve
+def _checknotesize(opts):
+ """ make sure note is of valid format """
+
+ note = opts.get('note')
+ if not note:
+ return
+
+ if len(note) > 255:
+ raise error.Abort(_("cannot store a note of more than 255 bytes"))
+ if '\n' in note:
+ raise error.Abort(_("note cannot contain a newline"))
+
def _resolveoptions(ui, opts):
"""modify commit options dict to handle related options