closes #601987
1) sqlutils.restore_from_file have to use its confirm argument when
a command fail, to propose to continue there (this can't be handled
by the caller)
2) source.restore method hence needs to take this confirmation callback
as argument
3) properly fix places where 'drop' was given instead of 'confirm'
--- a/server/migractions.py Tue Dec 22 20:06:24 2009 +0100
+++ b/server/migractions.py Tue Dec 22 21:02:37 2009 +0100
@@ -196,7 +196,7 @@
if systemonly and source.uri != 'system':
continue
try:
- source.restore(osp.join(tmpdir, source.uri), drop=drop)
+ source.restore(osp.join(tmpdir, source.uri), self.confirm, drop)
except Exception, exc:
print '-> error trying to restore [%s]' % exc
if not self.confirm('Continue anyway?', default='n'):
--- a/server/sources/__init__.py Tue Dec 22 20:06:24 2009 +0100
+++ b/server/sources/__init__.py Tue Dec 22 21:02:37 2009 +0100
@@ -104,7 +104,7 @@
"""method called to create a backup of source's data"""
pass
- def restore(self, backupfile):
+ def restore(self, backupfile, confirm, drop):
"""method called to restore a backup of source's data"""
pass
--- a/server/sources/extlite.py Tue Dec 22 20:06:24 2009 +0100
+++ b/server/sources/extlite.py Tue Dec 22 21:02:37 2009 +0100
@@ -101,11 +101,11 @@
finally:
self.open_pool_connections()
- def restore(self, backupfile, drop):
+ def restore(self, backupfile, confirm, drop):
"""method called to restore a backup of source's data"""
self.close_pool_connections()
try:
- self.sqladapter.restore_from_file(backupfile, drop)
+ self.sqladapter.restore_from_file(backupfile, confirm, drop)
finally:
self.open_pool_connections()
--- a/server/sources/native.py Tue Dec 22 20:06:24 2009 +0100
+++ b/server/sources/native.py Tue Dec 22 21:02:37 2009 +0100
@@ -214,12 +214,12 @@
finally:
self.open_pool_connections()
- def restore(self, backupfile, drop):
+ def restore(self, backupfile, confirm, drop):
"""method called to restore a backup of source's data"""
if self.repo.config.open_connections_pools:
self.close_pool_connections()
try:
- self.restore_from_file(backupfile, drop)
+ self.restore_from_file(backupfile, confirm, drop=drop)
finally:
if self.repo.config.open_connections_pools:
self.open_pool_connections()
--- a/server/sqlutils.py Tue Dec 22 20:06:24 2009 +0100
+++ b/server/sqlutils.py Tue Dec 22 21:02:37 2009 +0100
@@ -183,7 +183,9 @@
keepownership=False,
drop=drop):
if os.system(cmd):
- raise Exception('Failed command: %s' % cmd)
+ print '-> Failed command: %s' % cmd
+ if not confirm('Continue anyway?', default='n'):
+ raise Exception('Failed command: %s' % cmd)
def merge_args(self, args, query_args):
if args is not None: