test-meta.sh: use the more portable "touch -t" instead of "touch -d".

Thanks to Greg Troxel <gdt@work.lexort.com> for the report.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
web-cmd.py: add a tornado import guard like the one for fuse in fuse-cmd.py.

In Debian, we replace the embedded copy of tornado with a Recommends on
the python-tornado package. Print a nice error message instead of a
backtrace if the user doesn't have it installed.

Signed-off-by: Robert S. Edmonds <edmonds@debian.org>
[rlb@defaultvalue.org: edited commit and error message]
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
web-cmd.py: accommodate HTTPServer s/_socket/_sockets/ in newer versions.

Newer versions of tornado changed HTTPServer._socket to
HTTPServer._sockets, with slightly different semantics.  Handle both.

Thanks to Andy Somerville <andy.somerville@gmail.com> for reporting
the problem and proposing an initial patch.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
fuse-cmd.py: match the style of the import failure message in web-cmd.py.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
git.py: don't automatically initialize ~/.bup if it doesn't exist.

bup had a convenience feature where commands would automagically
initialize a repo in ~/.bup if it didn't exist and no other BUP_DIR
was given.

This had the odd effect that when one forgot to specify BUP_DIR, a bup
repo would be initialized in ~/.bup even though only a browsing
command was used.

This patch drops that behaviour.  Now all repositories must be
explicitly intiialized via "bup init".

Signed-off-by: Zoran Zaric <zz@zoranzaric.de>
[rlb@defaultvalue.org: edit commit message; fix test ("set +e" during
 init run).]
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
README.md: add a "bup init" step to "Using bup" since we killed auto-init.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Implement git.PackIdxV{1,2}.hashes_sorted_by_ofs()
Implement BitArray
Implement repository wide locking

Add git.lock(), git.unlock() and git.is_locked(), which handle locking
of the repository.
Add repack command
Make save and repack respect a lock
unlock repository on error "No reachable objects found"

running bup repack on an empty repository left the repository locked.

Signed-off-by: Tim Riemenschneider <debian@tim-riemenschneider.de>
Reviewed-by: Zoran Zaric <zz@zoranzaric.de>
also delete pack-*.vol000+200.par2 files after repack

otherwise these would be left behind

Signed-off-by: Tim Riemenschneider <debian@tim-riemenschneider.de>
[zz@zoranzaric.de: Remove the test that counts packfiles]
Signed-off-by: Zoran Zaric <zz@zoranzaric.de>
Bugfix: repack did not work for "larger" repositories

repack only worked, if the git.PackIdxList still contained all the
*.idx files, one per *.pack file. If they got replaced by a *.midx file,
not only it traversed objects multiple times, these objects are not
considered for repack. (Since I think that the other pack-files are
untouched, no data-loss should occur)

This fix tells PackIdxList to ignore the midx-files.

Signed-off-by: Tim Riemenschneider <git@tim-riemenschneider.de>
Reviewed-by: Zoran Zaric <zz@zoranzaric.de>
Fix: Use env-var BUP_MAIN_EXE

Instead of running 'bup fsck -g' (and thus require bup being in the PATH)
use the environment variable BUP_MAIN_EXE
(otherwise the testcase with par2 fails, too)

Signed-off-by: Tim Riemenschneider <git@tim-riemenschneider.de>
Reviewed-by: Zoran Zaric <zz@zoranzaric.de>
Delete midx after repack

otherwise subsequent bup-runs fire warnings of missing .idx files used by the
(old) midx-file(s)

Signed-off-by: Tim Riemenschneider <git@tim-riemenschneider.de>
Reviewed-by: Zoran Zaric <zz@zoranzaric.de>
A test-case for the repack-with-midx-problem

(containing a recipe to reproduce it)

Signed-off-by: Tim Riemenschneider <git@tim-riemenschneider.de>
[zz@zoranzaric.de: Remove grep-writing-objects-tests because we don't
rewrite the packfile anymore]
Signed-off-by: Zoran Zaric <zz@zoranzaric.de>
Add test for repack to check if all objects are reachable
Implement a pre Python 2.6 fallback bin() version
Add a method to calculate the set bits ratio in a BitArray