patches with different branch names included in their name are wrongly appended as succesive revisions of the same patch in a series. This is due to the patches being assigned to the same series after their prefixes got removed during series naming/search.
This change looks for an updated release name list from the Yocto wiki and keeps the release name in the series naming/search, effectively creating individual series for patches targeted to diferent releases. [YOCTO #10716] Signed-off-by: Jose Lamego <jose.a.lam...@linux.intel.com> --- patchwork/bin/parsemail.py | 28 ++++++++++++++++++++++++++++ patchwork/models.py | 5 ++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/patchwork/bin/parsemail.py b/patchwork/bin/parsemail.py index 1d27f24..ed081b5 100755 --- a/patchwork/bin/parsemail.py +++ b/patchwork/bin/parsemail.py @@ -678,6 +678,34 @@ prefixes_re = re.compile(r'^\[[^\]]*\]\s*') def strip_prefixes(subject): + # get last releases names from Yocto wiki page to keep them + # as part of the series name if present, since such patches + # are branch-specific + try: + from lxml import html + import requests + + page = requests.get( + 'https://wiki.yoctoproject.org/wiki/Stable_branch_maintenance') + tree = html.fromstring(page.content) + branches = tree.xpath('//table[@class="wikitable"]//td[count(\ +//th[contains(., "Branch name")]/preceding-sibling::th)+1]//text()') + # uncomment the following line to keep only last two branch names + # branches=branches[0:2] + branches[:] = [branch.replace('\n', '') for branch in branches] + subject = re.sub((r',?\d+/\d+\]'), ']', subject) + for branch in branches: + if "[" + branch + "]" in subject: + prefixes_re = re.compile(r'^\s*\[[^\]]*\]\s*') + branch_re = r"(?<=\[" + branch + "\])\s*(.*)" + branch_search = re.search(branch_re, subject) + if branch_search: + return "[" + branch + "] " + prefixes_re.sub( + '', branch_search.group(0)) + except ImportError: + pass + + prefixes_re = re.compile(r'^\[[^\]]*\]\s*') return prefixes_re.sub('', subject) diff --git a/patchwork/models.py b/patchwork/models.py index 7dd8120..d08e189 100644 --- a/patchwork/models.py +++ b/patchwork/models.py @@ -1047,13 +1047,16 @@ def _on_revision_complete(sender, revision, **kwargs): if series.name == SERIES_DEFAULT_NAME: name = series.latest_revision().ordered_patches()[0].name n = re.compile(r'((\[.*\]\s?)*\[.*\w+.*' - '(?P<comb_pref>\W+\d+\/\d+)+\s*\]\s?)' + '(?P<comb_pref>(\[|,)+\d+\/\d+\s*)\]\s?)' '|(?P<ind_pref>\[\d+\/\d+\]\s?)') if n.match(name): name = re.sub( n.match(name).group("comb_pref") or re.escape(n.match(name).group("ind_pref")), '', name) + re.sub(r'\[\]', '', name) + re.sub(r'\[\[+', '\[', name) + re.sub(r'\]\]+', '\]', name) c = len(series.latest_revision().ordered_patches()) # For one-patch series (1/1) without cover letter if c == 1: -- 2.7.4 -- _______________________________________________ yocto mailing list yocto@yoctoproject.org https://lists.yoctoproject.org/listinfo/yocto