Skip to content

Commit

Permalink
- osc.cli.cli.update: use "wc_path" - this simplified the WCUpdateCon…
Browse files Browse the repository at this point in the history
…troller code a lot
  • Loading branch information
marcus-h committed Aug 20, 2012
1 parent d4f7be3 commit 4aa7428
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 24 deletions.
2 changes: 1 addition & 1 deletion osc/cli/update/ui.py
Expand Up @@ -15,7 +15,7 @@ class Update(CommandDescription, OscCommand):
"""
cmd = 'update'
args = 'path?'
args = 'wc_path'
args_opt = [0]
opt_expand = Option('u', 'unexpand', 'do not expand a source link',
action='store_true')
Expand Down
36 changes: 13 additions & 23 deletions osc/cli/update/update.py
Expand Up @@ -97,32 +97,24 @@ def checkout(self, renderer, project, package, info):
def update(self, renderer, path, info):
"""Updates a project or a list of packages"""
self._renderer = renderer
if path is None:
path = os.curdir
if wc_is_project(path):
self._update_project(path, info)
elif wc_is_package(path):
par_dir = os.path.join(path, os.pardir)
if wc_is_project(par_dir):
self._update_project(par_dir, info, wc_read_package(path))
else:
self._update_package(path, info)
tl = RendererUpdateTransactionListener(self._renderer)
prj = path.project_obj(transaction_listener=[tl])
if prj is not None:
packages = []
if path.package is not None:
packages.append(path.package)
self._update_project(prj, info, *packages)
else:
par_dir = os.path.abspath(os.path.join(path, os.pardir))
if wc_is_project(par_dir):
self._update_project(par_dir, info, path)
pkg = path.package_obj(transaction_listener=[tl])
self._update_package(pkg, info)

def _update_project(self, path, info, *packages):
def _update_project(self, prj, info, *packages):
"""Updates a project wc."""
tl = RendererUpdateTransactionListener(self._renderer)
prj = Project(path, transaction_listener=[tl])
query = self._build_query(info)
prj.update(*packages, **query)

def _update_package(self, path, info):
def _update_package(self, pkg, info):
"""Updates a package wc."""
tl = RendererUpdateTransactionListener(self._renderer)
pkg = Package(path, transaction_listener=[tl])
query = self._build_query(info)
pkg.update(**query)

Expand All @@ -134,17 +126,15 @@ def _checkout_package(self, project, package, info):
else:
prj = Project.init(path, project, info.apiurl,
transaction_listener=[tl])
query = self._build_query(info)
prj.update(package, **query)
self._update_project(prj, info, package)

def _checkout_project(self, project, info):
"""Checks out the project project."""
path = self._path_join(project)
tl = RendererUpdateTransactionListener(self._renderer)
prj = Project.init(path, project, info.apiurl,
transaction_listener=[tl])
query = self._build_query(info)
prj.update(**query)
self._update_project(prj, info)

def _build_query(self, info):
"""Builds query dict."""
Expand Down

0 comments on commit 4aa7428

Please sign in to comment.