Răsfoiți Sursa

remove archive checks from location_validator, use --other-repo

Thomas Waldmann 3 ani în urmă
părinte
comite
1bf2a6a240
2 a modificat fișierele cu 9 adăugiri și 16 ștergeri
  1. 8 11
      src/borg/archiver.py
  2. 1 5
      src/borg/helpers/parseformat.py

+ 8 - 11
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(),

+ 1 - 5
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)