[PATCH 2 of 2 v7] releasenotes: add similarity check function to compare incoming notes
Rishabh Madan
rishabhmadan96 at gmail.com
Fri Aug 4 18:56:12 EDT 2017
On Thu, Aug 3, 2017 at 6:49 PM, Yuya Nishihara <yuya at tcha.org> wrote:
> On Tue, 01 Aug 2017 16:37:42 +0530, Rishabh Madan wrote:
> > # HG changeset patch
> > # User Rishabh Madan <rishabhmadan96 at gmail.com>
> > # Date 1501585562 -19800
> > # Tue Aug 01 16:36:02 2017 +0530
> > # Node ID be3b6b414d443412d5df53ddbf3e80192b6311cc
> > # Parent 1d79b04c402f3f431ca052b677b1021ddd93a10e
> > releasenotes: add similarity check function to compare incoming notes
>
> The series seems getting better, thanks.
>
> > - # TODO perform similarity comparison and try to match
> against
> > - # existing.
> > + incoming_str = converttitled([(title, paragraphs)])[0]
>
> > + if section == 'fix':
> > + issue = getissuenum(incoming_str)
> > + if issue:
> > + if findissue(ui, existingnotes, issue):
> > + continue
> > +
> > + if similar(ui, existingnotes, incoming_str):
> > + continue
>
> > +
> > self.addtitleditem(section, title, paragraphs)
> >
> > for paragraphs in other.nontitledforsection(section):
> > if paragraphs in self.nontitledforsection(section):
> > continue
> >
> > - # TODO perform similarily comparison and try to match
> against
> > - # existing.
> > + incoming_str = convertnontitled([paragraphs])[0]
>
> > + if section == 'fix':
> > + issue = getissuenum(incoming_str)
> > + if issue:
> > + if findissue(ui, existingnotes, issue):
> > + continue
> > +
> > + if similar(ui, existingnotes, incoming_str):
> > + continue
>
> Optionally these similarity comparison logic could be factored out to a
> helper
> function or method.
>
I think that rendering them to a helper function would lead us to the same
problem of managing titled/non-titled notes.
>
> > +def converttitled(titledparagraphs):
> > + """
> > + Convert titled paragraphs to strings
> > + """
> > + string_list = []
> > + str = ""
> > + for title, paragraphs in titledparagraphs:
> > + for para in paragraphs:
> > + str = str.join(para)
> > + string_list.append(str)
> > + return string_list
>
> str was initially a separator, but is overwritten by the result. Perhaps
> this function needs to join a list of all lines by ' ' or '\n' ?
>
> lines = []
> for para in paragraphs:
> lines.extend(para)
> string_list.append(' '.join(lines))
>
> Thanks for pointing out. I'll correct this thing.
> > +def convertnontitled(nontitledparagraphs):
> > + """
> > + Convert non-titled bullets to strings
> > + """
> > + string_list = []
> > + str = ""
> > + for paragraphs in nontitledparagraphs:
> > + for para in paragraphs:
> > + str = str.join(para)
> > + string_list.append(str)
> > + return string_list
>
> Same here.
ᐧ
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20170805/d3c5ef66/attachment.html>
More information about the Mercurial-devel
mailing list