Commit 98b3baa9 authored by Jérome Perrin's avatar Jérome Perrin Committed by GitHub

repozo: prevent an incorrect "option ignored" warning (#404)

When running backup or verify, "--with-verify option is ignored"
warning was issued even when this option was not passed
parent bcca6630
......@@ -5,6 +5,8 @@
6.0.1 (unreleased)
==================
- repozo: prevent an incorrect "option ignored" warning when running backup or verify.
6.0 (2024-03-20)
================
......
......@@ -249,9 +249,9 @@ def parseargs(argv):
if options.output is not None:
log('--output option is ignored in backup mode')
options.output = None
if options.withverify is not None:
if options.withverify:
log('--with-verify option is ignored in backup mode')
options.withverify = None
options.withverify = False
if not options.file:
usage(1, '--file is required in backup mode')
elif options.mode == RECOVER:
......@@ -281,9 +281,9 @@ def parseargs(argv):
if options.killold:
log('--kill-old-on-full option is ignored in verify mode')
options.killold = False
if options.withverify is not None:
if options.withverify:
log('--with-verify option is ignored in verify mode')
options.withverify = None
options.withverify = False
return options
......
......@@ -189,6 +189,7 @@ class Test_parseargs(unittest.TestCase):
def test_backup_ignored_args(self):
from ZODB.scripts import repozo
options = repozo.parseargs(['-B', '-r', '/tmp/nosuchdir', '-v',
'--with-verify',
'-f', '/tmp/Data.fs',
'-o', '/tmp/ignored.fs',
'-D', '2011-12-13'])
......@@ -198,6 +199,10 @@ class Test_parseargs(unittest.TestCase):
self.assertEqual(options.output, None)
self.assertIn('--output option is ignored in backup mode',
sys.stderr.getvalue())
self.assertEqual(options.withverify, False)
self.assertIn(
'--with-verify option is ignored in backup mode',
sys.stderr.getvalue())
def test_backup_required_args(self):
from ZODB.scripts import repozo
......@@ -205,6 +210,12 @@ class Test_parseargs(unittest.TestCase):
['-B', '-r', '/tmp/nosuchdir'])
self.assertIn('--file is required', sys.stderr.getvalue())
def test_backup_no_ignored_args_warning(self):
from ZODB.scripts import repozo
repozo.parseargs(['-B', '-r', '/tmp/nosuchdir', '-v',
'-f', '/tmp/Data.fs',])
self.assertNotIn('option is ignored', sys.stderr.getvalue())
def test_recover_ignored_args(self):
from ZODB.scripts import repozo
options = repozo.parseargs(['-R', '-r', '/tmp/nosuchdir', '-v',
......@@ -220,6 +231,7 @@ class Test_parseargs(unittest.TestCase):
def test_verify_ignored_args(self):
from ZODB.scripts import repozo
options = repozo.parseargs(['-V', '-r', '/tmp/nosuchdir', '-v',
'--with-verify',
'-o', '/tmp/ignored.fs',
'-D', '2011-12-13',
'-f', '/tmp/ignored.fs',
......@@ -242,6 +254,9 @@ class Test_parseargs(unittest.TestCase):
self.assertEqual(options.killold, False)
self.assertIn('--kill-old-on-full option is ignored in verify mode',
sys.stderr.getvalue())
self.assertEqual(options.withverify, False)
self.assertIn('--with-verify option is ignored in verify mode',
sys.stderr.getvalue())
class FileopsBase:
......
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