bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.211.2
by James Westby
Make it more like a real project. |
1 |
This is the python-git project. |
2 |
||
3 |
It aims to give an interface to git repos that doesn't call out to git |
|
4 |
directly. It is probably going to be implemented in pure python.
|
|
5 |
||
6 |
Currently can read blobs, trees and commits from the files. It reads both
|
|
7 |
legacy and new headers. However it is untested for anything but the simple
|
|
8 |
case.
|
|
9 |
||
10 |
Can also understand a little about the repository format.
|
|
11 |
||
12 |
The testsuite uses the nosetests program from Turbogears, as I got annoyed
|
|
13 |
trying to set up unittest.
|
|
14 |
||
15 |
Open up a repo by passing it the path to the .git dir. You can then ask for
|
|
16 |
HEAD with repo.head() or a ref with repo.ref(name). Both return the SHA id
|
|
17 |
they currently point to. You can then grab this object with
|
|
18 |
repo.get_object(sha).
|
|
19 |
||
20 |
For the actual objects the ShaFile.from_file(filename) will return the object
|
|
21 |
stored in the file whatever it is. To ensure you get the correct type then
|
|
22 |
call {Blob,Tree,Commit}.from_file(filename). I will add repo methods to do
|
|
23 |
this for you with file lookup soon.
|
|
24 |
||
25 |
There is also support for creating blobs. Blob.from_string(string) will create
|
|
26 |
a blob object from the string. You can then call blob.sha() to get the sha
|
|
27 |
object for this blob, and hexdigest() on that will get its ID. There is
|
|
28 |
currently no method that allows you to write it out though.
|
|
29 |
||
30 |
Everything is currently done with assertions, where much of it should probably
|
|
31 |
be exceptions. This was merely done for expediency. If you hit an assertion,
|
|
32 |
it either means you have done something wrong, there is corruption, or
|
|
33 |
you are trying an unsupported operation.
|
|
34 |
||
35 |
If you have any comments or questions you can contact me at
|
|
36 |
jw+debian@jameswestby.net
|
|
37 |
||
38 |
James Westby
|
|
39 |