changeset 36768:658ed9c7442b

releasenotes: replace abort with warning while parsing (issue5775) During the 4.5 development cycle, the extension broke on two different changesets. This fixes the issue by ensuring that it just throws a warning when it encounters unexpected behaviour, instead of aborting. Differential Revision: https://phab.mercurial-scm.org/D2255
author Rishabh Madan <rishabhmadan96@gmail.com>
date Sat, 03 Mar 2018 23:47:22 +0530
parents a148c67d8b09
children 3fff6f30bd7f
files hgext/releasenotes.py tests/test-releasenotes-parsing.t
diffstat 2 files changed, 25 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/releasenotes.py	Wed Mar 07 09:07:34 2018 +1100
+++ b/hgext/releasenotes.py	Sat Mar 03 23:47:22 2018 +0530
@@ -325,8 +325,8 @@
                     continue
 
                 if pblock['type'] != 'paragraph':
-                    raise error.Abort(_('unexpected block in release notes '
-                                        'directive %s') % directive)
+                    repo.ui.warn(_('unexpected block in release notes '
+                                        'directive %s\n') % directive)
 
                 if pblock['indent'] > 0:
                     paragraphs.append(pblock['lines'])
--- a/tests/test-releasenotes-parsing.t	Wed Mar 07 09:07:34 2018 +1100
+++ b/tests/test-releasenotes-parsing.t	Sat Mar 03 23:47:22 2018 +0530
@@ -177,3 +177,26 @@
       paragraph: Bullet item 1
     bullet point:
       paragraph: Bullet item 2
+
+Warn user in case of unexpected block while parsing
+
+  $ hg init relnotes-warn
+  $ cd relnotes-warn
+  $ touch feature1
+  $ hg -q commit -A -l - << EOF
+  > commit 1
+  > 
+  > .. feature::
+  > 
+  >    new feature added.
+  >     some words about the feature.
+  > EOF
+
+  $ hg releasenote -r .
+  unexpected block in release notes directive feature
+  New Features
+  ============
+  
+  * new feature added.  some words about the feature.
+
+  $ cd ..