From cc55f3fd5e6fd5c3ccfcb9a7477e1b0a7bc3e8f2 Mon Sep 17 00:00:00 2001 From: "Luiz Fernando N. Capitulino" Date: Sun, 15 Jul 2007 17:19:24 -0300 Subject: [PATCH] libgit-thin: pygit: More revlist methods Signed-off-by: Luiz Fernando N. Capitulino --- libgit-thin/pygit/pygit.c | 60 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 9 deletions(-) diff --git a/libgit-thin/pygit/pygit.c b/libgit-thin/pygit/pygit.c index 15b9f3122c..b47daf7b29 100644 --- a/libgit-thin/pygit/pygit.c +++ b/libgit-thin/pygit/pygit.c @@ -20,13 +20,6 @@ pygit_error(void) strerror(errno)); } -static PyObject * -pygit_error_revlist(void) -{ - PyErr_SetString(PyGitError, "revlist not configured"); - return NULL; -} - static int pyarg_to_sha1(PyObject *args, unsigned char *sha1) { @@ -211,7 +204,7 @@ pygit_revlist_free(GitRevListObject *self) } static PyObject * -pygit_revlist_include(GitRevListObject *self, PyObject *args) +pygit_revlist_add_commit(GitRevListObject *self, PyObject *args, int exclude) { int err; unsigned char sha1[GIT_SHA1_SIZE]; @@ -222,7 +215,53 @@ pygit_revlist_include(GitRevListObject *self, PyObject *args) return NULL; } - err = git_revlist_include(self->opt, sha1); + if (exclude) + err = git_revlist_exclude(self->opt, sha1); + else + err = git_revlist_include(self->opt, sha1); + + if (err) + return pygit_error(); + + Py_RETURN_NONE; +} + +static PyObject * +pygit_revlist_include(GitRevListObject *self, PyObject *args) +{ + return pygit_revlist_add_commit(self, args, 0); +} + +static PyObject * +pygit_revlist_exclude(GitRevListObject *self, PyObject *args) +{ + return pygit_revlist_add_commit(self, args, 1); +} + +static PyObject * +pygit_revlist_reverse(GitRevListObject *self, PyObject *args) +{ + int err; + + UNUSED(args); + + err = git_revlist_reverse(self->opt); + if (err) + return pygit_error(); + + Py_RETURN_NONE; +} + +static PyObject * +pygit_revlist_max_count(GitRevListObject *self, PyObject *args) +{ + int err; + unsigned long count; + + if (!PyArg_ParseTuple(args, "k", &count)) + return NULL; + + err = git_revlist_max_count(self->opt, (size_t) count); if (err) return pygit_error(); @@ -231,6 +270,9 @@ pygit_revlist_include(GitRevListObject *self, PyObject *args) static PyMethodDef git_revlist_methods[] = { {"include", (PyCFunction) pygit_revlist_include, METH_VARARGS, NULL}, + {"exclude", (PyCFunction) pygit_revlist_exclude, METH_VARARGS, NULL}, + {"reverse", (PyCFunction) pygit_revlist_reverse, METH_NOARGS, NULL}, + {"max_count", (PyCFunction) pygit_revlist_max_count,METH_VARARGS,NULL}, {NULL, NULL, 0, NULL} }; -- 2.11.4.GIT