mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-12-21 09:21:33 +01:00
patman: Improve Series support for patchwork links
Update Series with a way to better manage the Series-links lines in patches. Use this in the 'status' subcommand instead of the existing primitive method of expecting a link without a version prefix. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
dcf630b3be
commit
e8b64cfdbb
@ -20,8 +20,11 @@ except ImportError:
|
|||||||
from u_boot_pylib import gitutil
|
from u_boot_pylib import gitutil
|
||||||
from u_boot_pylib import terminal
|
from u_boot_pylib import terminal
|
||||||
from u_boot_pylib import tools
|
from u_boot_pylib import tools
|
||||||
|
from u_boot_pylib import tout
|
||||||
|
from patman import cseries
|
||||||
|
from patman import cser_helper
|
||||||
from patman import patchstream
|
from patman import patchstream
|
||||||
from patman import patchwork
|
from patman.patchwork import Patchwork
|
||||||
from patman import send
|
from patman import send
|
||||||
from patman import settings
|
from patman import settings
|
||||||
|
|
||||||
@ -70,9 +73,11 @@ def patchwork_status(branch, count, start, end, dest_branch, force,
|
|||||||
Raises:
|
Raises:
|
||||||
ValueError: if the branch has no Series-link value
|
ValueError: if the branch has no Series-link value
|
||||||
"""
|
"""
|
||||||
|
if not branch:
|
||||||
|
branch = gitutil.get_branch()
|
||||||
if count == -1:
|
if count == -1:
|
||||||
# Work out how many patches to send if we can
|
# Work out how many patches to send if we can
|
||||||
count = (gitutil.count_commits_to_branch(branch) - start)
|
count = gitutil.count_commits_to_branch(branch) - start
|
||||||
|
|
||||||
series = patchstream.get_metadata(branch, start, count - end)
|
series = patchstream.get_metadata(branch, start, count - end)
|
||||||
warnings = 0
|
warnings = 0
|
||||||
@ -89,21 +94,23 @@ def patchwork_status(branch, count, start, end, dest_branch, force,
|
|||||||
if not links:
|
if not links:
|
||||||
raise ValueError("Branch has no Series-links value")
|
raise ValueError("Branch has no Series-links value")
|
||||||
|
|
||||||
# Find the link without a version number (we don't support versions yet)
|
_, version = cser_helper.split_name_version(branch)
|
||||||
found = [link for link in links.split() if not ':' in link]
|
link = series.get_link_for_version(version, links)
|
||||||
if not found:
|
if not link:
|
||||||
raise ValueError('Series-links has no current version (without :)')
|
raise ValueError('Series-links has no link for v{version}')
|
||||||
|
tout.debug(f"Link '{link}")
|
||||||
|
|
||||||
# Allow the series to override the URL
|
# Allow the series to override the URL
|
||||||
if 'patchwork_url' in series:
|
if 'patchwork_url' in series:
|
||||||
url = series.patchwork_url
|
url = series.patchwork_url
|
||||||
pwork = patchwork.Patchwork(url, single_thread=single_thread)
|
pwork = Patchwork(url, single_thread=single_thread)
|
||||||
|
|
||||||
# Import this here to avoid failing on other commands if the dependencies
|
# Import this here to avoid failing on other commands if the dependencies
|
||||||
# are not present
|
# are not present
|
||||||
from patman import status
|
from patman import status
|
||||||
status.check_and_show_status(series, found[0], branch, dest_branch, force,
|
pwork = Patchwork(url)
|
||||||
show_comments, pwork)
|
status.check_and_show_status(series, link, branch, dest_branch, force,
|
||||||
|
show_comments, False, pwork)
|
||||||
|
|
||||||
|
|
||||||
def do_patman(args):
|
def do_patman(args):
|
||||||
|
|||||||
@ -430,3 +430,58 @@ class Series(dict):
|
|||||||
if self.get('postfix'):
|
if self.get('postfix'):
|
||||||
postfix = ' %s' % self['postfix']
|
postfix = ' %s' % self['postfix']
|
||||||
return '%s%sPATCH%s%s' % (git_prefix, prefix, postfix, version)
|
return '%s%sPATCH%s%s' % (git_prefix, prefix, postfix, version)
|
||||||
|
|
||||||
|
def get_links(self, links_str=None, cur_version=None):
|
||||||
|
"""Look up the patchwork links for each version
|
||||||
|
|
||||||
|
Args:
|
||||||
|
links_str (str): Links string to parse, or None to use self.links
|
||||||
|
cur_version (int): Default version to assume for un-versioned links,
|
||||||
|
or None to use self.version
|
||||||
|
|
||||||
|
Return:
|
||||||
|
dict:
|
||||||
|
key (int): Version number
|
||||||
|
value (str): Link string
|
||||||
|
"""
|
||||||
|
if links_str is None:
|
||||||
|
links_str = self.links if 'links' in self else ''
|
||||||
|
if cur_version is None:
|
||||||
|
cur_version = int(self.version) if 'version' in self else 1
|
||||||
|
assert isinstance(cur_version, int)
|
||||||
|
links = {}
|
||||||
|
for item in links_str.split():
|
||||||
|
if ':' in item:
|
||||||
|
version, link = item.split(':')
|
||||||
|
links[int(version)] = link
|
||||||
|
else:
|
||||||
|
links[cur_version] = item
|
||||||
|
return links
|
||||||
|
|
||||||
|
def build_links(self, links):
|
||||||
|
"""Build a string containing the links
|
||||||
|
|
||||||
|
Args:
|
||||||
|
links (dict):
|
||||||
|
key (int): Version number
|
||||||
|
value (str): Link string
|
||||||
|
|
||||||
|
Return:
|
||||||
|
str: Link string, e.g. '2:4433 1:2872'
|
||||||
|
"""
|
||||||
|
out = ''
|
||||||
|
for vers in sorted(links.keys(), reverse=True):
|
||||||
|
out += f' {vers}:{links[vers]}'
|
||||||
|
return out[1:]
|
||||||
|
|
||||||
|
def get_link_for_version(self, find_vers, links_str=None):
|
||||||
|
"""Look up the patchwork link for a particular version
|
||||||
|
|
||||||
|
Args:
|
||||||
|
find_vers (int): Version to find
|
||||||
|
links_str (str): Links string to parse, or None to use self.links
|
||||||
|
|
||||||
|
Return:
|
||||||
|
str: Series-links entry for that version, or None if not found
|
||||||
|
"""
|
||||||
|
return self.get_links(links_str).get(find_vers)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user