]> arthur.barton.de Git - bup.git/commitdiff
save-cmd.py: insist on having an index; check for the primary index file.
authorJean-Baptiste Denis <jbd@jbdenis.net>
Fri, 8 Mar 2013 22:43:26 +0000 (23:43 +0100)
committerRob Browning <rlb@defaultvalue.org>
Sun, 10 Mar 2013 23:54:13 +0000 (18:54 -0500)
Insist on having an index, and report an error (with a suggestion to
run "bup index") if one isn't found.

Previously (at least as recently as 0.25-rc1), bup save would just
create an empty tree if there was no index.  The metadata work
unintentionally broke that behavior.

For now, treat a missing index as an error under the assumption that
it's not likely to be intentional.  If a good use case for the
previous behavior is presented, we can always restore it.

Signed-off-by: Jean-Baptiste Denis <jbd@jbdenis.net>
[rlb@defaultvalue.org: adjust commit message and save-cmd.py error message.]
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
cmd/save-cmd.py

index b1e6e7b0eb374951b38a37bc425cf667fe2b75a9..3f1649a5e74c87f875f96c91d4bbff76439554f2 100755 (executable)
@@ -180,6 +180,9 @@ def progress_report(n):
 
 indexfile = opt.indexfile or git.repo('bupindex')
 r = index.Reader(indexfile)
+if not os.access(indexfile + '.meta', os.W_OK|os.R_OK):
+    log('error: cannot access "%s"; have you run bup index?' % indexfile)
+    sys.exit(1)
 msr = index.MetaStoreReader(indexfile + '.meta')
 hlink_db = hlinkdb.HLinkDB(indexfile + '.hlink')