[PATCH 3 of 3 v5] releasenotes: add similarity check function to compare incoming notes
Yuya Nishihara
yuya at tcha.org
Wed Jul 19 10:00:43 EDT 2017
On Tue, 18 Jul 2017 16:37:21 -0500, Kevin Bullock wrote:
> > On Jul 18, 2017, at 13:02, Rishabh Madan <rishabhmadan96 at gmail.com> wrote:
> > @@ -136,6 +139,80 @@
> >
> > return None
> >
> > +class mergereleasenotes(object):
> > + def __init__(self, section, titlediter, nontitlediter):
> > + self.existing_points = self.gatherexistingnotes(section, titlediter,
> > + nontitlediter)
>
> This says it's a class, but it's really a function split into pieces. Let's try and find a better abstraction here. I'm not sure yet what that might be, but I'll give it some thought after 4.3-rc is cut, and we can sync up on IRC. (We can continue iterating on GSoC work during the freeze.)
I suggested a class because there were two sources of existing paragraphs
fed into and cached by the merge function.
m = merger()
m.feed(titledforsection(section))
m.feed(nontitledforsection(section))
for ...
if m(paragraphs):
addtitleditem(...)
> > + def gatherexistingnotes(self, section, titlediter, nontitlediter):
> > + existing_points = []
> > + titled_existing_points = converttostring(titlediter, title=True)
> > + nontitled_existing_points = converttostring(nontitlediter)
> > + existing_points = titled_existing_points + nontitled_existing_points
> > + return existing_points
> > +
> > + def checkmerge(self, ui, section, paragraphs, title=False):
> > + incoming_str = converttostring(iter(paragraphs), title)[0]
> > + if section == 'fix':
> > + issues = re.search(RE_ISSUE, incoming_str, re.IGNORECASE)
> > + if issues:
> > + issuenumber = issues.group()
> > + issuenumber = "".join(issuenumber.split())
> > + if any(issuenumber in s for s in self.existing_points):
> > + ui.write(_("\"%s\" already exists in notes; "
> > + "ignoring\n") % issuenumber)
> > + return False
> > + else:
> > + return True
> > + if len(incoming_str.split()) > 10:
> > + merge = similaritycheck(incoming_str, self.existing_points)
> > + if not merge:
> > + ui.write(_("\"%s\" already exists in notes file; "
> > + "ignoring\n") % incoming_str)
> > + return False
> > + else:
> > + return True
> > + else:
> > + return True
But these titled/nontitled and title= arguments smell. Maybe we only need
functions to convert paragraphs to texts, and compare them?
existing = converttitled(titled) + convertnontitled(nontitled)
issue = getissuenum(converttitled(paragraphs))
if findissue(existing, issue):
...
if similar(existing, converttitled(paragraphs)):
...
> [...]
>
> pacem in terris / мир / शान्ति / سَلاَم / 平和
> Kevin R. Bullock
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list