@@ -156,19 +156,19 @@ def add_patchwork_subparser(subparsers):
'patchwork', aliases=ALIASES['patchwork'],
help='Manage patchwork connection')
patchwork.defaults_cmds = [
- ['set-project', 'U-Boot'],
+ ['set-project', 'U-Boot', 'us'],
]
patchwork_subparsers = patchwork.add_subparsers(dest='subcmd')
gproj = patchwork_subparsers.add_parser('get-project')
gproj.add_argument(
- '-u', '--upstream-name',
- help='Upstream to get the project for')
+ 'remote', nargs='?',
+ help='Remote to get the project for')
uset = patchwork_subparsers.add_parser('set-project')
uset.add_argument(
'project_name', help="Patchwork project name, e.g. 'U-Boot'")
uset.add_argument(
- '-u', '--upstream-name',
- help='Upstream to associate this project with')
+ 'remote', nargs='?',
+ help='Remote to associate with this project')
patchwork_subparsers.add_parser('list')
return patchwork
@@ -272,12 +272,16 @@ def patchwork(args, test_db=None, pwork=None):
try:
cser.open_database()
if args.subcmd == 'set-project':
+ if not args.remote:
+ raise ValueError('Please specify the remote name')
if not pwork:
pwork = Patchwork(args.patchwork_url)
cser.project_set(pwork, args.project_name,
- ups=args.upstream_name)
+ ups=args.remote)
elif args.subcmd == 'get-project':
- ups = args.upstream_name
+ if not args.remote:
+ raise ValueError('Please specify the remote name')
+ ups = args.remote
info = cser.project_get(ups)
if not info:
raise ValueError(
@@ -287,7 +291,7 @@ def patchwork(args, test_db=None, pwork=None):
msg = (f"Project '{name}' patchwork-ID {pwid} "
f"link-name '{link_name}'")
if ups:
- msg += f" upstream '{ups}'"
+ msg += f" remote '{ups}'"
print(msg)
elif args.subcmd == 'list':
cser.project_list()
@@ -666,7 +666,7 @@ class Cseries(cser_helper.CseriesHelper):
msg = f"Project '{name}' patchwork-ID {proj_id} "
msg += f"link-name '{link_name}'"
if ups:
- msg += f" upstream '{ups}'"
+ msg += f" remote '{ups}'"
tout.notice(msg)
def project_get(self, ups=None):
@@ -689,7 +689,7 @@ class Cseries(cser_helper.CseriesHelper):
if not settings:
print('No patchwork projects configured')
return
- print(f"{'Project':20} {'ID':>4} {'Link name':15} Upstream")
+ print(f"{'Project':20} {'ID':>4} {'Link name':15} Remote")
border = f"{'-' * 20} {'-' * 4} {'-' * 15} {'-' * 15}"
print(border)
for name, proj_id, link_name, ups in settings:
@@ -2483,23 +2483,29 @@ Tested-by: Mary Smith <msmith@wibble.com> # yak
self.assertFalse(cser.project_get())
+ cser.db.upstream_add('us', 'https://us.example.com')
+ cser.db.commit()
+
pwork = Patchwork.for_testing(self._fake_patchwork_cser)
with terminal.capture() as (out, _):
self.run_args('-P', 'https://url', 'patchwork', 'set-project',
- 'U-Boot', pwork=pwork)
+ 'U-Boot', 'us', pwork=pwork)
self.assertEqual(
- f"Project 'U-Boot' patchwork-ID {self.PROJ_ID} link-name 'uboot'",
+ f"Project 'U-Boot' patchwork-ID {self.PROJ_ID} "
+ f"link-name 'uboot' remote 'us'",
out.getvalue().strip())
- name, pwid, link_name = cser.project_get()
+ name, pwid, link_name = cser.project_get('us')
self.assertEqual('U-Boot', name)
self.assertEqual(6, pwid)
self.assertEqual('uboot', link_name)
with terminal.capture() as (out, _):
- self.run_args('-P', 'https://url', 'patchwork', 'get-project')
+ self.run_args('-P', 'https://url', 'patchwork', 'get-project',
+ 'us')
self.assertEqual(
- f"Project 'U-Boot' patchwork-ID {self.PROJ_ID} link-name 'uboot'",
+ f"Project 'U-Boot' patchwork-ID {self.PROJ_ID} "
+ f"link-name 'uboot' remote 'us'",
out.getvalue().strip())
def test_patchwork_list(self):