From: Zoran Zaric Date: Thu, 2 Dec 2010 06:24:12 +0000 (+0100) Subject: Adds --exclude-file option to bup index. X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=a1d5ae13d5739cc8810f11f6d590ec9dc30f700e;p=packages%2Fb%2Fbup.git Adds --exclude-file option to bup index. Signed-off-by: Zoran Zaric --- diff --git a/cmd/index-cmd.py b/cmd/index-cmd.py index c78dc76..2710c02 100755 --- a/cmd/index-cmd.py +++ b/cmd/index-cmd.py @@ -131,7 +131,8 @@ fake-valid mark all index entries as up-to-date even if they aren't 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 ore than once) +exclude= a path to exclude from the backup (can be used more than once) +exclude-file= a file that contains exclude paths v,verbose increase log output (can be used more than once) """ o = options.Options('bup index', optspec) @@ -153,14 +154,24 @@ if opt.check: log('check: starting initial check.\n') check_index(index.Reader(indexfile)) +excluded_paths = [] + if opt.exclude: - excluded_paths = [] for flag in flags: (option, parameter) = flag if option == '--exclude': excluded_paths.append(realpath(parameter)) -else: - excluded_paths = None + +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() + paths = index.reduce_paths(extra) diff --git a/t/test.sh b/t/test.sh index 233e4b4..458f69a 100755 --- a/t/test.sh +++ b/t/test.sh @@ -281,3 +281,24 @@ bup save -n exclude $D WVPASSEQ "$(bup ls exclude/latest/$TOP/$D/)" "a b f" + +WVSTART "exclude-file" +D=exclude-filedir.tmp +EXCLUDE_FILE=exclude-file.tmp +echo "$D/d + $TOP/$D/g +$D/h" > $EXCLUDE_FILE +rm -rf $D +mkdir $D +export BUP_DIR="$D/.bup" +WVPASS bup init +touch $D/a +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 +b +f"