##// END OF EJS Templates
amend: prevent '\n' in the note string...
Matt Harbison -
r43203:7e999704 default
parent child Browse files
Show More
@@ -16,7 +16,6 b' from mercurial.i18n import _'
16 16 from mercurial import (
17 17 cmdutil,
18 18 commands,
19 error,
20 19 pycompat,
21 20 registrar,
22 21 )
@@ -50,8 +49,8 b' def amend(ui, repo, *pats, **opts):'
50 49 See :hg:`help commit` for more details.
51 50 """
52 51 opts = pycompat.byteskwargs(opts)
53 if len(opts['note']) > 255:
54 raise error.Abort(_("cannot store a note of more than 255 bytes"))
52 cmdutil.checknotesize(ui, opts)
53
55 54 with repo.wlock(), repo.lock():
56 55 if not opts.get('logfile'):
57 56 opts['message'] = opts.get('message') or repo['.'].description()
@@ -210,6 +210,18 b' def resolvecommitoptions(ui, opts):'
210 210
211 211 return datemaydiffer
212 212
213 def checknotesize(ui, opts):
214 """ make sure note is of valid format """
215
216 note = opts.get('note')
217 if not note:
218 return
219
220 if len(note) > 255:
221 raise error.Abort(_(b"cannot store a note of more than 255 bytes"))
222 if b'\n' in note:
223 raise error.Abort(_(b"note cannot contain a newline"))
224
213 225 def ishunk(x):
214 226 hunkclasses = (crecordmod.uihunk, patch.recordhunk)
215 227 return isinstance(x, hunkclasses)
General Comments 0
You need to be logged in to leave comments. Login now