Patchwork D1179: amend: error out if the note is greater than 255bytes

login
register
mail settings
Submitter phabricator
Date Oct. 18, 2017, 10:15 p.m.
Message ID <3f24b0e85010d7d23249342fee26f0ea@localhost.localdomain>
Download mbox | patch
Permalink /patch/25218/
State Not Applicable
Headers show

Comments

phabricator - Oct. 18, 2017, 10:15 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG9dc521c54f01: amend: error out if the note is greater than 255bytes (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1179?vs=3004&id=3007

REVISION DETAIL
  https://phab.mercurial-scm.org/D1179

AFFECTED FILES
  hgext/amend.py
  tests/test-amend.t

CHANGE DETAILS




To: pulkit, #hg-reviewers, durin42
Cc: mercurial-devel

Patch

diff --git a/tests/test-amend.t b/tests/test-amend.t
--- a/tests/test-amend.t
+++ b/tests/test-amend.t
@@ -198,6 +198,9 @@ 
 
   $ echo foo > bar
   $ hg add bar
+  $ hg amend --note 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
+  abort: cannot store a note of more than 255 bytes
+  [255]
   $ hg amend --note "adding bar"
   $ hg debugobsolete -r .
   112478962961147124edd43549aedd1a335e44bf be169c7e8dbe21cd10b3d79691cbe7f241e3c21c 0 (Thu Jan 01 00:00:00 1970 +0000) {'operation': 'amend', 'user': 'test'}
diff --git a/hgext/amend.py b/hgext/amend.py
--- a/hgext/amend.py
+++ b/hgext/amend.py
@@ -16,6 +16,7 @@ 
 from mercurial import (
     cmdutil,
     commands,
+    error,
     registrar,
 )
 
@@ -45,6 +46,8 @@ 
 
     See :hg:`help commit` for more details.
     """
+    if len(opts['note']) > 255:
+        raise error.Abort(_("cannot store a note of more than 255 bytes"))
     with repo.wlock(), repo.lock():
         if not opts.get('logfile'):
             opts['message'] = opts.get('message') or repo['.'].description()