##// 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 from mercurial import (
16 from mercurial import (
17 cmdutil,
17 cmdutil,
18 commands,
18 commands,
19 error,
20 pycompat,
19 pycompat,
21 registrar,
20 registrar,
22 )
21 )
@@ -50,8 +49,8 b' def amend(ui, repo, *pats, **opts):'
50 See :hg:`help commit` for more details.
49 See :hg:`help commit` for more details.
51 """
50 """
52 opts = pycompat.byteskwargs(opts)
51 opts = pycompat.byteskwargs(opts)
53 if len(opts['note']) > 255:
52 cmdutil.checknotesize(ui, opts)
54 raise error.Abort(_("cannot store a note of more than 255 bytes"))
53
55 with repo.wlock(), repo.lock():
54 with repo.wlock(), repo.lock():
56 if not opts.get('logfile'):
55 if not opts.get('logfile'):
57 opts['message'] = opts.get('message') or repo['.'].description()
56 opts['message'] = opts.get('message') or repo['.'].description()
@@ -210,6 +210,18 b' def resolvecommitoptions(ui, opts):'
210
210
211 return datemaydiffer
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 def ishunk(x):
225 def ishunk(x):
214 hunkclasses = (crecordmod.uihunk, patch.recordhunk)
226 hunkclasses = (crecordmod.uihunk, patch.recordhunk)
215 return isinstance(x, hunkclasses)
227 return isinstance(x, hunkclasses)
General Comments 0
You need to be logged in to leave comments. Login now