diff options
author | V3n3RiX <venerix@koprulu.sector> | 2024-06-27 07:59:40 +0100 |
---|---|---|
committer | V3n3RiX <venerix@koprulu.sector> | 2024-06-27 07:59:40 +0100 |
commit | d2ed973482fdd800013658e83a61709b29e0a80f (patch) | |
tree | 57ea7666a57b5a05a4c8866e4915e90b4a6e7c94 /dev-util/rbtools | |
parent | 9f6a82a85d400d6ae7de04c43cee88dbc6bc4da0 (diff) |
gentoo auto-resync : 27:06:2024 - 07:59:39
Diffstat (limited to 'dev-util/rbtools')
-rw-r--r-- | dev-util/rbtools/Manifest | 3 | ||||
-rw-r--r-- | dev-util/rbtools/files/rbtools-5.0-scmtool-crash.patch | 483 | ||||
-rw-r--r-- | dev-util/rbtools/rbtools-5.0-r1.ebuild (renamed from dev-util/rbtools/rbtools-5.0.ebuild) | 4 |
3 files changed, 487 insertions, 3 deletions
diff --git a/dev-util/rbtools/Manifest b/dev-util/rbtools/Manifest index 79c616128c78..606dc6d083ea 100644 --- a/dev-util/rbtools/Manifest +++ b/dev-util/rbtools/Manifest @@ -1,6 +1,7 @@ AUX rbtools-5.0-importlib-resources.patch 425 BLAKE2B 6ea4e39cd033b468f8e3ecdef564e161299f539580890a5ba4930e5ceee7a339ecaf4c77f88d0b700019cfd1319369061262bef7301d2e84201d4af26e12a77c SHA512 44ebe3eced9f5fbee2ecfe891959d37e83699dd74677a4aef614de39ffc2aab69dbb79f0cf0df1921fd73cd70e61c89b9b1f326dbef72bb5f93aab71f118262d +AUX rbtools-5.0-scmtool-crash.patch 18177 BLAKE2B 67d07d40ecaaf75ac2c2908f78127f8821f37cb499c9e46d464335f989d94e776dcc0d1a64fed8e48218e566d3b342ce0863c00921322a1ac1cece4ac8c70b13 SHA512 a9bbaed7b467707124d2f505d93fae76d5d3f1a4ac548736b762357585a17a7c6e31bffa0d631e6158b088cd544056af50dab175f68674ca6f962e984c4cf45f DIST rbtools-4.1.tar.gz 619541 BLAKE2B 9b1aeca4f139a0189affb873363dba8f6d13eb954d4872939c543f6d91c00b09b2452cc379d4d99450c05d3d44a1996e910ff512ba9849292a7b705ce01be654 SHA512 58aa58ce6c55d4d3be9f221c493c8a3c15537776ff4e28be1ea44c0441f1dd9877ac9145066fdceb90d392c75cf29ec80e7efd154b0a2f1893422b65a0189ea0 DIST rbtools-5.0.tar.gz 649338 BLAKE2B c6a08004e7c8ba17936865e53b78e086ec74e8f5fee7ecc124750f3bf24b9b52ab8a26d1caa7010cdd2822463fcb27b8e5c5f757068924e22d3e59268166f7bf SHA512 7fbc5198fc89ee911a3cc487ead094d46213cfc4f85ab01cf22bd2a628559acdaaed138b430b08aa94ea25dec1179bf7c28349ac8226d632a6112ec83e2b57b7 EBUILD rbtools-4.1.ebuild 1421 BLAKE2B e3ad76841f38a456551bf7180645059c2dbd54be236eac0b4407b29936724d74e1bdac8197ab812e731eb5c09c49e92b0c7f83b5b96ed696f605fb4d1eb54a0c SHA512 c21b192ef90417f5e5726ae2158de614079a16a10275fd589b738788ed5f005cd0eeb33801435ada41b4932373ca04e10d62dfb8aa318ced52f39290c697c94a -EBUILD rbtools-5.0.ebuild 1537 BLAKE2B 594e197b4fc87c616d6f045d5d3028e65336f2bcb3105f6bd7c3bbade13d75e126ee685a512125dd6a412f337a1a29b917047e13193b343280940ecebafb3e0e SHA512 3cb89e3fbb36f4a63b0873d3ad5bdf02b19cf06853dc412c330dc0f8ce82061021b4ce67b97d6aa1665eafc87976cc3e11508a162e036e1693850c701afe64a5 +EBUILD rbtools-5.0-r1.ebuild 1580 BLAKE2B 93d644d3f6b0ae7ab73b74e9841cd60d60b5bd817a7501cfcb3381b53f3e4d3bc8389dc9fc27642ed2a18aeec0f8f7c8898d4f61b775dd291c21f59c562affc4 SHA512 89b375e100c567602654fa5a7361cabd4438fb59bbf781fe4f78d0124bfe63c2cd9abf6f07415437e1a50435e6ecfff0b4296fcf3907f0f5a3aede7c8400ea6c MISC metadata.xml 310 BLAKE2B d4825072b11fd2f9cad88fd9f3e0670d42f997f2f49034539ea9cab13751e08d7f4153fc7534d4931baa55cab6a4bb1ae65f1790fce12d784dfab1eb747a344b SHA512 4b2b81003437f8f97af748509521ce7f946df9e0fcc4ffbabf4de5289b046eeee25d0e1acaf3604fa09995965728b7e4cd10233074ddc4e9bed54a68f26e6613 diff --git a/dev-util/rbtools/files/rbtools-5.0-scmtool-crash.patch b/dev-util/rbtools/files/rbtools-5.0-scmtool-crash.patch new file mode 100644 index 000000000000..28783545edef --- /dev/null +++ b/dev-util/rbtools/files/rbtools-5.0-scmtool-crash.patch @@ -0,0 +1,483 @@ +From 36efa0724e3b4d941aa0554b1d82934319d25ce3 Mon Sep 17 00:00:00 2001 +From: David Trowbridge <trowbrds@gmail.com> +Date: Tue, 11 Jun 2024 17:22:15 -0600 +Subject: [PATCH] Use SCMTool IDs to look up repositories when possible. + +Many versions of Review Board currently have a bug where sending an +unknown value in the tool= parameter to the repository list API would +cause a crash. We'll be shipping a fix for that, but unfortunately there +are a variety of released versions where the Git and Clearcase clients +can trigger this crash on servers that do not have Power Pack installed. + +This change fixes the RBTools side to not include the Power Pack SCMTool +names, which will avoid the problem for existing servers. For new +servers, we'll be shipping a server-side fix that fixes the crash, adds +the SCMTool IDs to the capabilities, and allows us to pass SCMTool IDs +rather than names to the repository list API. If we see the IDs in the +capability blob, we can assume that we can pass the IDs, including +potentially unknown IDs. + +This also fixes a problem where we were sometimes accessing the +repository list API twice with exactly the same parameters. + +Testing Done: +- Ran unit tests. +- Verified that the repository list API was accessed using SCMTool names + that did not include potentially missing ones when running against an + older server. +- Verified that the repository list API was accessed with SCMTool IDs + when running against a server with the new API fixes. + +Reviewed at https://reviews.reviewboard.org/r/13973/ +--- + rbtools/clients/base/scmclient.py | 59 +++++++++++++++++++++++++------ + rbtools/clients/bazaar.py | 1 + + rbtools/clients/clearcase.py | 10 +++++- + rbtools/clients/cvs.py | 1 + + rbtools/clients/git.py | 10 +++++- + rbtools/clients/mercurial.py | 1 + + rbtools/clients/perforce.py | 1 + + rbtools/clients/plastic.py | 1 + + rbtools/clients/svn.py | 1 + + rbtools/clients/tfs.py | 1 + + rbtools/commands/base/commands.py | 3 +- + rbtools/commands/setup_repo.py | 25 +++++++++---- + rbtools/utils/repository.py | 58 ++++++++++++++++++++++-------- + 13 files changed, 139 insertions(+), 33 deletions(-) + +diff --git a/rbtools/clients/base/scmclient.py b/rbtools/clients/base/scmclient.py +index c053b91b..9f56c084 100644 +--- a/rbtools/clients/base/scmclient.py ++++ b/rbtools/clients/base/scmclient.py +@@ -9,24 +9,24 @@ + import argparse + import logging + import re +-from typing import (Any, Dict, List, Mapping, Optional, Tuple, Union, cast, +- TYPE_CHECKING) ++from typing import (Any, cast, ClassVar, Dict, List, Mapping, Optional, ++ TYPE_CHECKING, Tuple, Union) + + from typing_extensions import NotRequired, TypedDict, final + +-from rbtools.api.capabilities import Capabilities +-from rbtools.api.resource import (ItemResource, +- ListResource, +- ReviewRequestResource) + from rbtools.clients.base.patch import PatchAuthor, PatchResult +-from rbtools.clients.base.repository import RepositoryInfo + from rbtools.clients.errors import SCMClientDependencyError, SCMError + from rbtools.deprecation import RemovedInRBTools50Warning +-from rbtools.diffs.tools.base import BaseDiffTool + from rbtools.diffs.tools.registry import diff_tools_registry + from rbtools.utils.process import execute + + if TYPE_CHECKING: ++ from rbtools.api.capabilities import Capabilities ++ from rbtools.api.resource import (ItemResource, ++ ListResource, ++ ReviewRequestResource) ++ from rbtools.clients.base.repository import RepositoryInfo ++ from rbtools.diffs.tools.base import BaseDiffTool + from rbtools.config import RBToolsConfig + + +@@ -281,14 +281,27 @@ class BaseSCMClient(object): + #: str + name: str = '' + +- #: A comma-separated list of SCMClient names on the server ++ #: A comma-separated list of SCMClient names on the server. + #: + #: Version Added: + #: 3.0 + #: + #: Type: + #: str +- server_tool_names: Optional[str] = None ++ server_tool_names: ClassVar[Optional[str]] = None ++ ++ #: A comma-separated list of SCMClient IDs on the server. ++ #: ++ #: This supersedes :py:attr:`server_tool_names` when running on a version ++ #: of Review Board that supports passing tool IDs to the repositories ++ #: list API. ++ #: ++ #: Version Added: ++ #: 5.0.1 ++ #: ++ #: Type: ++ #: str ++ server_tool_ids: ClassVar[Optional[List[str]]] = None + + #: Whether this tool requires a command line diff tool. + #: +@@ -692,6 +705,32 @@ def get_diff_tool(self) -> Optional[BaseDiffTool]: + + return diff_tool + ++ def get_server_tool_names( ++ self, ++ capabilities: Optional[Capabilities], ++ ) -> Optional[str]: ++ """Return the list of supported tool names on the server. ++ ++ Version Added: ++ 5.0.1 ++ ++ Args: ++ capabilities (rbtools.api.capabilities.Capabilities): ++ The server capabilities, if present. ++ ++ Returns: ++ str: ++ A comma-separated list of server-side tool names to match with. ++ """ ++ if (capabilities is not None and ++ capabilities.get_capability('scmtools', 'supported_tools') and ++ self.server_tool_ids is not None): ++ # Versions of Review Board that have this capability allow us to ++ # pass SCMTool IDs rather than names. ++ return ','.join(self.server_tool_ids) ++ else: ++ return self.server_tool_names ++ + def find_matching_server_repository( + self, + repositories: ListResource, +diff --git a/rbtools/clients/bazaar.py b/rbtools/clients/bazaar.py +index 0e39315d..4174c010 100644 +--- a/rbtools/clients/bazaar.py ++++ b/rbtools/clients/bazaar.py +@@ -37,6 +37,7 @@ class BazaarClient(BaseSCMClient): + scmclient_id = 'bazaar' + name = 'Bazaar' + server_tool_names = 'Bazaar' ++ server_tool_ids = ['bazaar'] + supports_diff_exclude_patterns = True + supports_parent_diffs = True + can_branch = True +diff --git a/rbtools/clients/clearcase.py b/rbtools/clients/clearcase.py +index f9c8762e..e2c04633 100644 +--- a/rbtools/clients/clearcase.py ++++ b/rbtools/clients/clearcase.py +@@ -392,7 +392,15 @@ class ClearCaseClient(BaseSCMClient): + + scmclient_id = 'clearcase' + name = 'VersionVault / ClearCase' +- server_tool_names = 'ClearCase,VersionVault / ClearCase' ++ ++ # Review Board versions that use the old names-based repositories/?tool= ++ # API parameter also have a bug where a missing name could cause a ++ # server-side crash. This was making it so servers that did not have Power ++ # Pack were failing when we tried to make a query that included the ++ # VersionVault name. We therefore only include it when we know the server ++ # can use server_tool_ids instead. ++ server_tool_names = 'ClearCase' ++ server_tool_ids = ['clearcase', 'versionvault'] + + requires_diff_tool = True + +diff --git a/rbtools/clients/cvs.py b/rbtools/clients/cvs.py +index 98354e8b..dd2c72ef 100644 +--- a/rbtools/clients/cvs.py ++++ b/rbtools/clients/cvs.py +@@ -28,6 +28,7 @@ class CVSClient(BaseSCMClient): + scmclient_id = 'cvs' + name = 'CVS' + server_tool_names = 'CVS' ++ server_tool_ids = ['cvs'] + supports_diff_exclude_patterns = True + supports_patch_revert = True + +diff --git a/rbtools/clients/git.py b/rbtools/clients/git.py +index f4b96cb6..431fd7c6 100644 +--- a/rbtools/clients/git.py ++++ b/rbtools/clients/git.py +@@ -76,7 +76,15 @@ class GitClient(BaseSCMClient): + + scmclient_id = 'git' + name = 'Git' +- server_tool_names = 'Git,Perforce,Subversion,Team Foundation Server (git)' ++ ++ # Review Board versions that use the old names-based repositories/?tool= ++ # API parameter also have a bug where a missing name could cause a ++ # server-side crash. This was making it so servers that did not have Power ++ # Pack were failing when we tried to make a query that included the TFS-Git ++ # name. We therefore only include it when we know the server can use ++ # server_tool_ids instead. ++ server_tool_names = 'Git,Perforce,Subversion' ++ server_tool_ids = ['git', 'perforce', 'subversion', 'tfs_git'] + + supports_commit_history = True + supports_diff_exclude_patterns = True +diff --git a/rbtools/clients/mercurial.py b/rbtools/clients/mercurial.py +index 2ee473c9..6f1c5ea0 100644 +--- a/rbtools/clients/mercurial.py ++++ b/rbtools/clients/mercurial.py +@@ -64,6 +64,7 @@ class MercurialClient(BaseSCMClient): + scmclient_id = 'mercurial' + name = 'Mercurial' + server_tool_names = 'Mercurial,Subversion' ++ server_tool_ids = ['mercurial', 'subversion'] + + supports_commit_history = True + supports_diff_exclude_patterns = True +diff --git a/rbtools/clients/perforce.py b/rbtools/clients/perforce.py +index f5892073..4f5d7fb1 100644 +--- a/rbtools/clients/perforce.py ++++ b/rbtools/clients/perforce.py +@@ -445,6 +445,7 @@ class PerforceClient(BaseSCMClient): + scmclient_id = 'perforce' + name = 'Perforce' + server_tool_names = 'Perforce' ++ server_tool_ids = ['perforce'] + + requires_diff_tool = True + +diff --git a/rbtools/clients/plastic.py b/rbtools/clients/plastic.py +index c45c7abd..3bec215a 100644 +--- a/rbtools/clients/plastic.py ++++ b/rbtools/clients/plastic.py +@@ -28,6 +28,7 @@ class PlasticClient(BaseSCMClient): + scmclient_id = 'plastic' + name = 'Plastic' + server_tool_names = 'Plastic SCM' ++ server_tool_ids = ['plastic'] + supports_changesets = True + supports_patch_revert = True + +diff --git a/rbtools/clients/svn.py b/rbtools/clients/svn.py +index 34cdffcb..6d0352cc 100644 +--- a/rbtools/clients/svn.py ++++ b/rbtools/clients/svn.py +@@ -52,6 +52,7 @@ class SVNClient(BaseSCMClient): + scmclient_id = 'svn' + name = 'Subversion' + server_tool_names = 'Subversion' ++ server_tool_ids = ['subversion'] + + requires_diff_tool = True + +diff --git a/rbtools/clients/tfs.py b/rbtools/clients/tfs.py +index 2b70fae3..7b02d3de 100644 +--- a/rbtools/clients/tfs.py ++++ b/rbtools/clients/tfs.py +@@ -1321,6 +1321,7 @@ class TFSClient(BaseSCMClient): + scmclient_id = 'tfs' + name = 'Team Foundation Server' + server_tool_names = 'Team Foundation Server' ++ server_tool_ids = ['tfs'] + + requires_diff_tool = True + +diff --git a/rbtools/commands/base/commands.py b/rbtools/commands/base/commands.py +index 3313a689..d4e20f61 100644 +--- a/rbtools/commands/base/commands.py ++++ b/rbtools/commands/base/commands.py +@@ -939,7 +939,8 @@ def initialize(self) -> None: + api_root=self.api_root, + tool=tool, + repository_name=options.repository_name, +- repository_paths=repository_info.path) ++ repository_paths=repository_info.path, ++ capabilities=self.capabilities) + self.repository = repository + + if repository: +diff --git a/rbtools/commands/setup_repo.py b/rbtools/commands/setup_repo.py +index 615bc9e3..9905d1b5 100644 +--- a/rbtools/commands/setup_repo.py ++++ b/rbtools/commands/setup_repo.py +@@ -1,14 +1,20 @@ + """Implementation of rbt setup-repo.""" + ++from __future__ import annotations ++ + import difflib + import os + import textwrap ++from typing import Optional, TYPE_CHECKING, Union + + from rbtools.commands.base import BaseCommand, CommandError + from rbtools.config.loader import CONFIG_FILENAME + from rbtools.utils.console import confirm, confirm_select + from rbtools.utils.repository import get_repository_resource + ++if TYPE_CHECKING: ++ from rbtools.api.resource import ItemResource, RootResource ++ + + class SetupRepo(BaseCommand): + """Configure a repository to point to a Review Board server. +@@ -38,22 +44,27 @@ class SetupRepo(BaseCommand): + BaseCommand.tfs_options, + ] + +- def prompt_rb_repository(self, local_tool_name, server_tool_names, +- repository_paths, api_root): ++ def prompt_rb_repository( ++ self, ++ local_tool_name: str, ++ server_tool_names: Optional[str], ++ repository_paths: Optional[Union[str, list[str]]], ++ api_root: RootResource, ++ ) -> Optional[ItemResource]: + """Interactively prompt to select a matching repository. + + The user is prompted to choose a matching repository found on the + Review Board server. + + Args: +- local_tool_name (unicode): ++ local_tool_name (str): + The local name of the detected tool. + +- server_tool_names (unicode): ++ server_tool_names (str): + A comma-separated list of potentially matching SCMTool names in + the Review Board server. + +- repository_paths (list or unicode, optional): ++ repository_paths (list or str, optional): + A list of potential paths to match for the repository. + + api_root (rbtools.api.resource.RootResource): +@@ -192,9 +203,11 @@ def main(self, *args): + while True: + self.stdout.new_line() + self.stdout.write('Current server: %s' % server) ++ ++ tool_names = tool.get_server_tool_names(self.capabilities) + selected_repo = self.prompt_rb_repository( + local_tool_name=tool.name, +- server_tool_names=tool.server_tool_names, ++ server_tool_names=tool_names, + repository_paths=repository_info.path, + api_root=api_root) + +diff --git a/rbtools/utils/repository.py b/rbtools/utils/repository.py +index d30d2cc0..d3ec280d 100644 +--- a/rbtools/utils/repository.py ++++ b/rbtools/utils/repository.py +@@ -1,17 +1,34 @@ + """Utility functions for working with repositories.""" + ++from __future__ import annotations ++ ++from typing import Optional, TYPE_CHECKING, Union ++ + from rbtools.api.errors import APIError + ++if TYPE_CHECKING: ++ from rbtools.api.capabilities import Capabilities ++ from rbtools.api.resource import ItemResource, RootResource ++ from rbtools.clients.base.repository import RepositoryInfo ++ from rbtools.clients.base.scmclient import BaseSCMClient ++ + +-def get_repository_resource(api_root, +- tool=None, +- repository_name=None, +- repository_paths=None): ++def get_repository_resource( ++ api_root: RootResource, ++ tool: Optional[BaseSCMClient] = None, ++ repository_name: Optional[str] = None, ++ repository_paths: Optional[Union[str, list[str]]] = None, ++ capabilities: Optional[Capabilities] = None, ++) -> tuple[Optional[ItemResource], Optional[ItemResource]]: + """Return the API resource for the matching repository on the server. + + Version Added: + 3.0 + ++ Version Changed: ++ 5.0.1: ++ Added the ``capabilities`` argument. ++ + Args: + api_root (rbtools.api.resource.RootResource): + The root resource for the API. +@@ -19,12 +36,15 @@ def get_repository_resource(api_root, + tool (rbtools.clients.base.BaseSCMClient, optional): + The SCM client corresponding to the local working directory. + +- repository_name (unicode, optional): ++ repository_name (str, optional): + An explicit repository name provided by the local configuration. + +- repository_paths (list or unicode, optional): ++ repository_paths (list or str, optional): + A list of potential paths to match for the repository. + ++ capabilities (rbtools.api.capabilities.Capabilities, optional): ++ The capabilities fetched from the server. ++ + Returns: + tuple of rbtools.api.resource.ItemResource: + A 2-tuple of :py:class:`~rbtools.api.resource.ItemResource`. The first +@@ -47,8 +67,11 @@ def _get_info(repository): + 'only_links': 'info,diff_file_attachments', + } + +- if tool and tool.server_tool_names: +- query['tool'] = tool.server_tool_names ++ if tool: ++ server_tool_names = tool.get_server_tool_names(capabilities) ++ ++ if server_tool_names: ++ query['tool'] = server_tool_names + + if repository_name: + query['name'] = repository_name +@@ -70,9 +93,12 @@ def _get_info(repository): + # configured path than the client. In that case, we want to try again + # without filtering by path, and ask each tool to match based on other + # conditions. +- query.pop('path', None) ++ if 'path' in query: ++ query.pop('path', None) + +- all_repositories = api_root.get_repositories(**query) ++ all_repositories = api_root.get_repositories(**query) ++ else: ++ all_repositories = repositories + + if all_repositories.total_results > 0 and tool: + repository, info = tool.find_matching_server_repository( +@@ -93,7 +119,11 @@ def _get_info(repository): + return None, None + + +-def get_repository_id(repository_info, api_root, repository_name=None): ++def get_repository_id( ++ repository_info: RepositoryInfo, ++ api_root: RootResource, ++ repository_name: Optional[str] = None, ++) -> Optional[int]: + """Return the ID of a repository from the server. + + This will look up all accessible repositories on the server and try to +@@ -106,18 +136,18 @@ def get_repository_id(repository_info, api_root, repository_name=None): + api_root (rbtools.api.resource.RootResource): + The root resource for the API. + +- repository_name (unicode, optional): ++ repository_name (str, optional): + An explicit repository name provided by local configuration. + + Returns: + int: + The ID of the repository, or ``None`` if not found. + """ +- repository, info = get_repository_resource( ++ repository = get_repository_resource( + api_root, + tool=None, + repository_name=repository_name, +- repository_paths=repository_info.path) ++ repository_paths=repository_info.path)[0] + + if repository: + return repository.id diff --git a/dev-util/rbtools/rbtools-5.0.ebuild b/dev-util/rbtools/rbtools-5.0-r1.ebuild index 6a99f1af7e31..e3d01d77608e 100644 --- a/dev-util/rbtools/rbtools-5.0.ebuild +++ b/dev-util/rbtools/rbtools-5.0-r1.ebuild @@ -16,7 +16,7 @@ S="${WORKDIR}/rbtools-release-${PV}" LICENSE="MIT" SLOT="0" KEYWORDS="~amd64 ~x86" -IUSE="" +IUSE="test" RDEPEND=" >=dev-python/certifi-2023.5.7[${PYTHON_USEDEP}] @@ -40,7 +40,7 @@ BDEPEND=" ) " -PATCHES=( "${FILESDIR}/${P}-importlib-resources.patch" ) +PATCHES=( "${FILESDIR}/${P}-importlib-resources.patch" "${FILESDIR}/${P}-scmtool-crash.patch" ) DOCS=( AUTHORS NEWS README.md ) |