Do simple pack checking during receive-pack.

Call obj.check() for each object in a pack. This requires passing the
Pack object back from the various commit callbacks.

In the future, we might consider not even moving the pack in until after
has been checked. At the moment, however, the only way to complete a
thin pack is to move it in, so we must do that first. This results in a
garbage pack if the check fails, which would have to be cleaned up by
an eventual GC. However, since only corrupt objects (not packs) can be
written to disk, with the SHA of their corrupt contents, the chances of
actually hitting a corrupt object in practice are very small.

Change-Id: Ib6c6ae2846f77f6a6cd4849b9608c29886258673
client: advertise capabilities correctly per-service

git capabilities are per-service, and we should correctly advertise
capabilities to either upload-pack, receive-pack, or both.

Change-Id: Id6cf579fa698a10a56b43adc055fa6c0d25c6942
dulwich.errors: cleanup whitespace

Change-Id: I9340c0187bc4bcf78da5aa009957007e99c14557
client: Make SSHSubprocess slightly more forgiving for proto

Change-Id: I0c4ed84e0a261f90738220cf8fcb5c11102cf0a4
client: raise an exception when send_pack fails

Change-Id: I55f6caa6f5c050f5feb556c3c21be18d3e57fcba
Fixed filename of initial .git/info/exclude
Merge fix to write info/exclude rather than info/excludes file.
Merge use of constants for OFS/REF delta's.
Merge Dave, highlights:

* fix thin pack handling
* more object checking
* test cleanups
* code cleanups
Pass external object resolve function rather than full object store to ThinPackData constructor.
Distinguish between ShaFile.from_file and ShaFile.from_path.
Allow non-os file-like objects passed to ShaFile.from_file.
Add make_object and make_commit convenience functions to test utils.

These functions reduce typing needed to create objects for testing.
Instead of
    test_object = Object()
    test_object.attr1 = foo
    test_object.attr2 = bar
we can now write
    test_object = make_object(Object, attr1=foo, attr2=bar)

This is even more simplified for Commit objects, which have many
attributes, most of which we usually don't care about. Using make_commit
pre-populates attributes with some arbitrary default values, ensuring
commit objects can be serialized.

Updated relevant test code to use the new methods.

Change-Id: Id8266774efb56ef92a3db6cca42d3ec9d81fd2a0
Add __setitem__ to DictRefsContainer.

BaseRefsContainer assumes __setitem__, but it is not defined in the base
class. This was not a problem previously because DictRefsContainer was
not widely used, but that will change.

Change-Id: Ica0786e63ed2ef301c63671a5f3637048c0338f9
Fix numerous style issues.

This largely fixes whitespace and imports, with a few typo fixes as
well. I only touched code that was previously touched by me, except in
the case of imports, where blame data is less useful.

Change-Id: Ie34063eb5abb3283a5b9b80fc902efca39159a97
Fix "x if y else z" syntax for python2.4.

This syntax is not supported in python2.4, and is trivial to rewrite.

Change-Id: Ibbf46cd0276445c0cfb016c7b9b8e845125b4cad
Fix yield in try/finally for python2.4 compatibility.

A yield statement in a try block with a finally clause was not supported
prior to python2.5; the same effect can be achieved with either a bare
except clause or an additional level of nesting.

Change-Id: Ib13a9f492feb69184a48e1013b6461ea643f0ebd
Clarify make_commit docstring and variable names.

Change-Id: Ifccc31a7bb78adcbb539f360cc62a1e76e7f7943
Refactor server code to allow custom handler classes.

Also changed to use the same default handler mapping in both TCP
and HTTP servers.

Change-Id: I2fb22768a58ca6f21888593467959bb4176e64e6
Add a typedef for Py_ssize_t, which is not available in python <2.5.

Based on a suggestion at:
http://mail.python.org/pipermail/python-dev/2006-March/062561.html

Change-Id: I170c17eab8eaf586da1db329c96c015edd59314b