From ac900fd4f25b8b87c961d2add0321fac70a90b5c Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 16 Jul 2016 09:58:18 +0300 Subject: Require --to for restore --- NEWS | 3 +++ obnamlib/plugins/restore_plugin.py | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/NEWS b/NEWS index 42eae186..0732518f 100644 --- a/NEWS +++ b/NEWS @@ -37,6 +37,9 @@ Bug fixes: * Michel Alexandre Salim fixed a bug in the FUSE (obnam mount) plugin, which was a typo in a method name (`get_clientgeneration_ids`). +* Lars Wirzenius fixed `obnam restore` to require a target set with + `--to`. Jonathan Dowland reported the problem. + Version 1.19.1, released 2016-01-30 --------------------------------- diff --git a/obnamlib/plugins/restore_plugin.py b/obnamlib/plugins/restore_plugin.py index 4b99cb69..b7944946 100644 --- a/obnamlib/plugins/restore_plugin.py +++ b/obnamlib/plugins/restore_plugin.py @@ -28,6 +28,11 @@ class WrongNumberOfGenerationSettingsError(obnamlib.ObnamError): msg = 'The restore command wants exactly one generation option' +class NoToError(obnamlib.ObnamError): + + msg = 'The restore command wants a target set with --to' + + class RestoreErrors(obnamlib.ObnamError): msg = '''There were errors when restoring @@ -124,6 +129,9 @@ class RestorePlugin(obnamlib.ObnamPlugin): self.app.settings.require('generation') self.app.settings.require('to') + if not self.app.settings['to']: + raise NoToError() + logging.debug( 'restoring generation %s', self.app.settings['generation']) logging.debug('restoring to %s', self.app.settings['to']) -- cgit v1.2.1