Repository: borgbackup/borg

Issue:
stats gives a stoping error
`borg create: error: argument -n/--dry-run: not allowed with argument -s/--stats`

It could be a warning, but an error is a bit of overreact, I guess.


Discussion:
borg version?
This is from current 1.1-maint code:
```
        if getattr(args, 'stats', False) and getattr(args, 'dry_run', False):
            # the data needed for --stats is not computed when using --dry-run, so we can't do it.
            # for ease of scripting, we just ignore --stats when given with --dry-run.
            logger.warning("Ignoring --stats. It is not supported when using --dry-run.")
            args.stats = False
```

Yep, it's the latest 1.1.14.
It's not being ignored, it's giving up in error.
Huh, that is strange. Do we deal at different places in borg code with that stuff?

The current 1.1-maint code is not very different from 1.1.14 release code...

Can you give the full borg command?
borg init --encryption none 

borg create --list --filter AME --stats --show-rc --compression zstd --exclude-caches --nobsdflags --exclude-from /backup/exclude.txt --dry-run /backup/repo::'{hostname}-{now}' /folder1 /folder2


```
usage: borg create [-h] [--critical] [--error] [--warning] [--info] [--debug]
                   [--debug-topic TOPIC] [-p] [--log-json]
                   [--lock-wait SECONDS] [--bypass-lock] [--show-version]
                   [--show-rc] [--umask M] [--remote-path PATH]
                   [--remote-ratelimit RATE] [--consider-part-files]
                   [--debug-profile FILE] [--rsh RSH] [-n | -s] [--list]
                   [--filter STATUSCHARS] [--json] [--no-cache-sync]
                   [--no-files-cache] [--stdin-name NAME] [-e PATTERN]
                   [--exclude-from EXCLUDEFILE] [--pattern PATTERN]
                   [--patterns-from PATTERNFILE] [--exclude-caches]
                   [--exclude-if-present NAME] [--keep-exclude-tags]
                   [--exclude-nodump] [-x] [--numeric-owner] [--noatime]
                   [--noctime] [--nobirthtime] [--nobsdflags] [--ignore-inode]
                   [--files-cache MODE] [--read-special] [--comment COMMENT]
                   [--timestamp TIMESTAMP] [-c SECONDS]
                   [--chunker-params PARAMS] [-C COMPRESSION]
                   ARCHIVE [PATH [PATH ...]]
borg create: error: argument -n/--dry-run: not allowed with argument -s/--stats
```
It's a bug, borg aborts when parsing args as they are defined in a mutually exclusive group.

Note: the --filter=AME does not give any output when used with --dry-run, because status will be `-`.

Resolving patch:
diff --git a/src/borg/archiver.py b/src/borg/archiver.py
--- a/src/borg/archiver.py
+++ b/src/borg/archiver.py
@@ -3389,10 +3389,11 @@ def define_archive_filters_group(subparser, *, sort_by=True, first_last=True):
                                           help='create backup')
         subparser.set_defaults(func=self.do_create)
 
-        dryrun_group = subparser.add_mutually_exclusive_group()
-        dryrun_group.add_argument('-n', '--dry-run', dest='dry_run', action='store_true',
+        # note: --dry-run and --stats are mutually exclusive, but we do not want to abort when
+        #  parsing, but rather proceed with the dry-run, but without stats (see run() method).
+        subparser.add_argument('-n', '--dry-run', dest='dry_run', action='store_true',
                                help='do not create a backup archive')
-        dryrun_group.add_argument('-s', '--stats', dest='stats', action='store_true',
+        subparser.add_argument('-s', '--stats', dest='stats', action='store_true',
                                help='print statistics for the created archive')
 
         subparser.add_argument('--list', dest='output_list', action='store_true',


Test patch: