]> arthur.barton.de Git - bup.git/commitdiff
bup drecurse/index: allow non-directory --exclude and --exclude-from paths.
authorJakob Matthes <jakob.matthes@gmail.com>
Sun, 10 Mar 2013 18:10:38 +0000 (19:10 +0100)
committerRob Browning <rlb@defaultvalue.org>
Sun, 17 Mar 2013 17:31:40 +0000 (12:31 -0500)
Previously bup only allowed directory exclusions.

Signed-off-by: Jakob Matthes <jakob.matthes@gmail.com>
Reviewed-by: Gabriel Filion <lelutin@gmail.com>
[rlb@defaultvalue.org: change test file from g to j to avoid conflict
 with subsequent "exclude-from" test; add WVPASS to mkdir so problem
 is evident; edit commit message.]
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/drecurse.py
t/test.sh

index 2f4f286e984c4fc6c377446c91451866c764fde4..5d497709531350176465d853b209376aa78e1344 100644 (file)
@@ -51,6 +51,10 @@ def _dirlist():
 
 def _recursive_dirlist(prepend, xdev, bup_dir=None, excluded_paths=None):
     for (name,pst) in _dirlist():
+        if excluded_paths:
+            if os.path.normpath(prepend+name) in excluded_paths:
+                debug1('Skipping %r: excluded.\n' % (prepend+name))
+                continue
         if name.endswith('/'):
             if xdev != None and pst.st_dev != xdev:
                 debug1('Skipping %r: different filesystem.\n' % (prepend+name))
@@ -59,10 +63,6 @@ def _recursive_dirlist(prepend, xdev, bup_dir=None, excluded_paths=None):
                 if os.path.normpath(prepend+name) == bup_dir:
                     debug1('Skipping BUP_DIR.\n')
                     continue
-            if excluded_paths:
-                if os.path.normpath(prepend+name) in excluded_paths:
-                    debug1('Skipping %r: excluded.\n' % (prepend+name))
-                    continue
             try:
                 OsFile(name).fchdir()
             except OSError, e:
index 644a07ba6a23e3838d0928e9d7de2a33c71acffd..f1c414286e6e5aecb6bdc411becb2613a6267596 100755 (executable)
--- a/t/test.sh
+++ b/t/test.sh
@@ -363,13 +363,15 @@ touch $D/a
 WVPASS bup random 128k >$D/b
 mkdir $D/d $D/d/e
 WVPASS bup random 512 >$D/f
-WVPASS bup index -ux --exclude $D/d $D
+WVPASS bup random 512 >$D/j
+WVPASS bup index -ux --exclude $D/d --exclude $D/j $D
 bup save -n exclude $D
 WVPASSEQ "$(bup ls exclude/latest/$TOP/$D/)" "a
 b
 f"
-mkdir $D/g $D/h
-WVPASS bup index -ux --exclude $D/d --exclude $TOP/$D/g --exclude $D/h $D
+WVPASS mkdir $D/g $D/h
+WVPASS bup index -ux --exclude $D/d --exclude $TOP/$D/g --exclude $D/h \
+  --exclude $TOP/$D/j $D
 bup save -n exclude $D
 WVPASSEQ "$(bup ls exclude/latest/$TOP/$D/)" "a
 b
@@ -380,7 +382,8 @@ D=exclude-fromdir.tmp
 EXCLUDE_FILE=exclude-from.tmp
 echo "$D/d 
  $TOP/$D/g
-$D/h" > $EXCLUDE_FILE
+$D/h
+$D/i" > $EXCLUDE_FILE
 force-delete $D
 mkdir $D
 export BUP_DIR="$D/.bup"
@@ -390,6 +393,7 @@ 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 random 128k > $D/i
 WVPASS bup index -ux --exclude-from $EXCLUDE_FILE $D
 bup save -n exclude-from $D
 WVPASSEQ "$(bup ls exclude-from/latest/$TOP/$D/)" "a