diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py --- a/hgext/releasenotes.py +++ b/hgext/releasenotes.py @@ -185,8 +185,8 @@ def parsereleasenotesfile(sections, text blocks = minirst.parse(text)[0] - def gatherparagraphs(offset): - paragraphs = [] + def gatherparagraphsbullets(offset, title=False): + notefragment = [] for i in range(offset + 1, len(blocks)): block = blocks[i] @@ -198,17 +198,27 @@ def parsereleasenotesfile(sections, text elif block['type'] == 'bullet': if block['indent'] != 0: raise error.Abort(_('indented bullet lists not supported')) + if title: + lines = [l[1:].strip() for l in block['lines']] + notefragment.append(lines) + continue + else: + lines = [[l[1:].strip() for l in block['lines']]] - lines = [l[1:].strip() for l in block['lines']] - paragraphs.append(lines) - continue + for block in blocks[i + 1:]: + if block['type'] in ('bullet', 'section'): + break + if block['type'] == 'paragraph': + lines.append(block['lines']) + notefragment.append(lines) + continue elif block['type'] != 'paragraph': raise error.Abort(_('unexpected block type in release notes: ' '%s') % block['type']) + if title: + notefragment.append(block['lines']) - paragraphs.append(block['lines']) - - return paragraphs + return notefragment currentsection = None for i, block in enumerate(blocks): @@ -226,16 +236,18 @@ def parsereleasenotesfile(sections, text title) currentsection = name - paragraphs = gatherparagraphs(i) - if paragraphs: - notes.addnontitleditem(currentsection, paragraphs) + bullet_points = gatherparagraphsbullets(i) + if bullet_points: + for para in bullet_points: + notes.addnontitleditem(currentsection, para) elif block['underline'] == '-': # sub-section - paragraphs = gatherparagraphs(i) - if title == BULLET_SECTION: - notes.addnontitleditem(currentsection, paragraphs) + bullet_points = gatherparagraphsbullets(i) + for para in bullet_points: + notes.addnontitleditem(currentsection, para) else: + paragraphs = gatherparagraphsbullets(i, True) notes.addtitleditem(currentsection, title, paragraphs) else: raise error.Abort(_('unsupported section type for %s') % title) diff --git a/tests/test-releasenotes-merging.t b/tests/test-releasenotes-merging.t --- a/tests/test-releasenotes-merging.t +++ b/tests/test-releasenotes-merging.t @@ -34,8 +34,7 @@ A fix directive from commit message is a * Fix from commit message. -Processing again will no-op -TODO this is buggy +Processing again ignores the already added bullet. $ hg releasenotes -r . $TESTTMP/single-fix-bullet @@ -45,8 +44,6 @@ TODO this is buggy * Fix from release notes. - Fix from commit message. - * Fix from commit message. $ cd .. @@ -111,7 +108,7 @@ Doing it again won't add another section $ cd .. -Bullets don't merge properly +Bullets from rev merge with those from notes file. $ hg init bullets $ cd bullets @@ -157,7 +154,7 @@ Bullets don't merge properly * this is fix1. - this is fix2. + * this is fix2. * this is fix3. diff --git a/tests/test-releasenotes-parsing.t b/tests/test-releasenotes-parsing.t --- a/tests/test-releasenotes-parsing.t +++ b/tests/test-releasenotes-parsing.t @@ -59,7 +59,9 @@ Multiple bullet points. With some entrie section: feature bullet point: paragraph: First bullet point. It has a single line. + bullet point: paragraph: Second bullet point. It consists of multiple lines. + bullet point: paragraph: Third bullet point. It has a single line. Bullet point without newline between items @@ -77,8 +79,11 @@ Bullet point without newline between ite section: feature bullet point: paragraph: First bullet point + bullet point: paragraph: Second bullet point And it has multiple lines + bullet point: paragraph: Third bullet point + bullet point: paragraph: Fourth bullet point Sub-section contents are read @@ -130,10 +135,12 @@ Multiple sections are read section: feature bullet point: paragraph: Feature 1 + bullet point: paragraph: Feature 2 section: fix bullet point: paragraph: Fix 1 + bullet point: paragraph: Fix 2 Mixed sub-sections and bullet list @@ -166,4 +173,5 @@ Mixed sub-sections and bullet list paragraph: Some words about the second feature. That span multiple lines. bullet point: paragraph: Bullet item 1 + bullet point: paragraph: Bullet item 2