From e57b3548c9fc8e5b2c0ab3c733a238d8c628230b Mon Sep 17 00:00:00 2001 From: Michal Vyskocil Date: Tue, 24 Nov 2009 16:25:48 +0000 Subject: [PATCH] osc mv command --- NEWS | 1 + osc/commandline.py | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/NEWS b/NEWS index b9ed5d80..33095d59 100644 --- a/NEWS +++ b/NEWS @@ -19,6 +19,7 @@ have changed and submits only the changed after asking back. - show worker/id on jobhistory and make it faster by adding a default limit of 20 - add "osc build --root" option to allow to specify build root directory + - added osc mv command which can rename file and leave him under version control # # Features which require OBS 1.7 # diff --git a/osc/commandline.py b/osc/commandline.py index 73b36802..08e44ee9 100755 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -4339,6 +4339,28 @@ Please submit there instead, or use --nodevelproject to force direct submission. vc.wait() sys.exit(vc.returncode) + @cmdln.option('-f', '--force', action='store_true', + help='forces removal of entire package and its files') + def do_mv(self, subcmd, opts, source, dest): + """${cmd_name}: Move SOURCE file to DEST and keep it under version control + + ${cmd_usage} + ${cmd_option_list} + """ + + if not os.path.isfile(source): + raise oscerr.WrongArgs("Source file ``%s'' does not exists" % source) + if not opts.force and os.path.isfile(dest): + raise oscerr.WrongArgs("Dest file ``%s'' already exists" % dest) + if not is_package_dir('.'): + raise oscerr.NoWorkingCopy("Error: \"%s\" is not an osc working copy." % os.path.abspath(dir)) + + p = findpacs('.')[0] + os.rename(source, dest) + self.do_add(subcmd, opts, dest) + self.do_delete(subcmd, opts, source) + + # fini! ###############################################################################