Commit cd35671d authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

Add '--dry-run' option.

parent d5deb01f
......@@ -219,6 +219,7 @@ _buildout_default_options = _annotate_section({
'log-level': 'INFO',
'newest': 'true',
'offline': 'false',
'dry-run': 'false',
'parts-directory': 'parts',
'prefer-final': 'false',
'python': 'buildout',
......@@ -328,6 +329,7 @@ class Buildout(UserDict.DictMixin):
self._logger = logging.getLogger('zc.buildout')
self.offline = (buildout_section['offline'] == 'true')
self.newest = (buildout_section['newest'] == 'true')
self.dry_run = (buildout_section['dry-run'] == 'true')
self.accept_buildout_test_releases = (
buildout_section['accept-buildout-test-releases'] == 'true')
......@@ -762,6 +764,8 @@ class Buildout(UserDict.DictMixin):
if part in installed_parts: # update
__doing__ = 'Updating %s.', part
self._logger.info(*__doing__)
if self.dry_run:
continue
old_options = installed_part_options[part]
old_installed_files = old_options['__buildout_installed__']
......@@ -787,6 +791,8 @@ class Buildout(UserDict.DictMixin):
else: # install
__doing__ = 'Installing %s.', part
self._logger.info(*__doing__)
if self.dry_run:
continue
installed_files = self[part]._call(recipe.install)
if installed_files is None:
self._logger.warning(
......@@ -806,7 +812,9 @@ class Buildout(UserDict.DictMixin):
finally:
installed_path = self['buildout']['installed']
if installed_parts:
if self.dry_run:
pass
elif installed_parts:
new = StringIO()
buildout = installed_part_options['buildout']
buildout['parts'] = ' '.join(installed_parts)
......@@ -842,6 +850,8 @@ class Buildout(UserDict.DictMixin):
# uninstall part
__doing__ = 'Uninstalling %s.', part
self._logger.info(*__doing__)
if self.dry_run:
return
# run uninstall recipe
recipe, entry = _recipe(installed_part_options[part])
......@@ -1979,6 +1989,12 @@ Options:
Squelch warnings about using an executable with a broken -S
implementation.
--dry-run
Dry-run mode. With this setting, buildout will display what will
be uninstalled and what will be installed without doing anything
in reality.
Assignments are of the form: section:option=value and are used to
provide configuration options that override those given in the
configuration file. For example, to run the buildout in offline mode,
......@@ -2098,6 +2114,8 @@ def main(args=None):
print 'Setting socket time out to %d seconds' % timeout
socket.setdefaulttimeout(timeout)
elif orig_op == '--dry-run':
options.append(('buildout', 'dry-run', 'true'))
elif op:
if orig_op == '--help':
_help()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment