Merge remote-tracking branch 'alexband/size'

This commit is contained in:
J. David Ibáñez 2013-11-01 10:26:12 +01:00
commit 145646a73b
2 changed files with 8 additions and 1 deletions

View File

@ -271,6 +271,12 @@ PyTypeObject DiffIterType = {
(iternextfunc) DiffIter_iternext, /* tp_iternext */
};
Py_ssize_t
Diff_len(Diff *self)
{
assert(self->list);
return (Py_ssize_t)git_diff_num_deltas(self->list);
}
PyDoc_STRVAR(Diff_patch__doc__, "Patch diff string.");
@ -466,7 +472,7 @@ PyGetSetDef Diff_getseters[] = {
};
PyMappingMethods Diff_as_mapping = {
0, /* mp_length */
(lenfunc)Diff_len, /* mp_length */
(binaryfunc)Diff_getitem, /* mp_subscript */
0, /* mp_ass_subscript */
};

View File

@ -255,6 +255,7 @@ class DiffTest(utils.BareRepoTestCase):
diff = commit_a.tree.diff_to_tree(commit_b.tree)
self.assertEqual(diff.patch, PATCH)
self.assertEqual(len(diff), len([patch for patch in diff]))
def test_diff_oids(self):
commit_a = self.repo[COMMIT_SHA1_1]