parent
909e03d8fc
commit
961d007b02
@ -44,6 +44,8 @@ API changes::
|
||||
Patch.status => Patch.delta.status
|
||||
Patch.similarity => Patch.delta.similarity
|
||||
Patch.is_binary => Patch.delta.is_binary
|
||||
Patch.additions => Patch.line_stats[1]
|
||||
Patch.deletions => Patch.line_stats[2]
|
||||
|
||||
|
||||
0.22.0 (2015-01-16)
|
||||
|
29
src/patch.c
29
src/patch.c
@ -48,7 +48,7 @@ wrap_patch(git_patch *patch)
|
||||
|
||||
py_patch = PyObject_New(Patch, &PatchType);
|
||||
if (py_patch) {
|
||||
size_t i, j, hunk_amounts, lines_in_hunk, additions, deletions;
|
||||
size_t i, j, hunk_amounts, lines_in_hunk;
|
||||
const git_diff_delta *delta;
|
||||
const git_diff_hunk *hunk;
|
||||
const git_diff_line *line;
|
||||
@ -58,10 +58,6 @@ wrap_patch(git_patch *patch)
|
||||
|
||||
delta = git_patch_get_delta(patch);
|
||||
|
||||
git_patch_line_stats(NULL, &additions, &deletions, patch);
|
||||
py_patch->additions = additions;
|
||||
py_patch->deletions = deletions;
|
||||
|
||||
hunk_amounts = git_patch_num_hunks(patch);
|
||||
py_patch->hunks = PyList_New(hunk_amounts);
|
||||
for (i = 0; i < hunk_amounts; ++i) {
|
||||
@ -125,15 +121,34 @@ Patch_delta__get__(Patch *self)
|
||||
return wrap_diff_delta(git_patch_get_delta(self->patch));
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(Patch_line_stats__doc__,
|
||||
"Get line counts of each type in a patch.");
|
||||
|
||||
PyObject *
|
||||
Patch_line_stats__get__(Patch *self)
|
||||
{
|
||||
size_t context, additions, deletions;
|
||||
int err;
|
||||
|
||||
if (!self->patch)
|
||||
Py_RETURN_NONE;
|
||||
|
||||
err = git_patch_line_stats(&context, &additions, &deletions,
|
||||
self->patch);
|
||||
if (err < 0)
|
||||
return Error_set(err);
|
||||
|
||||
return Py_BuildValue("III", context, additions, deletions);
|
||||
}
|
||||
|
||||
PyMemberDef Patch_members[] = {
|
||||
MEMBER(Patch, hunks, T_OBJECT, "hunks"),
|
||||
MEMBER(Patch, additions, T_INT, "additions"),
|
||||
MEMBER(Patch, deletions, T_INT, "deletions"),
|
||||
{NULL}
|
||||
};
|
||||
|
||||
PyGetSetDef Patch_getseters[] = {
|
||||
GETTER(Patch, delta),
|
||||
GETTER(Patch, line_stats),
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
@ -95,8 +95,6 @@ typedef struct {
|
||||
PyObject_HEAD
|
||||
git_patch *patch;
|
||||
PyObject* hunks;
|
||||
unsigned additions;
|
||||
unsigned deletions;
|
||||
} Patch;
|
||||
|
||||
/* git_diff */
|
||||
|
Loading…
x
Reference in New Issue
Block a user