Implement git.PackIdxV{1,2}.hashes_sorted_by_ofs()
Implement BitArray
Add repack command
Implement repository wide locking

Add git.lock(), git.unlock() and git.is_locked(), which handle locking
of the repository.
Add locking to 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
Don't rewrite packfiles when all objects are needed

Reported-by: Yung-Chin Oei <yungchin@yungchin.nl>
Merge branch 'index-excludes' into merged

Conflicts:
    Documentation/bup-index.md
    cmd/index-cmd.py
    lib/bup/drecurse.py
    t/test.sh
fix testcase
Merge branch 'ref-names-with-slashes' into merged
Merge branch 'set-config-packsize-limit' into merged