Browse Source

Merge pull request #3441 from ThomasWaldmann/backports

Backports to 1.1
TW 7 years ago
parent
commit
4ac6ee221a
7 changed files with 22 additions and 4 deletions
  1. 3 0
      docs/man/borg-placeholders.1
  2. 3 0
      docs/usage/help.rst.inc
  3. 2 0
      setup.py
  4. 1 1
      src/borg/_chunker.c
  5. 1 1
      src/borg/_hashindex.c
  6. 9 1
      src/borg/archiver.py
  7. 3 1
      src/borg/helpers.py

+ 3 - 0
docs/man/borg-placeholders.1

@@ -42,6 +42,9 @@ The (short) hostname of the machine.
 .B {fqdn}
 The full name of the machine.
 .TP
+.B {reverse-fqdn}
+The full name of the machine in reverse domain name notation.
+.TP
 .B {now}
 The current local date and time, by default in ISO\-8601 format.
 You can also supply your own \fI\%format string\fP, e.g. {now:%Y\-%m\-%d_%H:%M:%S}

+ 3 - 0
docs/usage/help.rst.inc

@@ -169,6 +169,9 @@ placeholders:
 {fqdn}
     The full name of the machine.
 
+{reverse-fqdn}
+    The full name of the machine in reverse domain name notation.
+
 {now}
     The current local date and time, by default in ISO-8601 format.
     You can also supply your own `format string <https://docs.python.org/3.4/library/datetime.html#strftime-and-strptime-behavior>`_, e.g. {now:%Y-%m-%d_%H:%M:%S}

+ 2 - 0
setup.py

@@ -651,6 +651,8 @@ class build_man(Command):
             examples = examples.replace(usage_include, '')
             examples = examples.replace('Examples\n~~~~~~~~', '')
             examples = examples.replace('Miscellaneous Help\n------------------', '')
+            examples = examples.replace('``docs/misc/prune-example.txt``:', '``docs/misc/prune-example.txt``.')
+            examples = examples.replace('.. highlight:: none\n', '')  # we don't support highlight
             examples = re.sub('^(~+)$', lambda matches: '+' * len(matches.group(0)), examples, flags=re.MULTILINE)
             examples = examples.strip()
         if examples:

+ 1 - 1
src/borg/_chunker.c

@@ -63,7 +63,7 @@ static uint32_t table_base[] =
     0xc5ae37bb, 0xa76ce12a, 0x8150d8f3, 0x2ec29218, 0xa35f0984, 0x48c0647e, 0x0b5ff98c, 0x71893f7b
 };
 
-#define BARREL_SHIFT(v, shift) ( ((v) << shift) | ((v) >> ((32 - shift) & 0x1f)) )
+#define BARREL_SHIFT(v, shift) ( ((v) << (shift)) | ((v) >> ((32 - (shift)) & 0x1f)) )
 
 size_t pagemask;
 

+ 1 - 1
src/borg/_hashindex.c

@@ -71,7 +71,7 @@ static int hash_sizes[] = {
 #define EMPTY _htole32(0xffffffff)
 #define DELETED _htole32(0xfffffffe)
 
-#define BUCKET_ADDR(index, idx) (index->buckets + (idx * index->bucket_size))
+#define BUCKET_ADDR(index, idx) (index->buckets + ((idx) * index->bucket_size))
 
 #define BUCKET_MATCHES_KEY(index, idx, key) (memcmp(key, BUCKET_ADDR(index, idx), index->key_size) == 0)
 

+ 9 - 1
src/borg/archiver.py

@@ -2093,6 +2093,9 @@ class Archiver:
         {fqdn}
             The full name of the machine.
 
+        {reverse-fqdn}
+            The full name of the machine in reverse domain name notation.
+
         {now}
             The current local date and time, by default in ISO-8601 format.
             You can also supply your own `format string <https://docs.python.org/3.4/library/datetime.html#strftime-and-strptime-behavior>`_, e.g. {now:%Y-%m-%d_%H:%M:%S}
@@ -2202,7 +2205,12 @@ class Archiver:
             else:
                 commands[args.topic].print_help()
         else:
-            parser.error('No help available on %s' % (args.topic,))
+            msg_lines = []
+            msg_lines += ['No help available on %s.' % args.topic]
+            msg_lines += ['Try one of the following:']
+            msg_lines += ['    Commands: %s' % ', '.join(sorted(commands.keys()))]
+            msg_lines += ['    Topics: %s' % ', '.join(sorted(self.helptext.keys()))]
+            parser.error('\n'.join(msg_lines))
         return self.exit_code
 
     def do_subcommand_help(self, parser, args):

+ 3 - 1
src/borg/helpers.py

@@ -661,9 +661,11 @@ def format_line(format, data):
 def replace_placeholders(text):
     """Replace placeholders in text with their values."""
     current_time = datetime.now()
+    fqdn = socket.getfqdn()
     data = {
         'pid': os.getpid(),
-        'fqdn': socket.getfqdn(),
+        'fqdn': fqdn,
+        'reverse-fqdn': '.'.join(reversed(fqdn.split('.'))),
         'hostname': socket.gethostname(),
         'now': DatetimeWrapper(current_time.now()),
         'utcnow': DatetimeWrapper(current_time.utcnow()),