From b74b6e9ed26463042609156f3e7084de984210b7 Mon Sep 17 00:00:00 2001 From: andrepapoti Date: Tue, 19 Mar 2024 02:13:57 -0300 Subject: [PATCH 1/4] modules: Add series modules Signed-off-by: andrepapoti --- pwclient/series.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 pwclient/series.py diff --git a/pwclient/series.py b/pwclient/series.py new file mode 100644 index 0000000..1efdd1c --- /dev/null +++ b/pwclient/series.py @@ -0,0 +1,8 @@ +import sys + +def link(api, series_ids): + try: + api.series_linking(series_ids) + except Exception as exc: + print(str(exc), file=sys.stderr) + sys.exit(1) From 04244c3ee270d7070eecb9da550b4402134f5b17 Mon Sep 17 00:00:00 2001 From: andrepapoti Date: Tue, 19 Mar 2024 02:12:44 -0300 Subject: [PATCH 2/4] shell: Add 'linkseries' action Signed-off-by: andrepapoti --- pwclient/shell.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pwclient/shell.py b/pwclient/shell.py index 631bbbd..d973f51 100644 --- a/pwclient/shell.py +++ b/pwclient/shell.py @@ -14,6 +14,7 @@ from . import parser from . import patches from . import projects +from . import series from . import states from . import utils @@ -186,6 +187,12 @@ def main(argv=sys.argv[1:]): sys.stderr.write("Apply failed with exit status %d\n" % ret) sys.exit(1) + elif action == 'linkseries': + if len(patch_ids) < 2: + sys.stderr.write("At least two ids are necessary to link series") + sys.exit(1) + series.link(api, patch_ids) + elif action == 'git_am': cmd = ['git', 'am'] From 95a7401fbf40eb22c19b4288057c35d7b84b4101 Mon Sep 17 00:00:00 2001 From: andrepapoti Date: Tue, 19 Mar 2024 02:13:35 -0300 Subject: [PATCH 3/4] api: Add series linking API Signed-off-by: andrepapoti --- pwclient/api.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pwclient/api.py b/pwclient/api.py index 3817935..4fceea5 100644 --- a/pwclient/api.py +++ b/pwclient/api.py @@ -381,6 +381,12 @@ def patch_set( 'Error updating patch: %s' % f.faultString ) + + # series + + def series_linking(self, series_ids): + raise exceptions.APIError('XMLRPC API does not support series linking') + # states def state_list(self, search_str=None, max_count=0): @@ -668,6 +674,17 @@ def person_get(self, person_id): person = self._detail('people', person_id) return self._person_to_dict(person) + # series + + def series_linking(self, series_ids): + for index, series_id_1 in enumerate(series_ids): + for series_id_2 in series_ids[index + 1:]: + print(f'Linking series of id\'s {series_id_1} and {series_id_2}') + url = f'{self._server}/series/{series_id_1}/link/{series_id_2}' + self._put(url, {}) + print('Finished linking series') + + # patch @staticmethod From c1872886884d79ed1ad13f3ade2a20761e6c1adc Mon Sep 17 00:00:00 2001 From: andrepapoti Date: Tue, 19 Mar 2024 09:55:12 -0300 Subject: [PATCH 4/4] man: Add documentation for 'linkseries' Signed-off-by: andrepapoti --- man/pwclient.1 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/man/pwclient.1 b/man/pwclient.1 index f48d17c..5bdfba7 100644 --- a/man/pwclient.1 +++ b/man/pwclient.1 @@ -44,6 +44,9 @@ view a patch \fBpwclient\fR \fI\,update\/\fR update patch .TP +\fBpwclient\fR \fI\,linkseries\/\fR +link two or more series to each other +.TP \fBpwclient\fR \fI\,list\/\fR list patches using optional filters .TP @@ -95,6 +98,13 @@ pass '\-\-3way' to 'git\-am' \fB\-m\fR, \fB\-\-msgid\fR pass '\-\-message\-id' to 'git\-am' +.SH COMMAND \fI\,'pwclient linkseries'\/\fR +usage: pwclient link_series [\-\-help] [\-h] [PATCH_ID ...] + +.TP +\fBPATCH_ID\fR +patch ID + .SH COMMAND \fI\,'pwclient get'\/\fR usage: pwclient get [\-\-help] [\-h] [\-p PROJECT] PATCH_ID [PATCH_ID ...]