]> arthur.barton.de Git - bup.git/commitdiff
'bup split' takes a list of filenames on the command line.
authorAvery Pennarun <apenwarr@gmail.com>
Thu, 31 Dec 2009 23:46:04 +0000 (18:46 -0500)
committerAvery Pennarun <apenwarr@gmail.com>
Thu, 31 Dec 2009 23:46:40 +0000 (18:46 -0500)
Makefile
cmd-split.py

index ae2924baa60742559da6cfbbd90af452edfdbbb2..d0df36c99d707de0aee2d3d9b6636e945da21308 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -15,7 +15,7 @@ runtests: all
 runtests-cmdline: all
        @echo "Testing \"$@\" in Makefile:"
        ./bup split -b <testfile1 >tags1
-       ./bup split -b <testfile2 >tags2
+       ./bup split -b testfile2 >tags2
        diff -u tags1 tags2 || true
        wc -c testfile1 testfile2
        wc -l tags1 tags2
index e5eb5c3a1f6f3a53e4e2552495031440e48c97a7..e755efec45338d73b7f88fdcbe9321ab1f694a30 100755 (executable)
@@ -52,7 +52,7 @@ def hashsplit_iter(f):
     lv = 0
     while blob or not eof:
         if not eof and (buf.used() < BLOB_LWM or not blob):
-            bnew = sys.stdin.read(BLOB_HWM)
+            bnew = f.read(BLOB_HWM)
             if not len(bnew): eof = 1
             #log('got %d, total %d\n' % (len(bnew), buf.used()))
             buf.put(bnew)
@@ -74,8 +74,17 @@ def hashsplit_iter(f):
             log('%d\t' % nv)
             lv = nv
 
+
+def autofiles(filenames):
+    if not filenames:
+        yield sys.stdin
+    else:
+        for n in filenames:
+            yield open(n)
+
+
 optspec = """
-bup split [-t] <filename
+bup split [-t] [filenames...]
 --
 b,blobs    output a series of blob ids
 t,tree     output a tree id
@@ -90,16 +99,17 @@ if not (opt.blobs or opt.tree or opt.commit or opt.name):
     log("bup split: use one or more of -b, -t, -c, -n\n")
     o.usage()
 
-
 start_time = time.time()
 shalist = []
 
 ofs = 0
-for (ofs, size, sha) in hashsplit_iter(sys.stdin):
-    #log('SPLIT @ %-8d size=%-8d\n' % (ofs, size))
-    if opt.blobs:
-        print sha
-    shalist.append(('100644', '%016x.bupchunk' % ofs, sha))
+
+for f in autofiles(extra):
+    for (ofs, size, sha) in hashsplit_iter(f):
+        #log('SPLIT @ %-8d size=%-8d\n' % (ofs, size))
+        if opt.blobs:
+            print sha
+        shalist.append(('100644', '%016x.bupchunk' % ofs, sha))
 tree = git.gen_tree(shalist)
 if opt.tree:
     print tree