Adjust to oid -> id renaming

This commit is contained in:
Carlos Martín Nieto
2014-02-02 20:28:23 +01:00
parent dd6fc972dd
commit e5f6798f67
15 changed files with 69 additions and 69 deletions

View File

@@ -50,8 +50,8 @@ Attributes:
.. autoattribute:: pygit2.Patch.old_file_path .. autoattribute:: pygit2.Patch.old_file_path
.. autoattribute:: pygit2.Patch.new_file_path .. autoattribute:: pygit2.Patch.new_file_path
.. autoattribute:: pygit2.Patch.old_oid .. autoattribute:: pygit2.Patch.old_id
.. autoattribute:: pygit2.Patch.new_oid .. autoattribute:: pygit2.Patch.new_id
.. autoattribute:: pygit2.Patch.status .. autoattribute:: pygit2.Patch.status
.. autoattribute:: pygit2.Patch.similarity .. autoattribute:: pygit2.Patch.similarity
.. autoattribute:: pygit2.Patch.hunks .. autoattribute:: pygit2.Patch.hunks

View File

@@ -22,8 +22,8 @@ merge with the default ones defined in GIT_MERGE_OPTS_INIT libgit2 constant.
Example:: Example::
>>> branch_head_hex = '5ebeeebb320790caf276b9fc8b24546d63316533' >>> branch_head_hex = '5ebeeebb320790caf276b9fc8b24546d63316533'
>>> branch_oid = self.repo.get(branch_head_hex).id >>> branch_id = self.repo.get(branch_head_hex).id
>>> merge_result = self.repo.merge(branch_oid) >>> merge_result = self.repo.merge(branch_id)
The MergeResult object The MergeResult object
====================== ======================
@@ -33,5 +33,5 @@ Represents the result of a merge and contains these fields:
- is_uptodate: bool, if there wasn't any merge because the repo was already - is_uptodate: bool, if there wasn't any merge because the repo was already
up to date up to date
- is_fastforward: bool, whether the merge was fastforward or not - is_fastforward: bool, whether the merge was fastforward or not
- fastforward_oid: Oid, in the case it was a fastforward, this is the - fastforward_id: Oid, in the case it was a fastforward, this is the
forwarded Oid. forwarded id.

View File

@@ -14,14 +14,14 @@ type.
Object lookup Object lookup
================= =================
In the previous chapter we learnt about Object IDs. With an oid we can ask the In the previous chapter we learnt about Object IDs. With an Oid we can ask the
repository to get the associated object. To do that the ``Repository`` class repository to get the associated object. To do that the ``Repository`` class
implementes a subset of the mapping interface. implementes a subset of the mapping interface.
.. automethod:: pygit2.Repository.get .. automethod:: pygit2.Repository.get
Return the Git object for the given *oid*, returns the *default* value if Return the Git object for the given *id*, returns the *default* value if
there's no object in the repository with that oid. The oid can be an Oid there's no object in the repository with that id. The id can be an Oid
object, or an hexadecimal string. object, or an hexadecimal string.
Example:: Example::
@@ -32,16 +32,16 @@ implementes a subset of the mapping interface.
>>> obj >>> obj
<_pygit2.Commit object at 0x7ff27a6b60f0> <_pygit2.Commit object at 0x7ff27a6b60f0>
.. method:: Repository.__getitem__(oid) .. method:: Repository.__getitem__(id)
Return the Git object for the given oid, raise ``KeyError`` if there's no Return the Git object for the given id, raise ``KeyError`` if there's no
object in the repository with that oid. The oid can be an Oid object, or object in the repository with that id. The id can be an Oid object, or
an hexadecimal string. an hexadecimal string.
.. method:: Repository.__contains__(oid) .. method:: Repository.__contains__(id)
Returns True if there is an object in the Repository with that oid, False Returns True if there is an object in the Repository with that id, False
if there is not. The oid can be an Oid object, or an hexadecimal string. if there is not. The id can be an Oid object, or an hexadecimal string.
The Object base type The Object base type
@@ -125,15 +125,15 @@ them to the Git object database:
Example: Example:
>>> oid = repo.create_blob('foo bar') # Creates blob from bytes string >>> id = repo.create_blob('foo bar') # Creates blob from bytes string
>>> blob = repo[oid] >>> blob = repo[id]
>>> blob.data >>> blob.data
'foo bar' 'foo bar'
.. automethod:: pygit2.Repository.create_blob_fromworkdir .. automethod:: pygit2.Repository.create_blob_fromworkdir
.. automethod:: pygit2.Repository.create_blob_fromdisk .. automethod:: pygit2.Repository.create_blob_fromdisk
There are also some functions to calculate the oid for a byte string without There are also some functions to calculate the id for a byte string without
creating the blob object: creating the blob object:
.. autofunction:: pygit2.hash .. autofunction:: pygit2.hash

View File

@@ -92,8 +92,8 @@ Example::
>>> for entry in head.log(): >>> for entry in head.log():
... print(entry.message) ... print(entry.message)
.. autoattribute:: pygit2.RefLogEntry.oid_new .. autoattribute:: pygit2.RefLogEntry.id_new
.. autoattribute:: pygit2.RefLogEntry.oid_old .. autoattribute:: pygit2.RefLogEntry.id_old
.. autoattribute:: pygit2.RefLogEntry.message .. autoattribute:: pygit2.RefLogEntry.message
.. autoattribute:: pygit2.RefLogEntry.committer .. autoattribute:: pygit2.RefLogEntry.committer
@@ -109,6 +109,6 @@ The Note type
-------------------- --------------------
.. autoattribute:: pygit2.Note.annotated_id .. autoattribute:: pygit2.Note.annotated_id
.. autoattribute:: pygit2.Note.oid .. autoattribute:: pygit2.Note.id
.. autoattribute:: pygit2.Note.message .. autoattribute:: pygit2.Note.message
.. automethod:: pygit2.Note.remove .. automethod:: pygit2.Note.remove

View File

@@ -8,8 +8,8 @@ Index read::
>>> index = repo.index >>> index = repo.index
>>> index.read() >>> index.read()
>>> oid = index['path/to/file'].id # from path to object id >>> id = index['path/to/file'].id # from path to object id
>>> blob = repo[oid] # from object id to object >>> blob = repo[id] # from object id to object
Iterate over all entries of the index:: Iterate over all entries of the index::
@@ -43,7 +43,7 @@ The Index type
The IndexEntry type The IndexEntry type
-------------------- --------------------
.. autoattribute:: pygit2.IndexEntry.oid .. autoattribute:: pygit2.IndexEntry.id
.. autoattribute:: pygit2.IndexEntry.hex .. autoattribute:: pygit2.IndexEntry.hex
.. autoattribute:: pygit2.IndexEntry.path .. autoattribute:: pygit2.IndexEntry.path
.. autoattribute:: pygit2.IndexEntry.mode .. autoattribute:: pygit2.IndexEntry.mode

View File

@@ -80,8 +80,8 @@ wrap_patch(git_patch *patch)
py_patch->status = git_diff_status_char(delta->status); py_patch->status = git_diff_status_char(delta->status);
py_patch->similarity = delta->similarity; py_patch->similarity = delta->similarity;
py_patch->flags = delta->flags; py_patch->flags = delta->flags;
py_patch->old_oid = git_oid_allocfmt(&delta->old_file.oid); py_patch->old_id = git_oid_allocfmt(&delta->old_file.id);
py_patch->new_oid = git_oid_allocfmt(&delta->new_file.oid); py_patch->new_id = git_oid_allocfmt(&delta->new_file.id);
git_patch_line_stats(NULL, &additions, &deletions, patch); git_patch_line_stats(NULL, &additions, &deletions, patch);
py_patch->additions = additions; py_patch->additions = additions;
@@ -149,8 +149,8 @@ static void
Patch_dealloc(Patch *self) Patch_dealloc(Patch *self)
{ {
Py_CLEAR(self->hunks); Py_CLEAR(self->hunks);
free(self->old_oid); free(self->old_id);
free(self->new_oid); free(self->new_id);
/* We do not have to free old_file_path and new_file_path, they will /* We do not have to free old_file_path and new_file_path, they will
* be freed by git_diff_list_free in Diff_dealloc */ * be freed by git_diff_list_free in Diff_dealloc */
PyObject_Del(self); PyObject_Del(self);
@@ -159,8 +159,8 @@ Patch_dealloc(Patch *self)
PyMemberDef Patch_members[] = { PyMemberDef Patch_members[] = {
MEMBER(Patch, old_file_path, T_STRING, "old file path"), MEMBER(Patch, old_file_path, T_STRING, "old file path"),
MEMBER(Patch, new_file_path, T_STRING, "new file path"), MEMBER(Patch, new_file_path, T_STRING, "new file path"),
MEMBER(Patch, old_oid, T_STRING, "old oid"), MEMBER(Patch, old_id, T_STRING, "old oid"),
MEMBER(Patch, new_oid, T_STRING, "new oid"), MEMBER(Patch, new_id, T_STRING, "new oid"),
MEMBER(Patch, status, T_CHAR, "status"), MEMBER(Patch, status, T_CHAR, "status"),
MEMBER(Patch, similarity, T_INT, "similarity"), MEMBER(Patch, similarity, T_INT, "similarity"),
MEMBER(Patch, hunks, T_OBJECT, "hunks"), MEMBER(Patch, hunks, T_OBJECT, "hunks"),

View File

@@ -628,7 +628,7 @@ IndexEntry_init(IndexEntry *self, PyObject *args, PyObject *kwds)
return -1; return -1;
if (id) if (id)
git_oid_cpy(&self->entry.oid, &id->oid); git_oid_cpy(&self->entry.id, &id->oid);
if (mode) if (mode)
self->entry.mode = mode; self->entry.mode = mode;
@@ -689,18 +689,18 @@ IndexEntry_path__set__(IndexEntry *self, PyObject *py_path)
return 0; return 0;
} }
PyDoc_STRVAR(IndexEntry_oid__doc__, "Object id."); PyDoc_STRVAR(IndexEntry_id__doc__, "Object id.");
PyObject * PyObject *
IndexEntry_oid__get__(IndexEntry *self) IndexEntry_id__get__(IndexEntry *self)
{ {
return git_oid_to_python(&self->entry.oid); return git_oid_to_python(&self->entry.id);
} }
int int
IndexEntry_oid__set__(IndexEntry *self, PyObject *py_id) IndexEntry_id__set__(IndexEntry *self, PyObject *py_id)
{ {
if (!py_oid_to_git_oid(py_id, &self->entry.oid)) if (!py_oid_to_git_oid(py_id, &self->entry.id))
return -1; return -1;
return 0; return 0;
@@ -711,13 +711,13 @@ PyDoc_STRVAR(IndexEntry_hex__doc__, "Hex id.");
PyObject * PyObject *
IndexEntry_hex__get__(IndexEntry *self) IndexEntry_hex__get__(IndexEntry *self)
{ {
return git_oid_to_py_str(&self->entry.oid); return git_oid_to_py_str(&self->entry.id);
} }
PyGetSetDef IndexEntry_getseters[] = { PyGetSetDef IndexEntry_getseters[] = {
GETSET(IndexEntry, mode), GETSET(IndexEntry, mode),
GETSET(IndexEntry, path), GETSET(IndexEntry, path),
GETSET(IndexEntry, oid), GETSET(IndexEntry, id),
GETTER(IndexEntry, hex), GETTER(IndexEntry, hex),
{NULL}, {NULL},
}; };

View File

@@ -80,15 +80,15 @@ MergeResult_is_fastforward__get__(MergeResult *self)
Py_RETURN_FALSE; Py_RETURN_FALSE;
} }
PyDoc_STRVAR(MergeResult_fastforward_oid__doc__, "Fastforward Oid"); PyDoc_STRVAR(MergeResult_fastforward_id__doc__, "Fastforward Oid");
PyObject * PyObject *
MergeResult_fastforward_oid__get__(MergeResult *self) MergeResult_fastforward_id__get__(MergeResult *self)
{ {
if (git_merge_result_is_fastforward(self->result)) { if (git_merge_result_is_fastforward(self->result)) {
git_oid fastforward_oid; git_oid fastforward_id;
git_merge_result_fastforward_oid(&fastforward_oid, self->result); git_merge_result_fastforward_id(&fastforward_id, self->result);
return git_oid_to_python((const git_oid *)&fastforward_oid); return git_oid_to_python((const git_oid *)&fastforward_id);
} }
else Py_RETURN_NONE; else Py_RETURN_NONE;
} }
@@ -96,7 +96,7 @@ MergeResult_fastforward_oid__get__(MergeResult *self)
PyGetSetDef MergeResult_getseters[] = { PyGetSetDef MergeResult_getseters[] = {
GETTER(MergeResult, is_uptodate), GETTER(MergeResult, is_uptodate),
GETTER(MergeResult, is_fastforward), GETTER(MergeResult, is_fastforward),
GETTER(MergeResult, fastforward_oid), GETTER(MergeResult, fastforward_id),
{NULL}, {NULL},
}; };

View File

@@ -66,13 +66,13 @@ Note_remove(Note *self, PyObject* args)
} }
PyDoc_STRVAR(Note_oid__doc__, PyDoc_STRVAR(Note_id__doc__,
"Gets the id of the blob containing the note message\n"); "Gets the id of the blob containing the note message\n");
PyObject * PyObject *
Note_oid__get__(Note *self) Note_id__get__(Note *self)
{ {
return git_oid_to_python(git_note_oid(self->note)); return git_oid_to_python(git_note_id(self->note));
} }
@@ -108,7 +108,7 @@ PyMemberDef Note_members[] = {
PyGetSetDef Note_getseters[] = { PyGetSetDef Note_getseters[] = {
GETTER(Note, message), GETTER(Note, message),
GETTER(Note, oid), GETTER(Note, id),
{NULL} {NULL}
}; };

View File

@@ -588,9 +588,9 @@ Repository_merge_base(Repository *self, PyObject *args)
} }
PyDoc_STRVAR(Repository_merge__doc__, PyDoc_STRVAR(Repository_merge__doc__,
"merge(oid) -> MergeResult\n" "merge(id) -> MergeResult\n"
"\n" "\n"
"Merges the given oid and returns the MergeResult.\n" "Merges the given id and returns the MergeResult.\n"
"\n" "\n"
"If the merge is fastforward the MergeResult will contain the new\n" "If the merge is fastforward the MergeResult will contain the new\n"
"fastforward oid.\n" "fastforward oid.\n"
@@ -614,7 +614,7 @@ Repository_merge(Repository *self, PyObject *py_oid)
if (len == 0) if (len == 0)
return NULL; return NULL;
err = git_merge_head_from_oid(&oid_merge_head, self->repo, &oid); err = git_merge_head_from_id(&oid_merge_head, self->repo, &oid);
if (err < 0) if (err < 0)
return Error_set(err); return Error_set(err);

View File

@@ -114,8 +114,8 @@ typedef struct {
PyObject* hunks; PyObject* hunks;
const char * old_file_path; const char * old_file_path;
const char * new_file_path; const char * new_file_path;
char* old_oid; char* old_id;
char* new_oid; char* new_id;
char status; char status;
unsigned similarity; unsigned similarity;
unsigned additions; unsigned additions;

View File

@@ -257,13 +257,13 @@ class DiffTest(utils.BareRepoTestCase):
self.assertEqual(diff.patch, PATCH) self.assertEqual(diff.patch, PATCH)
self.assertEqual(len(diff), len([patch for patch in diff])) self.assertEqual(len(diff), len([patch for patch in diff]))
def test_diff_oids(self): def test_diff_ids(self):
commit_a = self.repo[COMMIT_SHA1_1] commit_a = self.repo[COMMIT_SHA1_1]
commit_b = self.repo[COMMIT_SHA1_2] commit_b = self.repo[COMMIT_SHA1_2]
patch = commit_a.tree.diff_to_tree(commit_b.tree)[0] patch = commit_a.tree.diff_to_tree(commit_b.tree)[0]
self.assertEqual(patch.old_oid, self.assertEqual(patch.old_id,
'7f129fd57e31e935c6d60a0c794efe4e6927664b') '7f129fd57e31e935c6d60a0c794efe4e6927664b')
self.assertEqual(patch.new_oid, self.assertEqual(patch.new_id,
'af431f20fc541ed6d5afede3e2dc7160f6f01f16') 'af431f20fc541ed6d5afede3e2dc7160f6f01f16')
def test_hunk_content(self): def test_hunk_content(self):

View File

@@ -181,13 +181,13 @@ class IndexTest(utils.RepoTestCase):
index = self.repo.index index = self.repo.index
entry = index['hello.txt'] entry = index['hello.txt']
ign_entry = index['.gitignore'] ign_entry = index['.gitignore']
self.assertNotEqual(ign_entry.oid, entry.oid) self.assertNotEqual(ign_entry.id, entry.id)
self.assertNotEqual(entry.mode, pygit2.GIT_FILEMODE_BLOB_EXECUTABLE) self.assertNotEqual(entry.mode, pygit2.GIT_FILEMODE_BLOB_EXECUTABLE)
entry.path = 'foo.txt' entry.path = 'foo.txt'
entry.oid = ign_entry.oid entry.id = ign_entry.id
entry.mode = pygit2.GIT_FILEMODE_BLOB_EXECUTABLE entry.mode = pygit2.GIT_FILEMODE_BLOB_EXECUTABLE
self.assertEqual('foo.txt', entry.path) self.assertEqual('foo.txt', entry.path)
self.assertEqual(ign_entry.oid, entry.oid) self.assertEqual(ign_entry.id, entry.id)
self.assertEqual(pygit2.GIT_FILEMODE_BLOB_EXECUTABLE, entry.mode) self.assertEqual(pygit2.GIT_FILEMODE_BLOB_EXECUTABLE, entry.mode)
def test_write_tree_to(self): def test_write_tree_to(self):
@@ -201,7 +201,7 @@ class IndexEntryTest(utils.RepoTestCase):
def test_create_entry(self): def test_create_entry(self):
index = self.repo.index index = self.repo.index
hello_entry = index['hello.txt'] hello_entry = index['hello.txt']
entry = pygit2.IndexEntry('README.md', hello_entry.oid, hello_entry.mode) entry = pygit2.IndexEntry('README.md', hello_entry.id, hello_entry.mode)
index.add(entry) index.add(entry)
tree_id = index.write_tree() tree_id = index.write_tree()
self.assertEqual('60e769e57ae1d6a2ab75d8d253139e6260e1f912', str(tree_id)) self.assertEqual('60e769e57ae1d6a2ab75d8d253139e6260e1f912', str(tree_id))

View File

@@ -58,7 +58,7 @@ class NotesTest(utils.BareRepoTestCase):
def test_lookup_note(self): def test_lookup_note(self):
annotated_id = self.repo.head.target.hex annotated_id = self.repo.head.target.hex
note = self.repo.lookup_note(annotated_id) note = self.repo.lookup_note(annotated_id)
self.assertEqual(NOTES[0][0], note.oid.hex) self.assertEqual(NOTES[0][0], note.id.hex)
self.assertEqual(NOTES[0][1], note.message) self.assertEqual(NOTES[0][1], note.message)
def test_remove_note(self): def test_remove_note(self):
@@ -70,7 +70,7 @@ class NotesTest(utils.BareRepoTestCase):
def test_iterate_notes(self): def test_iterate_notes(self):
for i, note in enumerate(self.repo.notes()): for i, note in enumerate(self.repo.notes()):
entry = (note.oid.hex, note.message, note.annotated_id) entry = (note.id.hex, note.message, note.annotated_id)
self.assertEqual(NOTES[i], entry) self.assertEqual(NOTES[i], entry)
def test_iterate_non_existing_ref(self): def test_iterate_non_existing_ref(self):

View File

@@ -314,7 +314,7 @@ class RepositoryTest_III(utils.RepoTestCaseForMerging):
merge_result = self.repo.merge(branch_oid) merge_result = self.repo.merge(branch_oid)
self.assertTrue(merge_result.is_uptodate) self.assertTrue(merge_result.is_uptodate)
self.assertFalse(merge_result.is_fastforward) self.assertFalse(merge_result.is_fastforward)
self.assertEqual(None, merge_result.fastforward_oid) self.assertEqual(None, merge_result.fastforward_id)
self.assertEqual({}, self.repo.status()) self.assertEqual({}, self.repo.status())
def test_merge_fastforward(self): def test_merge_fastforward(self):
@@ -324,8 +324,8 @@ class RepositoryTest_III(utils.RepoTestCaseForMerging):
self.assertFalse(merge_result.is_uptodate) self.assertFalse(merge_result.is_uptodate)
self.assertTrue(merge_result.is_fastforward) self.assertTrue(merge_result.is_fastforward)
# Asking twice to assure the reference counting is correct # Asking twice to assure the reference counting is correct
self.assertEqual(branch_head_hex, merge_result.fastforward_oid.hex) self.assertEqual(branch_head_hex, merge_result.fastforward_id.hex)
self.assertEqual(branch_head_hex, merge_result.fastforward_oid.hex) self.assertEqual(branch_head_hex, merge_result.fastforward_id.hex)
self.assertEqual({}, self.repo.status()) self.assertEqual({}, self.repo.status())
def test_merge_no_fastforward_no_conflicts(self): def test_merge_no_fastforward_no_conflicts(self):
@@ -335,8 +335,8 @@ class RepositoryTest_III(utils.RepoTestCaseForMerging):
self.assertFalse(merge_result.is_uptodate) self.assertFalse(merge_result.is_uptodate)
self.assertFalse(merge_result.is_fastforward) self.assertFalse(merge_result.is_fastforward)
# Asking twice to assure the reference counting is correct # Asking twice to assure the reference counting is correct
self.assertEqual(None, merge_result.fastforward_oid) self.assertEqual(None, merge_result.fastforward_id)
self.assertEqual(None, merge_result.fastforward_oid) self.assertEqual(None, merge_result.fastforward_id)
self.assertEqual({'bye.txt': 1}, self.repo.status()) self.assertEqual({'bye.txt': 1}, self.repo.status())
self.assertEqual({'bye.txt': 1}, self.repo.status()) self.assertEqual({'bye.txt': 1}, self.repo.status())
# Checking the index works as expected # Checking the index works as expected
@@ -351,8 +351,8 @@ class RepositoryTest_III(utils.RepoTestCaseForMerging):
self.assertFalse(merge_result.is_uptodate) self.assertFalse(merge_result.is_uptodate)
self.assertFalse(merge_result.is_fastforward) self.assertFalse(merge_result.is_fastforward)
# Asking twice to assure the reference counting is correct # Asking twice to assure the reference counting is correct
self.assertEqual(None, merge_result.fastforward_oid) self.assertEqual(None, merge_result.fastforward_id)
self.assertEqual(None, merge_result.fastforward_oid) self.assertEqual(None, merge_result.fastforward_id)
self.assertEqual({'.gitignore': 132}, self.repo.status()) self.assertEqual({'.gitignore': 132}, self.repo.status())
self.assertEqual({'.gitignore': 132}, self.repo.status()) self.assertEqual({'.gitignore': 132}, self.repo.status())
# Checking the index works as expected # Checking the index works as expected