From beff87192372a8276eab5893a4da112bfc9dbb8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20David=20Ib=C3=A1=C3=B1ez?= Date: Wed, 12 Nov 2014 10:18:21 +0100 Subject: [PATCH] Minor styling --- docs/remotes.rst | 6 +++++- pygit2/repository.py | 10 ++-------- src/diff.c | 26 +++++++++++++------------- src/note.c | 4 ++-- src/pygit2.c | 2 +- src/types.h | 6 +++--- 6 files changed, 26 insertions(+), 28 deletions(-) diff --git a/docs/remotes.rst b/docs/remotes.rst index 933637f..1dcbe5d 100644 --- a/docs/remotes.rst +++ b/docs/remotes.rst @@ -2,7 +2,11 @@ Remotes ********************************************************************** -.. autoattribute:: pygit2.Repository.remotes +.. py:attribute:: Repository.remotes + + The collection of configured remotes, an instance of + :py:class:`pygit2.remote.RemoteCollection` + .. automethod:: pygit2.Repository.create_remote The remote collection diff --git a/pygit2/repository.py b/pygit2/repository.py index d31e03e..7a3f8a6 100644 --- a/pygit2/repository.py +++ b/pygit2/repository.py @@ -48,7 +48,7 @@ from .config import Config from .errors import check_error from .ffi import ffi, C from .index import Index -from .remote import Remote, RemoteCollection +from .remote import RemoteCollection from .blame import Blame from .utils import to_bytes, is_string @@ -58,7 +58,7 @@ class Repository(_Repository): def __init__(self, *args, **kwargs): super(Repository, self).__init__(*args, **kwargs) - self._remotes = RemoteCollection(self) + self.remotes = RemoteCollection(self) # Get the pointer as the contents of a buffer and store it for # later access @@ -98,12 +98,6 @@ class Repository(_Repository): return self.remotes.create(name, url) - @property - def remotes(self): - """The collection of configured remotes""" - - return self._remotes - # # Configuration # diff --git a/src/diff.c b/src/diff.c index 403c196..b8fcdab 100644 --- a/src/diff.c +++ b/src/diff.c @@ -44,7 +44,7 @@ extern PyTypeObject RepositoryType; PyTypeObject PatchType; -PyObject* +PyObject * wrap_diff(git_diff *diff, Repository *repo) { Diff *py_diff; @@ -53,7 +53,7 @@ wrap_diff(git_diff *diff, Repository *repo) if (py_diff) { Py_INCREF(repo); py_diff->repo = repo; - py_diff->list = diff; + py_diff->diff = diff; } return (PyObject*) py_diff; @@ -134,7 +134,7 @@ wrap_patch(git_patch *patch) return (PyObject*) py_patch; } -PyObject* +PyObject * diff_get_patch_byindex(git_diff *diff, size_t idx) { git_patch *patch = NULL; @@ -235,7 +235,7 @@ PyObject * DiffIter_iternext(DiffIter *self) { if (self->i < self->n) - return diff_get_patch_byindex(self->diff->list, self->i++); + return diff_get_patch_byindex(self->diff->diff, self->i++); PyErr_SetNone(PyExc_StopIteration); return NULL; @@ -284,8 +284,8 @@ PyTypeObject DiffIterType = { Py_ssize_t Diff_len(Diff *self) { - assert(self->list); - return (Py_ssize_t)git_diff_num_deltas(self->list); + assert(self->diff); + return (Py_ssize_t)git_diff_num_deltas(self->diff); } PyDoc_STRVAR(Diff_patch__doc__, "Patch diff string."); @@ -299,12 +299,12 @@ Diff_patch__get__(Diff *self) size_t i, len, num; PyObject *py_patch = NULL; - num = git_diff_num_deltas(self->list); + num = git_diff_num_deltas(self->diff); if (num == 0) Py_RETURN_NONE; for (i = 0, len = 1; i < num ; ++i) { - err = git_patch_from_diff(&patch, self->list, i); + err = git_patch_from_diff(&patch, self->diff, i); if (err < 0) goto cleanup; @@ -430,7 +430,7 @@ Diff_merge(Diff *self, PyObject *args) if (py_diff->repo->repo != self->repo->repo) return Error_set(GIT_ERROR); - err = git_diff_merge(self->list, py_diff->list); + err = git_diff_merge(self->diff, py_diff->diff); if (err < 0) return Error_set(err); @@ -455,7 +455,7 @@ Diff_find_similar(Diff *self, PyObject *args, PyObject *kwds) &opts.flags, &opts.rename_threshold, &opts.copy_threshold, &opts.rename_from_rewrite_threshold, &opts.break_rewrite_threshold, &opts.rename_limit)) return NULL; - err = git_diff_find_similar(self->list, &opts); + err = git_diff_find_similar(self->diff, &opts); if (err < 0) return Error_set(err); @@ -472,7 +472,7 @@ Diff_iter(Diff *self) Py_INCREF(self); iter->diff = self; iter->i = 0; - iter->n = git_diff_num_deltas(self->list); + iter->n = git_diff_num_deltas(self->diff); } return (PyObject*)iter; } @@ -487,14 +487,14 @@ Diff_getitem(Diff *self, PyObject *value) i = PyLong_AsUnsignedLong(value); - return diff_get_patch_byindex(self->list, i); + return diff_get_patch_byindex(self->diff, i); } static void Diff_dealloc(Diff *self) { - git_diff_free(self->list); + git_diff_free(self->diff); Py_CLEAR(self->repo); PyObject_Del(self); } diff --git a/src/note.c b/src/note.c index ec50659..6a7a437 100644 --- a/src/note.c +++ b/src/note.c @@ -39,7 +39,7 @@ extern PyTypeObject SignatureType; PyDoc_STRVAR(Note_remove__doc__, "Removes a note for an annotated object"); -PyObject* +PyObject * Note_remove(Note *self, PyObject* args) { char *ref = "refs/notes/commits"; @@ -208,7 +208,7 @@ PyTypeObject NoteIterType = { }; -PyObject* +PyObject * wrap_note(Repository* repo, git_oid* annotated_id, const char* ref) { Note* py_note = NULL; diff --git a/src/pygit2.c b/src/pygit2.c index 767ae2e..2fec0c1 100644 --- a/src/pygit2.c +++ b/src/pygit2.c @@ -149,7 +149,7 @@ PyMethodDef module_methods[] = { {NULL} }; -PyObject* +PyObject * moduleinit(PyObject* m) { if (m == NULL) diff --git a/src/types.h b/src/types.h index 077439d..78747cf 100644 --- a/src/types.h +++ b/src/types.h @@ -90,12 +90,12 @@ typedef struct { } NoteIter; -/* git _diff */ -SIMPLE_TYPE(Diff, git_diff, list) +/* git_diff */ +SIMPLE_TYPE(Diff, git_diff, diff) typedef struct { PyObject_HEAD - Diff* diff; + Diff *diff; size_t i; size_t n; } DiffIter;