Commit 2dd42677 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki Committed by Xavier Thompson

Add '--dry-run' option.

parent ffcc9d8e
......@@ -173,6 +173,7 @@ _buildout_default_options = _annotate_section({
'log-level': 'INFO',
'newest': 'true',
'offline': 'false',
'dry-run': 'false',
'parts-directory': 'parts',
'prefer-final': 'true',
'python': 'buildout',
......@@ -351,6 +352,7 @@ class Buildout(DictMixin):
self.newest = ((not self.offline) and
bool_option(buildout_section, 'newest')
)
self.dry_run = (buildout_section['dry-run'] == 'true')
##################################################################
## WARNING!!!
......@@ -701,6 +703,8 @@ class Buildout(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]
installed_files = old_options['__buildout_installed__']
......@@ -731,6 +735,8 @@ class Buildout(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(
......@@ -758,6 +764,8 @@ class Buildout(DictMixin):
# uninstall part
__doing__ = 'Uninstalling %s.', part
self._logger.info(*__doing__)
if self.dry_run:
return
# run uuinstall recipe
recipe, entry = _recipe(installed_part_options[part])
......@@ -904,6 +912,8 @@ class Buildout(DictMixin):
def _save_installed_options(self):
if self.dry_run:
return
installed_path = self['buildout']['installed']
if not installed_path:
return
......@@ -1946,6 +1956,12 @@ Options:
will be started. This is especially useful for debuging recipe
problems.
--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,
......@@ -2064,12 +2080,15 @@ def main(args=None):
_error("No timeout value specified for option", orig_op)
except ValueError:
_error("Timeout value must be numeric", orig_op)
elif orig_op == '--dry-run':
options.append(('buildout', 'dry-run', 'true'))
elif op:
if orig_op == '--help':
_help()
elif orig_op == '--version':
_version()
_error("Invalid option", '-'+op[0])
_error("Invalid option", orig_op)
elif '=' in args[0]:
option, value = args.pop(0).split('=', 1)
option = option.split(':')
......
......@@ -335,6 +335,10 @@ we'll see that the directory gets removed and recreated::
... path = mydata
... """)
>>> print_(system(buildout+' --dry-run'), end='')
Develop: '/sample-buildout/recipes'
Uninstalling data-dir.
Installing data-dir.
>>> print_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
Uninstalling data-dir.
......@@ -355,6 +359,10 @@ If any of the files or directories created by a recipe are removed,
the part will be reinstalled::
>>> rmdir(sample_buildout, 'mydata')
>>> print_(system(buildout+' --dry-run'), end='')
Develop: '/sample-buildout/recipes'
Uninstalling data-dir.
Installing data-dir.
>>> print_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
Uninstalling data-dir.
......@@ -812,6 +820,8 @@ the origin of the value (file name or ``COMPUTED_VALUE``, ``DEFAULT_VALUE``,
DEFAULT_VALUE
directory= /sample-buildout
COMPUTED_VALUE
dry-run= false
DEFAULT_VALUE
eggs-directory= /sample-buildout/eggs
DEFAULT_VALUE
executable= ...
......@@ -2761,6 +2771,7 @@ database is shown::
bin-directory = /sample-buildout/bin
develop-eggs-directory = /sample-buildout/develop-eggs
directory = /sample-buildout
dry-run = false
eggs-directory = /sample-buildout/eggs
executable = python
find-links =
......
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