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 ...] 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 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) 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']