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(-) diff --git a/tools/patman/cmdline.py b/tools/patman/cmdline.py index a1697994571..8df9966ec6d 100644 --- a/tools/patman/cmdline.py +++ b/tools/patman/cmdline.py @@ -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', diff --git a/tools/patman/control.py b/tools/patman/control.py index 4363802cb3b..c8d7405f7e8 100644 --- a/tools/patman/control.py +++ b/tools/patman/control.py @@ -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) diff --git a/tools/patman/cseries.py b/tools/patman/cseries.py index 7237dd575cd..c48267964a1 100644 --- a/tools/patman/cseries.py +++ b/tools/patman/cseries.py @@ -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 -- 2.43.0