@@ -129,25 +129,6 @@ def checkSnapshotExtension(string):
129129 return "%s%s" % (extsep , string )
130130
131131
132- class ReverseAction (Action ):
133- """Action to reverse some source/destination arguments."""
134- def __init__ (self , option_strings , dest , const = None , default = None ,
135- required = False , help = None , metavar = None ):
136- """Create a new ReverseAction object."""
137- super ().__init__ (option_strings = option_strings , dest = dest , nargs = 0 ,
138- const = const , default = default , required = required ,
139- help = help )
140-
141-
142- def __call__ (self , parser , namespace , values , option_string = None ):
143- """Helper function to reverse arguments during parsing."""
144- # In case the reverse option was given we swap the repositories and
145- # the filters.
146- with alias (namespace ) as ns :
147- ns .src , ns .dst = ns .dst , ns .src
148- ns .send_filters , ns .recv_filters = ns .recv_filters , ns .send_filters
149-
150-
151132class CheckSnapshotExtensionAction (Action ):
152133 """Action to check correct usage of the --snapshot-ext parameter."""
153134 def __init__ (self , option_strings , dest , nargs = None , const = None ,
@@ -241,11 +222,6 @@ def addOptionalArgs(parser, backup):
241222 "to include the full path to the binary or script, e.g., "
242223 "\" /usr/bin/ssh server\" ." ,
243224 )
244- parser .add_argument (
245- "--reverse" , action = ReverseAction , dest = "reverse" ,
246- help = "Reverse (i.e., swap) the source and destination repositories "
247- "as well as the send and receive filters." ,
248- )
249225 parser .add_argument (
250226 "--send-filter" , action = "append" , default = None , dest = "send_filters" ,
251227 metavar = "command" , nargs = 1 ,
@@ -427,14 +403,12 @@ def prepare(filters):
427403 # not be a valid command.
428404 remote_cmd = remote_cmd .split ()
429405
430- # Note that intuitively only the send filters can contain a None
431- # element in case the --join option is supplied. However, in case we
432- # have a --reverse option as well the filters could get swapped (which
433- # always happens after the insertion of the empty element).
406+ # The send filters might contain a None element in case the --join
407+ # option is supplied. Handle this case correctly.
434408 if send_filters :
435409 send_filters = prepare (send_filters )
436410 if recv_filters :
437- recv_filters = prepare (recv_filters )
411+ recv_filters = split (recv_filters )
438412
439413 ns .recv_filters = recv_filters
440414 ns .send_filters = send_filters
@@ -448,7 +422,6 @@ def prepare(filters):
448422 del ns .src
449423 del ns .dst
450424 del ns .command
451- del ns .reverse
452425
453426 return command , subvolumes , src_repo , dst_repo
454427
@@ -477,16 +450,7 @@ def main(argv):
477450 # that end, we move it to the end of the options because the
478451 # ArgumentParser evaluates arguments in the order in which they are
479452 # provided in the argument vector.
480- # In order to have less branching in various cases, we want to
481- # evaluate the --reverse option on the fly. This option has a special
482- # action that reverses the source and destination repositories as well
483- # as the send and receive filters. However, in order for it to work
484- # correctly, it needs to be evaluated just before the --snapshot-ext
485- # option (because the latter requires the reordered arguments) but
486- # after all other options. Hence, we move it to the end right before
487- # we do the same with the --snapshot-ext option.
488453 args = argv [1 :].copy ()
489- args = reorderArg (args , "--reverse" , has_arg = False )
490454 args = reorderArg (args , "--snapshot-ext" , has_arg = True )
491455 namespace = parser .parse_args (args )
492456
0 commit comments