From: Rob Browning Date: Fri, 31 Jan 2014 00:56:05 +0000 (-0600) Subject: Add --exclude-rx and --exclude-rx-from support to "bup drecurse". X-Git-Tag: 0.26-rc1~50 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=bup.git;a=commitdiff_plain;h=eef7376275bc4bd8672d1295360b4f281ad38c37 Add --exclude-rx and --exclude-rx-from support to "bup drecurse". Thanks to nicolas.pouillard@gmail.com for the reminder. Signed-off-by: Rob Browning --- diff --git a/Documentation/bup-drecurse.md b/Documentation/bup-drecurse.md index 2a36362..c39c6d5 100644 --- a/Documentation/bup-drecurse.md +++ b/Documentation/bup-drecurse.md @@ -9,7 +9,8 @@ bup-drecurse - recursively list files in your filesystem # SYNOPSIS bup drecurse [-x] [-q] [\--exclude *path*] -[\--exclude-from *filename*] [\--profile] \ +\ [\--exclude-from *filename*] [\--exclude-rx *pattern*] +\ [\--exclude-rx-from *filename*] [\--profile] \ # 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. diff --git a/cmd/drecurse-cmd.py b/cmd/drecurse-cmd.py index e528055..cdf6680 100755 --- a/cmd/drecurse-cmd.py +++ b/cmd/drecurse-cmd.py @@ -10,6 +10,8 @@ bup drecurse 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(): diff --git a/t/test-drecurse.sh b/t/test-drecurse.sh index 5a52f39..bb94837 100755 --- a/t/test-drecurse.sh +++ b/t/test-drecurse.sh @@ -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"