From b190f27d007c253610ecfdc10ff333b43f5f38e0 Mon Sep 17 00:00:00 2001 From: Ed Bartosh Date: Thu, 6 Oct 2011 15:51:08 +0300 Subject: [PATCH] implemented --output-dir command line option --- osc/commandline.py | 9 ++++++++- osc/core.py | 38 ++++++++++++++++++-------------------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/osc/commandline.py b/osc/commandline.py index 3237b8fe..ab8e3ecd 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -3366,6 +3366,9 @@ Please submit there instead, or use --nodevelproject to force direct submission. @cmdln.option('-c', '--current-dir', action='store_true', help='place PACKAGE folder in the current directory' \ 'instead of a PROJECT/PACKAGE directory') + @cmdln.option('-o', '--output-dir', metavar='outdir', + help='place package in the specified directory' \ + 'instead of a PROJECT/PACKAGE directory') @cmdln.option('-s', '--source-service-files', action='store_true', help='Run source services.' ) @cmdln.option('-S', '--server-side-source-service-files', action='store_true', @@ -3454,9 +3457,13 @@ Please submit there instead, or use --nodevelproject to force direct submission. get_source_file(apiurl, project, package, filename, revision=rev, progress_obj=self.download_progress) elif package: + output_dir = None if opts.current_dir: project_dir = None - checkout_package(apiurl, project, package, rev, expand_link=expand_link, \ + if opts.output_dir: + project_dir = None + output_dir = getTransActPath(os.path.realpath(opts.output_dir)) + checkout_package(apiurl, project, package, rev, output_dir, expand_link=expand_link, \ prj_dir=project_dir, service_files = opts.source_service_files, server_service_files=opts.server_side_source_service_files, progress_obj=self.download_progress, size_limit=opts.limit_size, meta=opts.meta) print_request_list(apiurl, project, package) diff --git a/osc/core.py b/osc/core.py index 729080a4..bddec684 100644 --- a/osc/core.py +++ b/osc/core.py @@ -3972,29 +3972,30 @@ def make_dir(apiurl, project, package, pathname=None, prj_dir=None, package_trac # and should rename this path component by appending '.proj' # and give user a warning message, to discourage such clashes - pathname = pathname or getTransActPath(os.path.join(prj_dir, package)) - if is_package_dir(prj_dir): - # we want this to become a project directory, - # but it already is a package directory. - raise oscerr.OscIOError(None, 'checkout_package: package/project clash. Moving myself away not implemented') + path = pathname or getTransActPath(os.path.join(prj_dir, package)) - if not is_project_dir(prj_dir): - # this directory could exist as a parent direory for one of our earlier - # checked out sub-projects. in this case, we still need to initialize it. - print statfrmt('A', prj_dir) - Project.init_project(apiurl, prj_dir, project, package_tracking) + if not pathname: + if is_package_dir(prj_dir): + # we want this to become a project directory, + # but it already is a package directory. + raise oscerr.OscIOError(None, 'checkout_package: package/project clash. Moving myself away not implemented') - if is_project_dir(os.path.join(prj_dir, package)): + if not is_project_dir(prj_dir) and not pathname: + # this directory could exist as a parent direory for one of our earlier + # checked out sub-projects. in this case, we still need to initialize it. + print statfrmt('A', path) + Project.init_project(apiurl, prj_dir, project, package_tracking) + + if is_project_dir(path): # the thing exists, but is a project directory and not a package directory # FIXME: this should be a warning message to discourage package/project clashes raise oscerr.OscIOError(None, 'checkout_package: package/project clash. Moving project away not implemented') - - if not os.path.exists(os.path.join(prj_dir, package)): - print statfrmt('A', pathname) - os.mkdir(os.path.join(prj_dir, package)) + if not os.path.exists(path): + print statfrmt('A', path) + os.mkdir(path) # os.mkdir(os.path.join(prj_dir, package, store)) - return os.path.join(prj_dir, package) + return path def checkout_package(apiurl, project, package, @@ -4051,9 +4052,6 @@ def checkout_package(apiurl, project, package, print "found root of %s at %s" % (oldproj, root_dots) prj_dir = root_dots + prj_dir - if not pathname: - pathname = getTransActPath(os.path.join(prj_dir, package)) - # before we create directories and stuff, check if the package actually # exists show_package_meta(apiurl, project, package, meta) @@ -4075,7 +4073,7 @@ def checkout_package(apiurl, project, package, p = Package.init_package(apiurl, project, package, directory, size_limit, meta, progress_obj) if isfrozen: p.mark_frozen() - if conf.config['do_package_tracking']: + if conf.config['do_package_tracking'] and not pathname: # check if we can re-use an existing project object if prj_obj is None: prj_obj = Project(prj_dir)