Mercurial > evolve
changeset 3213:7bc587557e4f
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.
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Sun, 12 Nov 2017 01:26:30 +0530 |
parents | 6ffd0c36ccc1 |
children | 9fe2b3fd7fc7 |
files | hgext3rd/evolve/cmdrewrite.py |
diffstat | 1 files changed, 12 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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