diff --git a/NEWS b/NEWS index 0f41137e..17c96fd6 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,10 @@ - support of added .changes in commit message template - make submit request listing fast by server side filtering - allow pulling of conflicting changes via "osc repairlink" +- delete commands consolidated: + * deleteprj and deletepac are obsolete. + * delete and rdelete take over +- enable package tracking by default - bugfix: templates in edit commit message causes an empty commit logs - osc sr create consumes DESTPRJ [DESTPKG] arguments only diff --git a/osc/cmdln.py b/osc/cmdln.py index 8a8a50bc..3873c0a3 100644 --- a/osc/cmdln.py +++ b/osc/cmdln.py @@ -650,7 +650,8 @@ class RawCmdln(cmd.Cmd): #log.debug("stripping %r from start of %s's help string", # to_strip, cmdname) doc = doc[len(to_strip):].lstrip() - linedata.append( (cmdstr, doc) ) + if not getattr(self._get_cmd_handler(cmdname), "hidden", None): + linedata.append( (cmdstr, doc) ) if linedata: subindent = indent + ' '*4 @@ -982,6 +983,20 @@ def option(*args, **kwargs): return f return decorate +def hide(*args): + """For obsolete calls, hide them in help listings. + + Example: + class MyShell(cmdln.Cmdln): + @cmdln.hide() + def do_shell(self, argv): + #...implement 'shell' command + """ + def decorate(f): + f.hidden = 1 + return f + return decorate + class Cmdln(RawCmdln): """An improved (on cmd.Cmd) framework for building multi-subcommand diff --git a/osc/commandline.py b/osc/commandline.py index f360d863..bdbd3390 100755 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -969,48 +969,65 @@ Please submit there instead, or use --nodevelproject to force direct submission. % (apiopt, r, package) - def do_deletepac(self, subcmd, opts, *args): - """${cmd_name}: Delete packages on the repository server - - usage: - osc deletepac PROJECT PACKAGE [PACKAGE ...] - ${cmd_option_list} - """ - - args = slash_split(args) - pkgs = args[1:] - if not pkgs: - raise oscerr.WrongArgs('Missing argument.') - - for pkg in pkgs: - # careful: if pkg is an empty string, the package delete request results - # into a project delete request - which works recursively... - if pkg: - delete_package(conf.config['apiurl'], args[0], pkg) - + @cmdln.option('-f', '--force', action='store_true', help='deletes a project and its packages') - def do_deleteprj(self, subcmd, opts, project): - """${cmd_name}: Delete a project on the repository server + def do_rdelete(self, subcmd, opts, *args): + """${cmd_name}: Delete a project or packages on the server. As a safety measure, project must be empty (i.e., you need to delete all packages first). If you are sure that you want to remove this project and all its packages use \'--force\' switch. + usage: + osc rdelete -f PROJECT + osc rdelete PROJECT PACKAGE [PACKAGE ...] - ${cmd_usage} ${cmd_option_list} """ - if len(meta_get_packagelist(conf.config['apiurl'], project)) >= 1 and not opts.force: + args = slash_split(args) + prj = args[0] + pkgs = args[1:] + if not prj: + raise oscerr.WrongArgs('Missing argument.') + + if pkgs: + for pkg in pkgs: + # careful: if pkg is an empty string, the package delete request results + # into a project delete request - which works recursively... + if pkg: + delete_package(conf.config['apiurl'], prj, pkg) + elif len(meta_get_packagelist(conf.config['apiurl'], project)) >= 1 and not opts.force: print >>sys.stderr, 'Project contains packages. It must be empty before deleting it. ' \ 'If you are sure that you want to remove this project and all its ' \ 'packages use the \'--force\' switch' sys.exit(1) else: - delete_project(conf.config['apiurl'], project) + delete_project(conf.config['apiurl'], prj) + @cmdln.hide(1) + def do_deletepac(self, subcmd, opts, *args): + print """s{cmd_name} is obsolete ! + + Please use either + osc delete for checked out packages or projects + or + osc rdelete for server side operations.""" + + sys.exit(1) + + @cmdln.hide(1) + @cmdln.option('-f', '--force', action='store_true', + help='deletes a project and its packages') + def do_deleteprj(self, subcmd, opts, project): + """${cmd_name} is obsolete ! + + Please use + osc rdelete PROJECT + """ + sys.exit(1) @cmdln.alias('metafromspec') @cmdln.option('', '--specfile', metavar='FILE', @@ -1574,15 +1591,24 @@ Please submit there instead, or use --nodevelproject to force direct submission. @cmdln.option('-f', '--force', action='store_true', - help='forces removal of package') + help='forces removal of entire package and its files') @cmdln.alias('rm') @cmdln.alias('del') @cmdln.alias('remove') def do_delete(self, subcmd, opts, *args): - """${cmd_name}: Mark files to be deleted upon the next 'checkin' + """${cmd_name}: Mark files or directories to be deleted upon the next 'checkin' usage: - osc rm FILE [FILE...] + osc rm FILE/DIRECTORY [FILE/DIRECTORY...] + + This command works on check out copies. Use "rdelete" for working on server + side only. This is needed for removing the entire project. + + As a safety measure, package must be empty (i.e., you need to delete all + packages first). If you are sure that you want to remove a package and all + its files use \'--force\' switch. + + ${cmd_option_list} """ @@ -1612,9 +1638,12 @@ Please submit there instead, or use --nodevelproject to force direct submission. for p in pacs: if not p.todo: prj_dir, pac_dir = getPrjPacPaths(p.absdir) - if conf.config['do_package_tracking'] and is_project_dir(prj_dir): - prj = Project(prj_dir, False) - prj.delPackage(p, opts.force) + if is_project_dir(prj_dir): + if conf.config['do_package_tracking']: + prj = Project(prj_dir, False) + prj.delPackage(p, opts.force) + else: + print "WARNING: package tracking is disabled, operation skipped !" else: pathn = getTransActPath(p.dir) for filename in p.todo: diff --git a/osc/conf.py b/osc/conf.py index a928bde5..60066785 100644 --- a/osc/conf.py +++ b/osc/conf.py @@ -57,8 +57,8 @@ DEFAULTS = { 'apiurl': 'https://api.opensuse.org', 'traceback': '0', 'post_mortem': '0', 'cookiejar': '~/.osc_cookiejar', - # disable project tracking by default - 'do_package_tracking': '0', + # enable project tracking by default + 'do_package_tracking': '1', # default for osc build 'extra-pkgs': 'vim gdb strace', # default platform