]> arthur.barton.de Git - bup.git/commitdiff
Add --exclude-rx and --exclude-rx-from support to "bup drecurse".
authorRob Browning <rlb@defaultvalue.org>
Fri, 31 Jan 2014 00:56:05 +0000 (18:56 -0600)
committerRob Browning <rlb@defaultvalue.org>
Fri, 31 Jan 2014 00:58:11 +0000 (18:58 -0600)
Thanks to nicolas.pouillard@gmail.com for the reminder.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Documentation/bup-drecurse.md
cmd/drecurse-cmd.py
t/test-drecurse.sh

index 2a36362713c605c4e6b49dd9a9b3e8a9035116ae..c39c6d5fc46f65a66e77968fac5744b3a1e7837a 100644 (file)
@@ -9,7 +9,8 @@ bup-drecurse - recursively list files in your filesystem
 # SYNOPSIS
 
 bup drecurse [-x] [-q] [\--exclude *path*]
-[\--exclude-from *filename*] [\--profile] \<path\>
+\ [\--exclude-from *filename*] [\--exclude-rx *pattern*]
+\ [\--exclude-rx-from *filename*] [\--profile] \<path\>
 
 # DESCRIPTION
 
@@ -38,13 +39,22 @@ come after its children, making this easy.
     when testing performance of the traversal algorithms.
 
 \--exclude=*path*
-:   a path to exclude from the backup (can be used more
-    than once)
+:   exclude *path* from the backup (may be repeated).
 
 \--exclude-from=*filename*
-:   a file that contains exclude paths (can be used more
-    than once)
+:   read --exclude paths from *filename*, one path per-line (may be
+    repeated).
     
+\--exclude-rx=*pattern*
+:   exclude any path matching *pattern*.  See `bup-index`(1) for
+    details, but note that unlike index, drecurse will produce
+    relative paths if the drecurse target is a relative path. (may be
+    repeated).
+
+\--exclude-rx-from=*filename*
+:   read --exclude-rx patterns from *filename*, one pattern per-line
+    (may be repeated).
+
 \--profile
 :   print profiling information upon completion.  Useful
     when testing performance of the traversal algorithms.
index e52805549c5a32c5b0be89b1af902d46202642f6..cdf66803034bd0f429a869ea75b94ba06f29e25a 100755 (executable)
@@ -10,6 +10,8 @@ bup drecurse <path>
 x,xdev,one-file-system   don't cross filesystem boundaries
 exclude= a path to exclude from the backup (can be used more than once)
 exclude-from= a file that contains exclude paths (can be used more than once)
+exclude-rx= skip paths matching the unanchored regex (may be repeated)
+exclude-rx-from= skip --exclude-rx patterns in file (may be repeated)
 q,quiet  don't actually print filenames
 profile  run under the python profiler
 """
@@ -23,8 +25,10 @@ drecurse_top = extra[0]
 excluded_paths = parse_excludes(flags, o.fatal)
 if not drecurse_top.startswith('/'):
     excluded_paths = [relpath(x) for x in excluded_paths]
+exclude_rxs = parse_rx_excludes(flags, o.fatal)
 it = drecurse.recursive_dirlist([drecurse_top], opt.xdev,
-                                excluded_paths=excluded_paths)
+                                excluded_paths=excluded_paths,
+                                exclude_rxs=exclude_rxs)
 if opt.profile:
     import cProfile
     def do_it():
index 5a52f393ee0b1144d4c4418c9dfb3cbd5c801903..bb948370e58f0c151cf4454be52f45729da99927 100755 (executable)
@@ -80,4 +80,21 @@ src/a/
 src/a-link
 src/"
 
+WVSTART "drecurse --exclude-rx (trivial)"
+WVPASSEQ "$(bup drecurse --exclude-rx '^src/b' src)" "src/c
+src/a/2
+src/a/1
+src/a/
+src/a-link
+src/"
+
+WVSTART "drecurse --exclude-rx (trivial - absolute path)"
+WVPASSEQ "$(bup drecurse --exclude-rx "^$(pwd)/src/b" "$(pwd)/src")" \
+"$(pwd)/src/c
+$(pwd)/src/a/2
+$(pwd)/src/a/1
+$(pwd)/src/a/
+$(pwd)/src/a-link
+$(pwd)/src/"
+
 WVPASS rm -rf "$tmpdir"