From 1bf2a6a2409f41bb71ab4473fa79c5ef89d85759 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Wed, 15 Jun 2022 17:07:42 +0200 Subject: [PATCH] remove archive checks from location_validator, use --other-repo --- src/borg/archiver.py | 19 ++++++++----------- src/borg/helpers/parseformat.py | 6 +----- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/borg/archiver.py b/src/borg/archiver.py index 0e2d07855..cea035ab0 100644 --- a/src/borg/archiver.py +++ b/src/borg/archiver.py @@ -4143,12 +4143,12 @@ class Archiver: # initialize DST_REPO reusing key material from SRC_REPO, so that # chunking and chunk id generation will work in the same way as before. - borg init --other-location=SRC_REPO --encryption=DST_ENC DST_REPO + borg --repo=DST_REPO init --other-repo=SRC_REPO --encryption=DST_ENC # transfer archives from SRC_REPO to DST_REPO - borg transfer --dry-run SRC_REPO DST_REPO # check what it would do - borg transfer SRC_REPO DST_REPO # do it! - borg transfer --dry-run SRC_REPO DST_REPO # check! anything left? + borg --repo=DST_REPO transfer --other-repo=SRC_REPO --dry-run # check what it would do + borg --repo=DST_REPO transfer --other-repo=SRC_REPO # do it! + borg --repo=DST_REPO transfer --other-repo=SRC_REPO --dry-run # check! anything left? The default is to transfer all archives, including checkpoint archives. @@ -4164,12 +4164,9 @@ class Archiver: subparser.set_defaults(func=self.do_transfer) subparser.add_argument('-n', '--dry-run', dest='dry_run', action='store_true', help='do not change repository, just check') - subparser.add_argument('other_location', metavar='SRC_REPOSITORY', - type=location_validator(archive=False, other=True), + subparser.add_argument('--other-repo', metavar='SRC_REPOSITORY', dest='other_location', + type=location_validator(other=True), help='source repository') - # subparser.add_argument('-r', '--repo', dest='location', metavar='DST_REPOSITORY', - # type=location_validator(archive=False, other=False), - # help='destination repository') define_archive_filters_group(subparser) # borg diff @@ -4504,8 +4501,8 @@ class Archiver: formatter_class=argparse.RawDescriptionHelpFormatter, help='initialize empty repository') subparser.set_defaults(func=self.do_init) - subparser.add_argument('--other-location', metavar='OTHER_REPOSITORY', dest='other_location', - type=location_validator(archive=False, other=True), + subparser.add_argument('--other-repo', metavar='SRC_REPOSITORY', dest='other_location', + type=location_validator(other=True), help='reuse the key material from the other repository') subparser.add_argument('-e', '--encryption', metavar='MODE', dest='encryption', required=True, choices=key_argument_names(), diff --git a/src/borg/helpers/parseformat.py b/src/borg/helpers/parseformat.py index 43e8d05eb..e4b54f0c8 100644 --- a/src/borg/helpers/parseformat.py +++ b/src/borg/helpers/parseformat.py @@ -507,16 +507,12 @@ class Location: return loc -def location_validator(archive=None, proto=None, other=False): +def location_validator(proto=None, other=False): def validator(text): try: loc = Location(text, other=other) except ValueError as err: raise argparse.ArgumentTypeError(str(err)) from None - if archive is True and not loc.archive: - raise argparse.ArgumentTypeError('"%s": No archive specified' % text) - elif archive is False and loc.archive: - raise argparse.ArgumentTypeError('"%s": No archive can be specified' % text) if proto is not None and loc.proto != proto: if proto == 'file': raise argparse.ArgumentTypeError('"%s": Repository must be local' % text)