]> arthur.barton.de Git - bup.git/commitdiff
Adds --exclude-file option to bup index.
authorZoran Zaric <zz@zoranzaric.de>
Thu, 2 Dec 2010 06:24:12 +0000 (07:24 +0100)
committerAvery Pennarun <apenwarr@gmail.com>
Thu, 2 Dec 2010 07:30:16 +0000 (23:30 -0800)
Signed-off-by: Zoran Zaric <zz@zoranzaric.de>
cmd/index-cmd.py
t/test.sh

index c78dc76dc152b63fcfa7570f87d560929c11a8be..2710c02839869a85f79e36815d57ef4e80f67064 100755 (executable)
@@ -131,7 +131,8 @@ fake-valid mark all index entries as up-to-date even if they aren't
 fake-invalid mark all index entries as invalid
 check      carefully check index file integrity
 f,indexfile=  the name of the index file (normally BUP_DIR/bupindex)
-exclude=   a path to exclude from the backup (can be used ore than once)
+exclude=   a path to exclude from the backup (can be used more than once)
+exclude-file= a file that contains exclude paths
 v,verbose  increase log output (can be used more than once)
 """
 o = options.Options('bup index', optspec)
@@ -153,14 +154,24 @@ if opt.check:
     log('check: starting initial check.\n')
     check_index(index.Reader(indexfile))
 
+excluded_paths = []
+
 if opt.exclude:
-    excluded_paths = []
     for flag in flags:
         (option, parameter) = flag
         if option == '--exclude':
             excluded_paths.append(realpath(parameter))
-else:
-    excluded_paths = None
+
+if opt.exclude_file:
+    try:
+        f = open(realpath(opt.exclude_file))
+        for exclude_path in f.readlines():
+            excluded_paths.append(realpath(exclude_path.strip()))
+    except Error, e:
+        log("index: warning: couldn't read %s" % opt.exclude_file)
+    finally:
+        f.close()
+
 
 paths = index.reduce_paths(extra)
 
index 233e4b41cec1415b5211195bed963d581780a58b..458f69a5605ec5693c92acd3ee8d3f56def69ad8 100755 (executable)
--- a/t/test.sh
+++ b/t/test.sh
@@ -281,3 +281,24 @@ bup save -n exclude $D
 WVPASSEQ "$(bup ls exclude/latest/$TOP/$D/)" "a
 b
 f"
+
+WVSTART "exclude-file"
+D=exclude-filedir.tmp
+EXCLUDE_FILE=exclude-file.tmp
+echo "$D/d 
+ $TOP/$D/g
+$D/h" > $EXCLUDE_FILE
+rm -rf $D
+mkdir $D
+export BUP_DIR="$D/.bup"
+WVPASS bup init
+touch $D/a
+WVPASS bup random 128k >$D/b
+mkdir $D/d $D/d/e
+WVPASS bup random 512 >$D/f
+mkdir $D/g $D/h
+WVPASS bup index -ux --exclude-file $EXCLUDE_FILE $D
+bup save -n exclude-file $D
+WVPASSEQ "$(bup ls exclude-file/latest/$TOP/$D/)" "a
+b
+f"