]> arthur.barton.de Git - bup.git/commitdiff
Renames --exclude-file to --exclude-from and encaspulates exclude-parsing.
authorZoran Zaric <zz@zoranzaric.de>
Thu, 2 Dec 2010 06:24:14 +0000 (07:24 +0100)
committerAvery Pennarun <apenwarr@gmail.com>
Thu, 2 Dec 2010 07:30:17 +0000 (23:30 -0800)
Signed-off-by: Zoran Zaric <zz@zoranzaric.de>
Documentation/bup-drecurse.md
Documentation/bup-index.md
cmd/drecurse-cmd.py
cmd/index-cmd.py
lib/bup/drecurse.py
t/test.sh

index 13db28d209be61dea2ce0e864e1642eece0bb0f8..ffa5caff72be771a8fad567ae5bfbfa708995d8e 100644 (file)
@@ -8,7 +8,8 @@ bup-drecurse - recursively list files in your filesystem
 
 # SYNOPSIS
 
-bup drecurse [-x] [-q] [--profile] \<path\>
+bup drecurse [-x] [-q] [--exclude *path*]
+[--exclude-from *filename*] [--profile] \<path\>
 
 # DESCRIPTION
 
@@ -34,6 +35,14 @@ come after its children, making this easy.
 -q, --quiet
 :   don't print filenames as they are encountered.  Useful
     when testing performance of the traversal algorithms.
+
+--exclude=*path*
+:   a path to exclude from the backup (can be used more
+    than once)
+
+--exclude-from=*filename*
+:   a file that contains exclude paths (can be used more
+    than once)
     
 --profile
 :   print profiling information upon completion.  Useful
index 40336e78ec91bbb53adef1b6b1d059bda8ac75f6..2ec65e2c45d5878ec5301c7e416929562fd729e1 100644 (file)
@@ -9,7 +9,8 @@ bup-index - print and/or update the bup filesystem index
 # SYNOPSIS
 
 bup index <-p|-m|-u> [-s] [-H] [-l] [-x] [--fake-valid]
-[--check] [-f *indexfile*] [--exclude *path*] [--exclude-file *filename*] [-v] <filenames...>
+[--check] [-f *indexfile*] [--exclude *path*]
+[--exclude-from *filename*] [-v] <filenames...>
 
 # DESCRIPTION
 
@@ -101,8 +102,9 @@ need the same information).
 :   a path to exclude from the backup (can be used more
     than once)
 
---exclude-file=*filename*
-:   a file that contains exclude paths
+--exclude-from=*filename*
+:   a file that contains exclude paths (can be used more
+    than once)
 
 -v, --verbose
 :   increase log output during update (can be used more
index 74249c993b8be352525131faa150f6024a053e82..41503ee829a013bdb98e7ce51cdf9a77bef1e331 100755 (executable)
@@ -6,7 +6,8 @@ optspec = """
 bup drecurse <path>
 --
 x,xdev,one-file-system   don't cross filesystem boundaries
-exclude= a comma-seperated list of paths to exclude from the backup
+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)
 q,quiet  don't actually print filenames
 profile  run under the python profiler
 """
@@ -16,10 +17,7 @@ o = options.Options('bup drecurse', optspec)
 if len(extra) != 1:
     o.fatal("exactly one filename expected")
 
-if opt.exclude:
-    excluded_paths = [realpath(x) for x in opt.exclude.split(",")]
-else:
-    excluded_paths = None
+excluded_paths = drecurse.parse_excludes(flags)
 
 it = drecurse.recursive_dirlist(extra, opt.xdev, excluded_paths)
 if opt.profile:
index 2710c02839869a85f79e36815d57ef4e80f67064..43314d960f5be025f89c10faa14eb2496bd262fb 100755 (executable)
@@ -132,7 +132,7 @@ 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 more than once)
-exclude-file= a file that contains exclude paths
+exclude-from= a file that contains exclude paths (can be used more than once)
 v,verbose  increase log output (can be used more than once)
 """
 o = options.Options('bup index', optspec)
@@ -154,24 +154,7 @@ if opt.check:
     log('check: starting initial check.\n')
     check_index(index.Reader(indexfile))
 
-excluded_paths = []
-
-if opt.exclude:
-    for flag in flags:
-        (option, parameter) = flag
-        if option == '--exclude':
-            excluded_paths.append(realpath(parameter))
-
-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()
-
+excluded_paths = drecurse.parse_excludes(flags)
 
 paths = index.reduce_paths(extra)
 
index 879ba5a522fc64464bf43ec4d5545558c7ef362b..6da052321beb745a886f803aa279fbdcd058dd98 100644 (file)
@@ -112,3 +112,24 @@ def recursive_dirlist(paths, xdev, bup_dir=None, excluded_paths=None):
         except:
             pass
         raise
+
+def parse_excludes(flags):
+    excluded_paths = []
+
+    for flag in flags:
+        (option, parameter) = flag
+        if option == '--exclude':
+            excluded_paths.append(realpath(parameter))
+
+        if option == '--exclude-from':
+            try:
+                f = open(realpath(parameter))
+                for exclude_path in f.readlines():
+                    excluded_paths.append(realpath(exclude_path.strip()))
+            except Error, e:
+                log("warning: couldn't read %s" % parameter)
+            finally:
+                f.close()
+
+    return excluded_paths
+
index 458f69a5605ec5693c92acd3ee8d3f56def69ad8..0c83ba7882b54911513194023c2379d3e7f43d91 100755 (executable)
--- a/t/test.sh
+++ b/t/test.sh
@@ -282,9 +282,9 @@ WVPASSEQ "$(bup ls exclude/latest/$TOP/$D/)" "a
 b
 f"
 
-WVSTART "exclude-file"
-D=exclude-filedir.tmp
-EXCLUDE_FILE=exclude-file.tmp
+WVSTART "exclude-from"
+D=exclude-fromdir.tmp
+EXCLUDE_FILE=exclude-from.tmp
 echo "$D/d 
  $TOP/$D/g
 $D/h" > $EXCLUDE_FILE
@@ -297,8 +297,9 @@ 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
+WVPASS bup index -ux --exclude-from $EXCLUDE_FILE $D
+bup save -n exclude-from $D
+WVPASSEQ "$(bup ls exclude-from/latest/$TOP/$D/)" "a
 b
 f"
+rm $EXCLUDE_FILE