jelmer/dulwich-libgit2.git
13 years agoClean up asserts in Tree.
Dave Borowitz [Wed, 28 Apr 2010 17:43:08 +0000 (10:43 -0700)]
Clean up asserts in Tree.

Document the types of arguments to various tree methods instead of
asserting. In particular, these asserts were causing failures in
python2.4, when reading modes from the index resulted in a long rather
than an int. This is harmless, so the asserts were just dropped.

Change-Id: I4a8f8b1527e0fd9571ebdb760e09230f25ac3918

13 years agoConvert tree mode to int when sorting.
Dave Borowitz [Tue, 4 May 2010 18:20:23 +0000 (11:20 -0700)]
Convert tree mode to int when sorting.

This replaces the exact type check with the more pythonic (and
Python-2.4-compatible) PyNumber_Int, which is equivalent to int().

Change-Id: I142d9cfdf8250d9905a65756a95cf575ea81d377

13 years agoAdd non-bare repository tests.
Dave Borowitz [Wed, 28 Apr 2010 17:41:39 +0000 (10:41 -0700)]
Add non-bare repository tests.

These tests test building non-bare repos from scratch by manually
adding, staging, and committing files. Also fixed various bugs that the
tests exercise.

Change-Id: Ic5458b28f2e5e4534a7855f5be9562f4b59f5839

13 years agoFix RefsContainer.add_if_new to support dangling symrefs.
Dave Borowitz [Wed, 28 Apr 2010 19:36:22 +0000 (12:36 -0700)]
Fix RefsContainer.add_if_new to support dangling symrefs.

Change-Id: I411b60135c3374fefd03701db4bb0dc5d0644164

13 years agoTreat non-existent index files as empty.
Dave Borowitz [Wed, 28 Apr 2010 17:34:31 +0000 (10:34 -0700)]
Treat non-existent index files as empty.

Change-Id: Id9738a8fc6d3e53c6ef5b5b8d4144aaa5cd0e075

13 years agoFix up and test DictRefsContainer.
Dave Borowitz [Sat, 24 Apr 2010 01:53:36 +0000 (18:53 -0700)]
Fix up and test DictRefsContainer.

Refactored RefsContainerTests to put common tests in a common base
class.

Change-Id: Id5bd5a0b88a98bd43404e742972ba111fe5d51f3

13 years agoCope with missing newlines in patches.
Jelmer Vernooij [Tue, 11 May 2010 08:17:54 +0000 (10:17 +0200)]
Cope with missing newlines in patches.

13 years agoMerge cleanups and use of proper per-service capabilities from Augie.
Jelmer Vernooij [Wed, 5 May 2010 10:40:01 +0000 (12:40 +0200)]
Merge cleanups and use of proper per-service capabilities from Augie.

13 years agotest_pack: simpler assertion that passes in more places
Augie Fackler [Mon, 3 May 2010 03:25:42 +0000 (22:25 -0500)]
test_pack: simpler assertion that passes in more places

Change-Id: I224f251f791f1baf94910cc389797bf08139509a

13 years agoWhen diffstat is available, dulwich.patch.write_commit_patch() adds the
Tay Ray Chuan [Sun, 2 May 2010 14:10:17 +0000 (16:10 +0200)]
When diffstat is available, dulwich.patch.write_commit_patch() adds the
diffstat followed by a "\n", just before the contents and version info.
The assertion in test_simple() assumes that this is always the case, and
breaks when the diffstat is absent.

13 years agoImplement BaseRepo.__contains__.
Jelmer Vernooij [Sat, 1 May 2010 11:21:15 +0000 (13:21 +0200)]
Implement BaseRepo.__contains__.

13 years agoMerge cleanups from Dave.
Jelmer Vernooij [Fri, 30 Apr 2010 21:18:34 +0000 (23:18 +0200)]
Merge cleanups from Dave.

13 years agoAdd repository compat tests.
Dave Borowitz [Tue, 13 Apr 2010 23:29:46 +0000 (16:29 -0700)]
Add repository compat tests.

These tests ensure that dulwich and cgit think that the same repo has
the same set of refs and packed/loose objects.

Change-Id: Ie2f496e846228f3e9e30ff3eba031a3751bd3f62

13 years agoAdd SEEK_END to misc.py, since it was added in 2.5.
Dave Borowitz [Fri, 16 Apr 2010 23:05:53 +0000 (16:05 -0700)]
Add SEEK_END to misc.py, since it was added in 2.5.

Change-Id: I9caa891e53423b444063b2801da4043489647703

13 years agoAdd a typedef for Py_ssize_t, which is not available in python <2.5.
Dave Borowitz [Tue, 6 Apr 2010 23:29:49 +0000 (16:29 -0700)]
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

13 years agoRefactor server code to allow custom handler classes.
Dave Borowitz [Mon, 5 Apr 2010 23:55:28 +0000 (16:55 -0700)]
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

13 years agoClarify make_commit docstring and variable names.
Dave Borowitz [Thu, 25 Mar 2010 22:13:36 +0000 (15:13 -0700)]
Clarify make_commit docstring and variable names.

Change-Id: Ifccc31a7bb78adcbb539f360cc62a1e76e7f7943

13 years agoFix yield in try/finally for python2.4 compatibility.
Dave Borowitz [Mon, 22 Mar 2010 21:59:48 +0000 (14:59 -0700)]
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

13 years agoFix "x if y else z" syntax for python2.4.
Dave Borowitz [Mon, 22 Mar 2010 21:59:06 +0000 (14:59 -0700)]
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

13 years agoFix numerous style issues.
Dave Borowitz [Mon, 22 Mar 2010 21:40:31 +0000 (14:40 -0700)]
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

13 years agoAdd __setitem__ to DictRefsContainer.
Dave Borowitz [Mon, 22 Mar 2010 20:08:58 +0000 (13:08 -0700)]
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

13 years agoAdd make_object and make_commit convenience functions to test utils.
Dave Borowitz [Mon, 22 Mar 2010 16:44:10 +0000 (09:44 -0700)]
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

13 years agoAllow non-os file-like objects passed to ShaFile.from_file.
Jelmer Vernooij [Fri, 30 Apr 2010 13:17:04 +0000 (15:17 +0200)]
Allow non-os file-like objects passed to ShaFile.from_file.

13 years agoDistinguish between ShaFile.from_file and ShaFile.from_path.
Jelmer Vernooij [Fri, 30 Apr 2010 12:52:51 +0000 (14:52 +0200)]
Distinguish between ShaFile.from_file and ShaFile.from_path.

13 years agoPass external object resolve function rather than full object store to ThinPackData...
Jelmer Vernooij [Fri, 30 Apr 2010 00:38:39 +0000 (02:38 +0200)]
Pass external object resolve function rather than full object store to ThinPackData constructor.

13 years agoMerge Dave, highlights:
Jelmer Vernooij [Fri, 30 Apr 2010 00:35:44 +0000 (02:35 +0200)]
Merge Dave, highlights:

* fix thin pack handling
* more object checking
* test cleanups
* code cleanups

13 years agoMerge use of constants for OFS/REF delta's.
Jelmer Vernooij [Tue, 27 Apr 2010 21:21:40 +0000 (23:21 +0200)]
Merge use of constants for OFS/REF delta's.

14 years agoMerge fix to write info/exclude rather than info/excludes file.
Jelmer Vernooij [Mon, 26 Apr 2010 23:41:15 +0000 (01:41 +0200)]
Merge fix to write info/exclude rather than info/excludes file.

14 years agoFixed filename of initial .git/info/exclude
Travis Cline [Mon, 26 Apr 2010 22:36:41 +0000 (17:36 -0500)]
Fixed filename of initial .git/info/exclude

14 years agoclient: raise an exception when send_pack fails
Augie Fackler [Sun, 25 Apr 2010 18:27:43 +0000 (13:27 -0500)]
client: raise an exception when send_pack fails

Change-Id: I55f6caa6f5c050f5feb556c3c21be18d3e57fcba

13 years agoclient: Make SSHSubprocess slightly more forgiving for proto
Augie Fackler [Mon, 3 May 2010 03:25:42 +0000 (22:25 -0500)]
client: Make SSHSubprocess slightly more forgiving for proto

Change-Id: I0c4ed84e0a261f90738220cf8fcb5c11102cf0a4

14 years agodulwich.errors: cleanup whitespace
Augie Fackler [Sun, 25 Apr 2010 18:27:41 +0000 (13:27 -0500)]
dulwich.errors: cleanup whitespace

Change-Id: I9340c0187bc4bcf78da5aa009957007e99c14557

14 years agoclient: advertise capabilities correctly per-service
Augie Fackler [Sun, 25 Apr 2010 18:27:39 +0000 (13:27 -0500)]
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

14 years agoDo simple pack checking during receive-pack.
Dave Borowitz [Tue, 9 Mar 2010 19:44:14 +0000 (11:44 -0800)]
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

14 years agoClean up index tests.
Dave Borowitz [Tue, 9 Mar 2010 19:07:18 +0000 (11:07 -0800)]
Clean up index tests.

-Fix trailing whitespace.
-Fix SimpleIndexTestCase capitalization.
-Fix long line.
-Write files into temp dir instead of working directory.

This is the last of the tests that wrote into the working directory.

Change-Id: If8c194f645c93a68ff8493371ea712d7ca2da6dd

14 years agoClean up pack tests.
Dave Borowitz [Tue, 9 Mar 2010 18:53:09 +0000 (10:53 -0800)]
Clean up pack tests.

-Remove trailing whitespace.
-Fix long lines.
-Hard-code SHAs in their hexlified forms.
-Use '' consistently.
-Always write to temp directories instead of working directory.
-Various indentation and local var refactoring fixes.
-Moved TestHexToSha to test_objects.py, since those functions are from
 objects.py.
-While we're in there, also removed trailing whitespace in pack.py.

Change-Id: I19f133e3d867f31fa75e28142593f84807fbc746

14 years agoClean up object store tests.
Dave Borowitz [Tue, 9 Mar 2010 17:33:04 +0000 (09:33 -0800)]
Clean up object store tests.

-Moved SpecificDiskObjectStoreTests into DiskObjectStoreTests.
-Use pythonic syntax instead of calling __methods__ directory.
-Whitespace cleanup.

Change-Id: I484954ec00e7319c42fdd2d5762af0b38a45b6c3

14 years agoChange check() methods in pack.py to raise rather than return bools.
Dave Borowitz [Tue, 9 Mar 2010 01:22:01 +0000 (17:22 -0800)]
Change check() methods in pack.py to raise rather than return bools.

This makes Pack, PackIndex, and PackData consistent with the rest of
the check() methods recently added. Raising rather than returning makes
factoring out methods easier and exposes more information about the kind
of error that occurred. Moreover, in many cases, the correct default
behavior is probably to die anyway.

Change-Id: I87ab2b1e165c3c9e55727b25a49b1754c0ac4534

14 years agoHash packed objects without creating ShaFiles.
Dave Borowitz [Fri, 19 Mar 2010 02:46:25 +0000 (19:46 -0700)]
Hash packed objects without creating ShaFiles.

Recent changes to ShaFile result in parsing files when created from
strings. Since the packed object code was just using ShaFile for
computing a SHA, this change elminates that and hashes file contents
directly.

Change-Id: I70a14104fa896c248189f0839c24d02c48a43c4d

14 years agoSimplify and fix thin pack resolving.
Dave Borowitz [Fri, 19 Mar 2010 01:15:04 +0000 (18:15 -0700)]
Simplify and fix thin pack resolving.

This change cuts down on passing around callbacks to resolve external
references by creating a ThinPackData class that has different semantics
for resolving ref deltas. In all cases except thin packs, PackData
objects have associated pack objects (added as a member variable in
this change), so we can use the index to resolve ref deltas if they
exist. ThinPackDatas, on the other hand, are constructed with an
ObjectStore that is used for external ref resolving. Since we now
make use of the pack index, we only have to deal with postponing shas
in ThinPackData.iterentries. Since this is the only method used for
constructing an index, we still have to be able to handle ref deltas to
objects later in the file.

Modified the compat tests (and one small error in server.py) to
successfully exercise this code, but still missing unit tests.

Change-Id: I244b92c00cbae8e30883c5de4dbf47a9195bd174

14 years agoReplace ref delta/ofs delta magic numbers with constants.
Dave Borowitz [Mon, 15 Mar 2010 19:19:32 +0000 (12:19 -0700)]
Replace ref delta/ofs delta magic numbers with constants.

Change-Id: I49dc3fd7897b2748e4b355ee4ae1345a87431733

14 years agoAdd PackStreamReader.{offset,__len__}, extract PackObjectIterator.
Jelmer Vernooij [Sat, 17 Apr 2010 22:54:25 +0000 (00:54 +0200)]
Add PackStreamReader.{offset,__len__}, extract PackObjectIterator.

14 years agoMove PackStreamReader to dulwich.pack.
Jelmer Vernooij [Sat, 17 Apr 2010 22:40:37 +0000 (00:40 +0200)]
Move PackStreamReader to dulwich.pack.

14 years agoSplit generic pack reading code out of PackStreamVerifier.
Jelmer Vernooij [Sat, 17 Apr 2010 22:35:48 +0000 (00:35 +0200)]
Split generic pack reading code out of PackStreamVerifier.

14 years agoFix ordering of imports.
Jelmer Vernooij [Sat, 17 Apr 2010 22:12:41 +0000 (00:12 +0200)]
Fix ordering of imports.

14 years agoRemove unused imports.
Jelmer Vernooij [Sat, 17 Apr 2010 22:09:23 +0000 (00:09 +0200)]
Remove unused imports.

14 years agoAttempt to close index files properly.
Jelmer Vernooij [Fri, 16 Apr 2010 23:46:20 +0000 (01:46 +0200)]
Attempt to close index files properly.

14 years agoMerge various pack improvements from Dave.
Jelmer Vernooij [Fri, 16 Apr 2010 19:49:17 +0000 (21:49 +0200)]
Merge various pack improvements from Dave.

14 years agoClean up pack.py.
Dave Borowitz [Mon, 15 Mar 2010 19:19:19 +0000 (12:19 -0700)]
Clean up pack.py.

-Removed trailing whitespace.
-Fixed long lines.
-Various docstring cleanup.

Change-Id: I2ccde03bc56d0f69ba2e3be7e11b3effce2d30ed

14 years agoMake the server decode a pack as it streams.
Dave Borowitz [Thu, 11 Mar 2010 22:12:18 +0000 (14:12 -0800)]
Make the server decode a pack as it streams.

This, in combination with using recv() instead of read(), makes it so we
never do blocking reads past the end of the pack stream, even when the
client doesn't close the connection.

This is done via a PackStreamVerifier class that reads from a Protocol,
unpacks and counts objects, writes through to a file, and computes the
SHA-1 checksum on the fly. It is necessary because the only way we know
when the pack is supposed to end is by parsing the header and reading
the correct number of objects; otherwise, any further reads from the
client would hang.

Changed the Handler constructors to take a Protocol instead of taking
read and write callbacks separately. Modified some interfaces to utility
functions in pack.py so they can be used by the server-side code.

Change-Id: Id4d11e34658d1f00ad06e45330d0d128b367d8e5

14 years agoFix read_zlib_chunks to avoid appending junk data.
Dave Borowitz [Thu, 11 Mar 2010 22:10:17 +0000 (14:10 -0800)]
Fix read_zlib_chunks to avoid appending junk data.

Adding junk data to the end of data fed to the zlib.decompressobj
creates the potential for zlib errors if a read doesn't fill the entire
buffer. This implementation is cleaner, and only requires the assumption
that there is some data in the read source after the zlib stream. Since
compressed streams in packfiles are always followed by either a new
packed object or the SHA-1 trailer, this assumption should be safe.

Added more robust tests for zlib reading with various buffer sizes.

Change-Id: I813d30997edf3e0c924eceac05675e0eb121b96c

14 years agoAdd ReceivableProtocol that supports recv() as well as read().
Dave Borowitz [Thu, 11 Mar 2010 17:59:08 +0000 (09:59 -0800)]
Add ReceivableProtocol that supports recv() as well as read().

There are two different ways of dealing with reads beyond the end of a
TCP stream buffer. The usual rfile.read method blocks until exactly the
number of bytes (or EOF) are read. This causes deadlocks when we try to
do buffered reads from the stream. When reading a packfile. the cgit
client leaves the connection open, so EOF is never read.

The other method is to use the socket.recv method, which blocks until
at least one byte is read, then returns whatever is available (up to
bufsize).

ReceivableProtocol supports both ways of dealing with reads past the
end of a stream, which should be used in different contexts. Note that
currently the ReceivePackHandler code still deadlocks, since it doesn't
know when to stop calling recv.

Change-Id: I77bfea72bb09326d9946f64426637296d0389714

14 years agoStrip excess whitespace from capabilities lines.
Dave Borowitz [Wed, 10 Mar 2010 20:36:51 +0000 (12:36 -0800)]
Strip excess whitespace from capabilities lines.

C git separates client capabilities during send-pack with both \0 and a
space, so we need to handle that as well. This change is significantly
more lenient, but the cgit behavior is not well-documented, so there may
be more corner cases. It's hard to imagine that the extra strip() will
actually result in capabilities lists being parsed incorrectly.

Change-Id: I74b734e146add683b4c1e4ea6b575f458ec25de7

14 years agoPrevent server stack trace when the client request is a no-op.
Dave Borowitz [Wed, 10 Mar 2010 18:56:35 +0000 (10:56 -0800)]
Prevent server stack trace when the client request is a no-op.

The exception was not killing the server, just the connection, and was
technically correct since the server is supposed to close the connection
anyway when the client sends no wants. As a result, the compat tests
weren't failing.

A better long-term solution would be to modify the server used during
testing to stop serving if one request generates an exception.

Change-Id: I065463803f38175a50f364b11588929094a28aab

14 years agofix bug #557585 GitFile breaks dulwich on Windows
anatoly techtonik [Thu, 15 Apr 2010 17:53:31 +0000 (19:53 +0200)]
fix bug #557585 GitFile breaks dulwich on Windows
fix is to add os.O_BINARY flag as os.open doesn't open files as binary
on this platform by default

14 years agoCope with diffstat not being present in test_patch.
Jelmer Vernooij [Thu, 15 Apr 2010 17:51:21 +0000 (19:51 +0200)]
Cope with diffstat not being present in test_patch.

14 years agoAdd basic test for write_commit_patch.
Jelmer Vernooij [Thu, 15 Apr 2010 17:01:08 +0000 (19:01 +0200)]
Add basic test for write_commit_patch.

14 years agoFix fastexport commit exporter, add test.
Jelmer Vernooij [Thu, 15 Apr 2010 15:37:28 +0000 (17:37 +0200)]
Fix fastexport commit exporter, add test.

14 years agoAdd some basic tests for fastexport.
Jelmer Vernooij [Thu, 15 Apr 2010 14:55:47 +0000 (16:55 +0200)]
Add some basic tests for fastexport.

14 years agoCorrectly avoid parsing ShaFiles with fixed SHAs when calling sha().
Dave Borowitz [Mon, 8 Mar 2010 18:47:05 +0000 (10:47 -0800)]
Correctly avoid parsing ShaFiles with fixed SHAs when calling sha().

This required some reworking of the _needs_* and _sha ivars. Improved
check() to force computing the SHA and verifying that it matches the
previously-set value. Added a test for this check.

Change-Id: I6782693d7d7708bc7c28f357c27419d51409b884

14 years agoInitial work on a fastexport module.
Jelmer Vernooij [Thu, 1 Apr 2010 00:34:02 +0000 (02:34 +0200)]
Initial work on a fastexport module.

14 years agoAvoid double close when file has already gone away in abort().
Jelmer Vernooij [Fri, 16 Apr 2010 17:59:52 +0000 (19:59 +0200)]
Avoid double close when file has already gone away in abort().

14 years agoSkip test_dest_opened on non-Windows platforms.
Jelmer Vernooij [Fri, 16 Apr 2010 17:49:09 +0000 (19:49 +0200)]
Skip test_dest_opened on non-Windows platforms.

14 years agofix bug #557585 GitFile breaks dulwich on Windows
anatoly techtonik [Fri, 16 Apr 2010 17:25:52 +0000 (19:25 +0200)]
fix bug #557585 GitFile breaks dulwich on Windows
fix non-atomic os.rename() behavior on Windows that fails if target exists
added file.fancy_rename() that preserves source file is case rename fails

14 years agoAvoid mixing iterators/readline.
Jelmer Vernooij [Fri, 16 Apr 2010 01:35:57 +0000 (03:35 +0200)]
Avoid mixing iterators/readline.

14 years agoadd git_am_patch_split.
Jelmer Vernooij [Fri, 16 Apr 2010 00:49:03 +0000 (02:49 +0200)]
add git_am_patch_split.

14 years agofix bug #557585 GitFile breaks dulwich on Windows
anatoly techtonik [Thu, 15 Apr 2010 17:53:31 +0000 (19:53 +0200)]
fix bug #557585 GitFile breaks dulwich on Windows
fix is to add os.O_BINARY flag as os.open doesn't open files as binary
on this platform by default

14 years agoCope with diffstat not being present in test_patch.
Jelmer Vernooij [Thu, 15 Apr 2010 17:51:21 +0000 (19:51 +0200)]
Cope with diffstat not being present in test_patch.

14 years agoAdd basic test for write_commit_patch.
Jelmer Vernooij [Thu, 15 Apr 2010 17:01:08 +0000 (19:01 +0200)]
Add basic test for write_commit_patch.

14 years agomerge support for generating fastexport streams.
Jelmer Vernooij [Thu, 15 Apr 2010 16:13:25 +0000 (18:13 +0200)]
merge support for generating fastexport streams.

14 years agoFix fastexport commit exporter, add test.
Jelmer Vernooij [Thu, 15 Apr 2010 15:37:28 +0000 (17:37 +0200)]
Fix fastexport commit exporter, add test.

14 years agoAdd some basic tests for fastexport.
Jelmer Vernooij [Thu, 15 Apr 2010 14:55:47 +0000 (16:55 +0200)]
Add some basic tests for fastexport.

14 years agoMerge trunk.
Jelmer Vernooij [Thu, 15 Apr 2010 14:09:30 +0000 (16:09 +0200)]
Merge trunk.

14 years agoCorrectly avoid parsing ShaFiles with fixed SHAs when calling sha().
Dave Borowitz [Mon, 8 Mar 2010 18:47:05 +0000 (10:47 -0800)]
Correctly avoid parsing ShaFiles with fixed SHAs when calling sha().

This required some reworking of the _needs_* and _sha ivars. Improved
check() to force computing the SHA and verifying that it matches the
previously-set value. Added a test for this check.

Change-Id: I6782693d7d7708bc7c28f357c27419d51409b884

14 years agoFix Blob._deserialize.
Jelmer Vernooij [Wed, 14 Apr 2010 22:36:46 +0000 (00:36 +0200)]
Fix Blob._deserialize.

14 years agocompat tests: move assertRepos(Not)Equal to util
Augie Fackler [Tue, 13 Apr 2010 23:23:06 +0000 (18:23 -0500)]
compat tests: move assertRepos(Not)Equal to util

Change-Id: Ia226f2fed3b2b6dc23c11c541163bd081d0d45e7

14 years agodulwich.client: whitespace and 80 column cleanup
Augie Fackler [Tue, 13 Apr 2010 23:21:10 +0000 (18:21 -0500)]
dulwich.client: whitespace and 80 column cleanup

Change-Id: Idfd20438160153c863d96c7591d1797ed63d0727

14 years agoobject_store: clean up whitespace
Augie Fackler [Tue, 13 Apr 2010 18:40:55 +0000 (13:40 -0500)]
object_store: clean up whitespace

Change-Id: Ifa5cda814fb3aef7cfe68c27cd0388dc35c4cfa9

14 years agoMake ShaFiles created from files trust their filenames.
Dave Borowitz [Thu, 4 Mar 2010 23:37:24 +0000 (15:37 -0800)]
Make ShaFiles created from files trust their filenames.

This adds a dummy FixedSha class that implements the read-only part
of hashlib's hash interface but does not actually compute a SHA-1
digest. This allows us to assign ids to file objects based on their
filename rather than requiring a read of the whole file; SHA-1s will
soon be checked during check().

Added a filename_to_sha helper function to objects.py; refactored the
opposite sha_to_filename functionality into this file as well for
parallelism and testing. As a side effect, reorganized some files in
tests/data to have the normal 2/38 filename structure.

Change-Id: Ic459628aec32a92e29ea49cfd6cbe685053971ef

14 years agoLazily read the contents of ShaFiles from disk.
Dave Borowitz [Thu, 4 Mar 2010 20:39:40 +0000 (12:39 -0800)]
Lazily read the contents of ShaFiles from disk.

Previously, ShaFile.from_file read and inflated the entire contents of a
ShaFile, storing the inflated text in memory. Parsing that text was done
lazily, but this resulted in a confusing performance profile, since the
"lazy" part was in fact faster (memory/CPU-bound) than the eager part
(I/O-bound).

This change ensures that a file is only read fully from disk right
before it is about to be parsed. The first few bytes are still read
from disk to get the file type, but there is no need to slurp the
whole file. Moreover, we now maintain a distinction between ShaFiles
that are initialized from (possibly raw) strings and files initialized
with filenames. In order to parse the contents of a file, we need to
have one or the other. There is a third category of ShaFiles that
should never be parsed, where all the properties are intended to be set
explicitly (usually (but not always) during testing). These objects are
created as usual via __init__.

The tests all pass, but we do not currently have a way of testing the
point at which the implementation reads the whole file from disk.

Also, note that a call to foo.id still results in reading the whole file
and calculating its SHA-1; this behavior may change in the future.

Change-Id: Ib9f67ead0d2a812a2e43cffa54c37a1c4a219841

14 years agoCheck tag and commit objects for duplicate and out-of-order headers.
Dave Borowitz [Sat, 27 Feb 2010 19:29:44 +0000 (11:29 -0800)]
Check tag and commit objects for duplicate and out-of-order headers.

This requires factoring out the commit/tag parsing code so it can be
used directly from both the _parse_text and check methods. The parse
methods yield tuples, which can either be used to set members or
check for ordering.

Change-Id: I5ffe47100273912eaa283d03332286287b109a13

14 years agoAdd TESTFLAGS variable to Makefile to make running nosetests easier.
Dave Borowitz [Fri, 5 Mar 2010 21:16:09 +0000 (13:16 -0800)]
Add TESTFLAGS variable to Makefile to make running nosetests easier.

Change-Id: I7d94577883ad0805281bcac0003df964bfd05cdc

14 years agoAdd launchpad link.
Jelmer Vernooij [Tue, 13 Apr 2010 23:22:43 +0000 (01:22 +0200)]
Add launchpad link.

14 years agoFix whitespace bug in dul-web.
Dave Borowitz [Mon, 12 Apr 2010 22:09:09 +0000 (00:09 +0200)]
Fix whitespace bug in dul-web.

Had a tab that was syntactically correct, but since python treats tabs
as 8 spaces rather than 4 it resulted in incorrect behavior.

14 years agoMerge pack protocol receiver fix.
Jelmer Vernooij [Sun, 11 Apr 2010 01:01:04 +0000 (03:01 +0200)]
Merge pack protocol receiver fix.

14 years agoAdd DiskObjectStore.init.
Jelmer Vernooij [Sun, 11 Apr 2010 00:43:17 +0000 (02:43 +0200)]
Add DiskObjectStore.init.

14 years agotest_object_store: use temp dirs instead of 'foo'
Tay Ray Chuan [Sun, 11 Apr 2010 00:29:21 +0000 (02:29 +0200)]
test_object_store: use temp dirs instead of 'foo'

14 years agoclient: don't assume server response is of length 20 rc-fix-pack-protocol-v2
Tay Ray Chuan [Sun, 4 Apr 2010 14:58:31 +0000 (22:58 +0800)]
client: don't assume server response is of length 20

We do not for sure the length; it is safer to use
Protocol.read_pkt_line().

Also, handle HangupException if read_pkt_line() raises it. This happens
when talking to old versions of git-daemon (v1.6.6.1-26-g38a81b4), where
there won't be anything to read.

14 years agoObjectStoreGraphWalker.ack: use non-recursive implementation
Tay Ray Chuan [Fri, 9 Apr 2010 23:36:28 +0000 (01:36 +0200)]
ObjectStoreGraphWalker.ack: use non-recursive implementation

We were recursively removing from self.heads; rewrite this such we try
removing heads this in a loop.

This gives a nice performance boost.

14 years agoUse datetime.utcfromtimestamp() in tests.
Dave Borowitz [Fri, 9 Apr 2010 22:39:12 +0000 (00:39 +0200)]
Use datetime.utcfromtimestamp() in tests.

datetime.fromtimestamp() has the confusing behavior of treating the
timestamp as a UTC time and then converting to local time, but not
setting the tzinfo member. As a result, the function returns different
values depending on the local timezone, which makes it hard to write a
test that passes everywhere.

The output of datetime.utcfromtimestamp() is stable across all
timezones, which is all we really need for tests. (Returning sensible
datetime objects from the Commit/Tag API would require substantially
more work, but that is not fixed in this change.)

Tested in both US-Pacific and US-Eastern.

14 years agoPreserve '-' sign when -0000 is stored for the timezone in a commit/tag.
Jelmer Vernooij [Thu, 8 Apr 2010 22:29:32 +0000 (00:29 +0200)]
Preserve '-' sign when -0000 is stored for the timezone in a commit/tag.

14 years agoAdd Tree.__iter__.
Jelmer Vernooij [Thu, 8 Apr 2010 20:01:45 +0000 (22:01 +0200)]
Add Tree.__iter__.

14 years agoCope with \r in ref files on Windows.
Jelmer Vernooij [Wed, 7 Apr 2010 11:01:22 +0000 (13:01 +0200)]
Cope with \r in ref files on Windows.

14 years agoAvoid relying on PST for passing the testsuite.
Jelmer Vernooij [Thu, 8 Apr 2010 01:22:09 +0000 (03:22 +0200)]
Avoid relying on PST for passing the testsuite.

14 years agoEnsure we don't run past the end of the tree text.
Dave Borowitz [Thu, 8 Apr 2010 01:05:05 +0000 (03:05 +0200)]
Ensure we don't run past the end of the tree text.

We use strnlen so we can find namelen even if the buffer is truncated
in the name. This is not necessary for Python string objects, which are
guaranteed to be null-terminated, but some buffer objects (e.g. mmap)
may not be.

14 years agoRemove unused import, always ensure that objects is serialized before running check().
Jelmer Vernooij [Thu, 8 Apr 2010 01:02:15 +0000 (03:02 +0200)]
Remove unused import, always ensure that objects is serialized before running check().

14 years agoAdd check() methods to object classes for consistency checking.
Dave Borowitz [Thu, 8 Apr 2010 00:55:09 +0000 (02:55 +0200)]
Add check() methods to object classes for consistency checking.

These roughly mirror the parts of git fsck that deal with object
well-formedness, including checking the presence of required headers,
formatting of author/committer names, tree ordering, and so on. This
change does *not* include consistency checks that require touching other
objects; those will go in ObjectStore.

Note that currently many types of errors will still be raised during
object parsing proper, such as ValueErrors when trying to parse invalid
integers. In the check() method, any such exceptions are caught and
wrapped in an ObjectFormatException. The separate codepath also gives
us a place to put these checks if we decide to optimize them out of the
main object-parsing codepath.

14 years agoRename set_ref -> set_symbolic_ref.
Jelmer Vernooij [Mon, 5 Apr 2010 22:57:43 +0000 (00:57 +0200)]
Rename set_ref -> set_symbolic_ref.

14 years agoAvoid writing to stdout.
Jelmer Vernooij [Mon, 5 Apr 2010 22:29:30 +0000 (00:29 +0200)]
Avoid writing to stdout.

14 years agoFix import of NotTagError.
Jelmer Vernooij [Mon, 5 Apr 2010 19:59:47 +0000 (21:59 +0200)]
Fix import of NotTagError.