libgit2/pygit2 — pull request #88 by cholin (2012-05-15 10:13:38+00:00)
Title: added pygit2.utils and tree_insert_node()

According to issue #57 and issue #71 we want to have some stuff implemented in python rather than c.
I think for the beginning it would be nice to have a libgit2.utils module. For that I did some refactorization.
Moreover it adds a ```tree_insert_node``` function which should help to do some tree manipulation.

An example for ```pygit2.utils.tree_insert_node```

```
import time
from pygit2 import Repository, Signature, utils

# lookup head
repo = Repository('testrepo')
head = repo.lookup_reference('HEAD').resolve()
commit = repo[head.oid]
tree = commit.tree

# insert foo.txt in path/to/blob/foo.txt
node_oid = tree['foo.txt'].oid
root_oid = commit.tree.oid
tree_oid = utils.tree_insert_node(repo, root_oid, node_oid, 'path/to/blob/foo.txt')

# commit everything
author = committer = Signature('foo bar', 'foo@bar.de', 120, int(time.time()))
repo.create_commit(
'HEAD',
author,
committer,
'copied foo to path/to/blob/foo.txt',
tree_oid,
[commit.oid]
)
```

I'm open for comments? What do you think?