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({ ...@@ -219,6 +219,7 @@ _buildout_default_options = _annotate_section({
'log-level': 'INFO', 'log-level': 'INFO',
'newest': 'true', 'newest': 'true',
'offline': 'false', 'offline': 'false',
'dry-run': 'false',
'parts-directory': 'parts', 'parts-directory': 'parts',
'prefer-final': 'false', 'prefer-final': 'false',
'python': 'buildout', 'python': 'buildout',
...@@ -328,6 +329,7 @@ class Buildout(UserDict.DictMixin): ...@@ -328,6 +329,7 @@ class Buildout(UserDict.DictMixin):
self._logger = logging.getLogger('zc.buildout') self._logger = logging.getLogger('zc.buildout')
self.offline = (buildout_section['offline'] == 'true') self.offline = (buildout_section['offline'] == 'true')
self.newest = (buildout_section['newest'] == 'true') self.newest = (buildout_section['newest'] == 'true')
self.dry_run = (buildout_section['dry-run'] == 'true')
self.accept_buildout_test_releases = ( self.accept_buildout_test_releases = (
buildout_section['accept-buildout-test-releases'] == 'true') buildout_section['accept-buildout-test-releases'] == 'true')
...@@ -762,6 +764,8 @@ class Buildout(UserDict.DictMixin): ...@@ -762,6 +764,8 @@ class Buildout(UserDict.DictMixin):
if part in installed_parts: # update if part in installed_parts: # update
__doing__ = 'Updating %s.', part __doing__ = 'Updating %s.', part
self._logger.info(*__doing__) self._logger.info(*__doing__)
if self.dry_run:
continue
old_options = installed_part_options[part] old_options = installed_part_options[part]
old_installed_files = old_options['__buildout_installed__'] old_installed_files = old_options['__buildout_installed__']
...@@ -787,6 +791,8 @@ class Buildout(UserDict.DictMixin): ...@@ -787,6 +791,8 @@ class Buildout(UserDict.DictMixin):
else: # install else: # install
__doing__ = 'Installing %s.', part __doing__ = 'Installing %s.', part
self._logger.info(*__doing__) self._logger.info(*__doing__)
if self.dry_run:
continue
installed_files = self[part]._call(recipe.install) installed_files = self[part]._call(recipe.install)
if installed_files is None: if installed_files is None:
self._logger.warning( self._logger.warning(
...@@ -806,7 +812,9 @@ class Buildout(UserDict.DictMixin): ...@@ -806,7 +812,9 @@ class Buildout(UserDict.DictMixin):
finally: finally:
installed_path = self['buildout']['installed'] installed_path = self['buildout']['installed']
if installed_parts: if self.dry_run:
pass
elif installed_parts:
new = StringIO() new = StringIO()
buildout = installed_part_options['buildout'] buildout = installed_part_options['buildout']
buildout['parts'] = ' '.join(installed_parts) buildout['parts'] = ' '.join(installed_parts)
...@@ -842,6 +850,8 @@ class Buildout(UserDict.DictMixin): ...@@ -842,6 +850,8 @@ class Buildout(UserDict.DictMixin):
# uninstall part # uninstall part
__doing__ = 'Uninstalling %s.', part __doing__ = 'Uninstalling %s.', part
self._logger.info(*__doing__) self._logger.info(*__doing__)
if self.dry_run:
return
# run uninstall recipe # run uninstall recipe
recipe, entry = _recipe(installed_part_options[part]) recipe, entry = _recipe(installed_part_options[part])
...@@ -1979,6 +1989,12 @@ Options: ...@@ -1979,6 +1989,12 @@ Options:
Squelch warnings about using an executable with a broken -S Squelch warnings about using an executable with a broken -S
implementation. 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 Assignments are of the form: section:option=value and are used to
provide configuration options that override those given in the provide configuration options that override those given in the
configuration file. For example, to run the buildout in offline mode, configuration file. For example, to run the buildout in offline mode,
...@@ -2098,6 +2114,8 @@ def main(args=None): ...@@ -2098,6 +2114,8 @@ def main(args=None):
print 'Setting socket time out to %d seconds' % timeout print 'Setting socket time out to %d seconds' % timeout
socket.setdefaulttimeout(timeout) socket.setdefaulttimeout(timeout)
elif orig_op == '--dry-run':
options.append(('buildout', 'dry-run', 'true'))
elif op: elif op:
if orig_op == '--help': if orig_op == '--help':
_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