From 7f0e07603ebd5ecefeead31d301abcd07ae8b361 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Tue, 14 May 2019 14:51:57 +0200 Subject: [PATCH] enable placeholder usage in --comment, fixes #4559 --- src/borg/archiver.py | 10 +++++----- src/borg/helpers.py | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/borg/archiver.py b/src/borg/archiver.py index 7d4f2200c..5cf67e470 100644 --- a/src/borg/archiver.py +++ b/src/borg/archiver.py @@ -50,7 +50,7 @@ try: from .helpers import EXIT_SUCCESS, EXIT_WARNING, EXIT_ERROR from .helpers import Error, NoManifestError, set_ec from .helpers import positive_int_validator, location_validator, archivename_validator, ChunkerParams, Location - from .helpers import PrefixSpec, GlobSpec, SortBySpec, HUMAN_SORT_KEYS, FilesCacheMode + from .helpers import PrefixSpec, GlobSpec, CommentSpec, SortBySpec, HUMAN_SORT_KEYS, FilesCacheMode from .helpers import BaseFormatter, ItemFormatter, ArchiveFormatter from .helpers import format_timedelta, format_file_size, parse_file_size, format_archive from .helpers import safe_encode, remove_surrogates, bin_to_hex, prepare_dump_dict @@ -2336,8 +2336,8 @@ class Archiver: # don't backup the other home directories - /home/*\n\n''') helptext['placeholders'] = textwrap.dedent(''' - Repository (or Archive) URLs, ``--prefix``, ``--glob-archives`` and ``--remote-path`` - values support these placeholders: + Repository (or Archive) URLs, ``--prefix``, ``--glob-archives``, ``--comment`` + and ``--remote-path`` values support these placeholders: {hostname} The (short) hostname of the machine. @@ -3357,7 +3357,7 @@ class Archiver: 'regular files. Also follows symlinks pointing to these kinds of files.') archive_group = subparser.add_argument_group('Archive options') - archive_group.add_argument('--comment', dest='comment', metavar='COMMENT', default='', + archive_group.add_argument('--comment', dest='comment', metavar='COMMENT', type=CommentSpec, default='', help='add a comment text to the archive') archive_group.add_argument('--timestamp', metavar='TIMESTAMP', dest='timestamp', type=timestamp, default=None, @@ -3942,7 +3942,7 @@ class Archiver: archive_group.add_argument('-c', '--checkpoint-interval', dest='checkpoint_interval', type=int, default=1800, metavar='SECONDS', help='write checkpoint every SECONDS seconds (Default: 1800)') - archive_group.add_argument('--comment', dest='comment', metavar='COMMENT', default=None, + archive_group.add_argument('--comment', dest='comment', metavar='COMMENT', type=CommentSpec, default=None, help='add a comment text to the archive') archive_group.add_argument('--timestamp', metavar='TIMESTAMP', dest='timestamp', type=timestamp, default=None, diff --git a/src/borg/helpers.py b/src/borg/helpers.py index 796b70a40..a30dd260f 100644 --- a/src/borg/helpers.py +++ b/src/borg/helpers.py @@ -687,6 +687,8 @@ PrefixSpec = replace_placeholders GlobSpec = replace_placeholders +CommentSpec = replace_placeholders + HUMAN_SORT_KEYS = ['timestamp'] + list(ArchiveInfo._fields) HUMAN_SORT_KEYS.remove('ts')