From: Simon Glass <simon.glass@canonical.com>
When adding an upstream with 'us add', allow an optional project name
to be specified. This creates the settings row linking the remote to
its patchwork project in a single step, rather than requiring a
separate 'pw set-project' call.
Usage: patman us add origin https://example.com 'U-Boot'
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---
tools/patman/cmdline.py | 5 ++++-
tools/patman/control.py | 6 +++++-
tools/patman/cseries.py | 12 ++++++++++--
3 files changed, 19 insertions(+), 4 deletions(-)
@@ -406,7 +406,7 @@ def add_upstream_subparser(subparsers):
upstream = subparsers.add_parser('upstream', aliases=ALIASES['upstream'],
help='Manage upstream destinations')
upstream.defaults_cmds = [
- ['add', 'us', 'http://fred'],
+ ['add', 'us', 'http://fred', 'U-Boot'],
['delete', 'us'],
]
upstream_subparsers = upstream.add_subparsers(dest='subcmd')
@@ -416,6 +416,9 @@ def add_upstream_subparser(subparsers):
uadd.add_argument(
'url', help='URL to use for this upstream, e.g. '
"'https://gitlab.denx.de/u-boot/u-boot.git'")
+ uadd.add_argument(
+ 'project_name', nargs='?',
+ help="Patchwork project name, e.g. 'U-Boot'")
udel = upstream_subparsers.add_parser('delete')
udel.add_argument(
'remote_name',
@@ -239,7 +239,11 @@ def upstream(args, test_db=None):
try:
cser.open_database()
if args.subcmd == 'add':
- cser.upstream_add(args.remote_name, args.url)
+ pwork = None
+ if args.project_name:
+ pwork = Patchwork(args.patchwork_url)
+ cser.upstream_add(args.remote_name, args.url,
+ args.project_name, pwork)
elif args.subcmd == 'default':
if args.unset:
cser.upstream_set_default(None)
@@ -1145,16 +1145,24 @@ class Cseries(cser_helper.CseriesHelper):
self.rollback()
tout.info('Dry run completed')
- def upstream_add(self, name, url):
+ def upstream_add(self, name, url, project=None, pwork=None):
"""Add a new upstream tree
Args:
name (str): Name of the tree
url (str): URL for the tree
+ project (str or None): Patchwork project name to associate
+ pwork (Patchwork or None): Patchwork object for looking up
+ the project
"""
self.db.upstream_add(name, url)
+ if project:
+ self.project_set(pwork, project, ups=name, quiet=True)
self.commit()
- tout.notice(f"Added upstream '{name}' ({url})")
+ msg = f"Added upstream '{name}' ({url})"
+ if project:
+ msg += f" project '{project}'"
+ tout.notice(msg)
def upstream_list(self):
"""List the upstream repos