Permalink
Browse files

Renames --exclude-file to --exclude-from and encaspulates exclude-par…

…sing.

Signed-off-by: Zoran Zaric <zz@zoranzaric.de>
  • Loading branch information...
1 parent d47ca39 commit 92538ee6485429436b5e28f1677ff0811a2b90f7 @zoranzaric zoranzaric committed with Dec 2, 2010
Showing with 48 additions and 34 deletions.
  1. +10 −1 Documentation/bup-drecurse.md
  2. +5 −3 Documentation/bup-index.md
  3. +3 −5 cmd/drecurse-cmd.py
  4. +2 −19 cmd/index-cmd.py
  5. +21 −0 lib/bup/drecurse.py
  6. +7 −6 t/test.sh
@@ -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
@@ -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
View
@@ -6,7 +6,8 @@
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 @@
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:
View
@@ -132,7 +132,7 @@ def hashgen(name):
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 @@ def hashgen(name):
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)
View
@@ -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
+
View
@@ -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

0 comments on commit 92538ee

Please sign in to comment.