From 819153b703df5ff0c54c73f2f820a1a59fed93c5 Mon Sep 17 00:00:00 2001 From: Egbert Eich Date: Sat, 29 Mar 2025 12:47:13 +0100 Subject: [PATCH 1/2] Consolidate working copy modification check dialog into a function. Signed-off-by: Egbert Eich --- osc/commandline.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/osc/commandline.py b/osc/commandline.py index 6d1658cc..8cc0e6b3 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -739,6 +739,16 @@ class Osc(cmdln.Cmdln): return project.replace(conf.config['project_separator'], ':') return project + def modified_wc_dialog(self, package): + from .core import raw_input + + modified = [i for i in package.filenamelist if package.status(i) != " " and package.status(i) != "?"] + if len(modified) > 0: + print("Your working copy has local modifications.") + repl = raw_input("Proceed without committing the local changes? (y|N) ") + if repl != "y": + raise oscerr.UserAbort() + def add_global_options(self, parser, suppress=False): def _add_parser_arguments_from_data(argument_parser, data): @@ -2211,12 +2221,8 @@ class Osc(cmdln.Cmdln): sys.exit('Package \'%s\' is not a source link, so I cannot guess the submit target.\n' 'Please provide it the target via commandline arguments.' % p.name) - modified = [i for i in p.filenamelist if not p.status(i) in (' ', '?', 'S')] - if len(modified) > 0 and not opts.yes: - print('Your working copy has local modifications.') - repl = raw_input('Proceed without committing the local changes? (y|N) ') - if repl != 'y': - raise oscerr.UserAbort() + if not opts.yes: + self.modified_wc_dialog(p) elif len(args) >= 3: # get the arguments from the commandline src_project, src_package, dst_project = args[0:3] @@ -2433,12 +2439,7 @@ Please submit there instead, or use --nodevelproject to force direct submission. sys.exit('Package \'%s\' is not a source link, so I cannot guess the submit target.\n' 'Please provide it the target via commandline arguments.' % p.name) - modified = [i for i in p.filenamelist if p.status(i) != ' ' and p.status(i) != '?'] - if len(modified) > 0: - print('Your working copy has local modifications.') - repl = raw_input('Proceed without committing the local changes? (y|N) ') - if repl != 'y': - sys.exit(1) + self.modified_wc_dialog(p) elif len(args) >= 3: # get the arguments from the commandline src_project, src_package, dst_project = args[0:3] From 6a50e07f3a060f88a232f1de6b1474ae5e21eb78 Mon Sep 17 00:00:00 2001 From: Egbert Eich Date: Sat, 29 Mar 2025 17:37:00 +0100 Subject: [PATCH 2/2] When doing an mr from a working copy check for unchecked modifications Maintenance requests may be done from a working copy of a package to just update a single code stream at once. In this situation, this working copy may have been used to implement this change. Thus, like with submit requestes, check if the working copy has local changes that have not been checked in and warn the user about it. This should help to prevent resource-intensive accidents. Signed-off-by: Egbert Eich --- osc/commandline.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/osc/commandline.py b/osc/commandline.py index 8cc0e6b3..1e1bce4e 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -4228,11 +4228,13 @@ Please submit there instead, or use --nodevelproject to force direct submission. source_project = target_project = release_project = opt_sourceupdate = None source_packages = [] + local_package = None if len(args) == 0 and (is_project_dir(Path.cwd()) or is_package_dir(Path.cwd())): source_project = store_read_project(Path.cwd()) if is_package_dir(Path.cwd()): source_packages = [store_read_package(Path.cwd())] + local_package = Package(Path.cwd()) elif len(args) == 0: raise oscerr.WrongArgs('Too few arguments.') if len(args) > 0: @@ -4240,8 +4242,8 @@ Please submit there instead, or use --nodevelproject to force direct submission. if is_package_dir(Path.cwd()): source_project = store_read_project(Path.cwd()) source_packages = [store_read_package(Path.cwd())] - p = Package(Path.cwd()) - release_project = p.linkinfo.project + local_package = Package(Path.cwd()) + release_project = local_package.linkinfo.project else: raise oscerr.WrongArgs('No package directory') else: @@ -4259,6 +4261,9 @@ Please submit there instead, or use --nodevelproject to force direct submission. if source_project.startswith(default_branch): opt_sourceupdate = 'cleanup' + if local_package is not None: + self.modified_wc_dialog(local_package) + if opts.release_project: release_project = opts.release_project