]> arthur.barton.de Git - bup.git/blobdiff - cmd/index-cmd.py
options: remove unused 'exe' parameter
[bup.git] / cmd / index-cmd.py
index be064fb3f79739fc7d5ac08fcb7f8db4eb7331fe..0ff637ab97a809d4632148d732822f1518572f9b 100755 (executable)
@@ -1,5 +1,5 @@
 #!/usr/bin/env python
-import sys, stat, time
+import sys, stat, time, os
 from bup import options, git, index, drecurse
 from bup.helpers import *
 
@@ -54,7 +54,7 @@ def check_index(reader):
     log('check: passed.\n')
 
 
-def update_index(top):
+def update_index(top, excluded_paths):
     ri = index.Reader(indexfile)
     wi = index.Writer(indexfile)
     rig = IterHelper(ri.iter(name=top))
@@ -66,7 +66,10 @@ def update_index(top):
             return (0100644, index.FAKE_SHA)
 
     total = 0
-    for (path,pst) in drecurse.recursive_dirlist([top], xdev=opt.xdev):
+    bup_dir = os.path.abspath(git.repo())
+    for (path,pst) in drecurse.recursive_dirlist([top], xdev=opt.xdev,
+                                                 bup_dir=bup_dir,
+                                                 excluded_paths=excluded_paths):
         if opt.verbose>=2 or (opt.verbose==1 and stat.S_ISDIR(pst.st_mode)):
             sys.stdout.write('%s\n' % path)
             sys.stdout.flush()
@@ -127,10 +130,12 @@ x,xdev,one-file-system  don't cross filesystem boundaries
 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 (default 'index')
+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-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)
+o = options.Options(optspec)
 (opt, flags, extra) = o.parse(sys.argv[1:])
 
 if not (opt.modified or opt['print'] or opt.status or opt.update or opt.check):
@@ -149,13 +154,15 @@ if opt.check:
     log('check: starting initial check.\n')
     check_index(index.Reader(indexfile))
 
+excluded_paths = drecurse.parse_excludes(flags)
+
 paths = index.reduce_paths(extra)
 
 if opt.update:
-    if not paths:
+    if not extra:
         o.fatal('update (-u) requested but no paths given')
     for (rp,path) in paths:
-        update_index(rp)
+        update_index(rp, excluded_paths)
 
 if opt['print'] or opt.status or opt.modified:
     for (name, ent) in index.Reader(indexfile).filter(extra or ['']):