A small raft of changes to address comments raised.

This commit is contained in:
lingfish
2026-02-13 16:02:14 +11:00
parent 477320e36c
commit 6501bd9823
2 changed files with 18 additions and 14 deletions
+11 -6
View File
@@ -28,6 +28,8 @@ def diff(
arguments, optional local and remote Borg paths, executes the diff command with the given
arguments.
'''
borgmatic.logger.add_custom_log_levels()
lock_wait = config.get('lock_wait', None)
exclude_flags = flags.make_exclude_flags(config)
extra_borg_options = config.get('extra_borg_options', {}).get('diff', '')
@@ -38,6 +40,11 @@ def diff(
borgmatic.config.paths.get_working_directory(config),
)
if borgmatic.borg.feature.available(borgmatic.borg.feature.Feature.NUMERIC_IDS, local_borg_version):
numeric_ids_flags = ('--numeric-ids',) if config.get('numeric_ids') else ()
else:
numeric_ids_flags = ('--numeric-owner',) if config.get('numeric_ids') else ()
diff_command = (
(local_path, 'diff')
+ (('--remote-path', remote_path) if remote_path else ())
@@ -47,6 +54,7 @@ def diff(
+ (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ())
+ (('--patterns-from', patterns_file.name) if patterns_file else ())
+ exclude_flags
+ numeric_ids_flags
+ (tuple(shlex.split(extra_borg_options)) if extra_borg_options else ())
+ (
(
@@ -61,21 +69,18 @@ def diff(
borgmatic.borg.feature.Feature.SEPARATE_REPOSITORY_ARCHIVE,
local_borg_version,
)
else (
flags.make_repository_archive_flags(repository, archive, local_borg_version)
if archive
else flags.make_repository_flags(repository, local_borg_version)
)
else flags.make_repository_archive_flags(repository, archive, local_borg_version)
)
+ (('--same-chunker-params',) if diff_arguments.same_chunker_params else ())
+ (('--sort-by', diff_arguments.sort_by) if diff_arguments.sort_by else ())
+ (tuple(diff_arguments.sort_keys) if diff_arguments.sort_keys else ())
+ (('--content-only',) if diff_arguments.content_only else ())
+ (diff_arguments.second_archive, )
)
borgmatic.execute.execute_command(
full_command=diff_command,
output_log_level=logging.INFO,
output_log_level=logging.ANSWER,
environment=borgmatic.borg.environment.make_environment(config),
working_directory=borgmatic.config.paths.get_working_directory(config),
borg_local_path=local_path,
+7 -8
View File
@@ -1984,16 +1984,13 @@ def make_parsers(schema, unparsed_arguments): # noqa: PLR0915
)
diff_group.add_argument(
'--archive',
help='Archive name, hash, or series to diff, defaults to all archives in the repository (if specified)',
help='Archive name, hash, or series to diff',
required=True,
)
diff_group.add_argument(
'--second-archive',
help='Second archive name, hash, or series to diff',
)
diff_group.add_argument(
'--numeric-ids',
action='store_true',
help='Only consider numeric user and group identifiers',
required=True,
)
diff_group.add_argument(
'--same-chunker-params',
@@ -2002,8 +1999,10 @@ def make_parsers(schema, unparsed_arguments): # noqa: PLR0915
)
diff_group.add_argument(
'--sort-by',
metavar='KEYS',
help='Advanced sorting: specify field(s) to sort by. Accepts a comma-separated list. Prefix with > for descending or < for ascending (default).'
metavar='KEY',
dest='sort_keys',
action='append',
help='Advanced sorting: specify field(s) to sort by. Prefix with > for descending or < for ascending (default).'
)
diff_group.add_argument(
'--content-only',