Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for series linking #1

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions man/pwclient.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ...]

Expand Down
17 changes: 17 additions & 0 deletions pwclient/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions pwclient/series.py
Original file line number Diff line number Diff line change
@@ -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)
7 changes: 7 additions & 0 deletions pwclient/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from . import parser
from . import patches
from . import projects
from . import series
from . import states
from . import utils

Expand Down Expand Up @@ -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']

Expand Down