]> arthur.barton.de Git - bup.git/blobdiff - lib/bup/helpers.py
parse_excludes: drop empty --exclude-from paths
[bup.git] / lib / bup / helpers.py
index 42f91297f9b68ada81b1791a3fb792c51449ad2d..b55c4a981b4cf462e267b88a5192559c02dc72b5 100644 (file)
@@ -5,7 +5,7 @@ from os import environ
 import sys, os, pwd, subprocess, errno, socket, select, mmap, stat, re, struct
 import hashlib, heapq, operator, time, grp
 
-from bup import _version, _helpers
+from bup import _helpers
 import bup._helpers as _helpers
 import math
 
@@ -201,15 +201,6 @@ def readpipe(argv, preexec_fn=None):
     return out
 
 
-try:
-    _arg_max = os.sysconf('SC_ARG_MAX')
-    if _arg_max == -1:
-        raise ValueError()
-except ValueError, ex:
-    print >> sys.stderr, 'Cannot find SC_ARG_MAX, please report a bug.'
-    sys.exit(1)
-
-
 def _argmax_base(command):
     base_size = 2048
     for c in command:
@@ -223,14 +214,12 @@ def _argmax_args_size(args):
     return sum(len(x) + 1 + sizeof(c_void_p) for x in args)
 
 
-def batchpipe(command, args, preexec_fn=None, arg_max=None):
+def batchpipe(command, args, preexec_fn=None, arg_max=_helpers.SC_ARG_MAX):
     """If args is not empty, yield the output produced by calling the
 command list with args as a sequence of strings (It may be necessary
 to return multiple strings in order to respect ARG_MAX)."""
     # The optional arg_max arg is a workaround for an issue with the
     # current wvtest behavior.
-    if not arg_max:
-        arg_max = _arg_max
     base_size = _argmax_base(command)
     while args:
         room = arg_max - base_size
@@ -823,7 +812,10 @@ def parse_excludes(options, fatal):
             except IOError, e:
                 raise fatal("couldn't read %s" % parameter)
             for exclude_path in f.readlines():
-                excluded_paths.append(realpath(exclude_path.strip()))
+                # FIXME: perhaps this should be rstrip('\n')
+                exclude_path = realpath(exclude_path.strip())
+                if exclude_path:
+                    excluded_paths.append(exclude_path)
     return sorted(frozenset(excluded_paths))
 
 
@@ -846,6 +838,8 @@ def parse_rx_excludes(options, fatal):
                 raise fatal("couldn't read %s" % parameter)
             for pattern in f.readlines():
                 spattern = pattern.rstrip('\n')
+                if not spattern:
+                    continue
                 try:
                     excluded_patterns.append(re.compile(spattern))
                 except re.error, ex:
@@ -955,30 +949,3 @@ def grafted_path_components(graft_points, path):
     return path_components(clean_path)
 
 Sha1 = hashlib.sha1
-
-def version_date():
-    """Format bup's version date string for output."""
-    return _version.DATE.split(' ')[0]
-
-
-def version_commit():
-    """Get the commit hash of bup's current version."""
-    return _version.COMMIT
-
-
-def version_tag():
-    """Format bup's version tag (the official version number).
-
-    When generated from a commit other than one pointed to with a tag, the
-    returned string will be "unknown-" followed by the first seven positions of
-    the commit hash.
-    """
-    names = _version.NAMES.strip()
-    assert(names[0] == '(')
-    assert(names[-1] == ')')
-    names = names[1:-1]
-    l = [n.strip() for n in names.split(',')]
-    for n in l:
-        if n.startswith('tag: bup-'):
-            return n[9:]
-    return 'unknown-%s' % _version.COMMIT[:7]