diff --git a/docs/tutorial/index.txt b/docs/tutorial/index.txt index 79e914a3..7d085a1f 100644 --- a/docs/tutorial/index.txt +++ b/docs/tutorial/index.txt @@ -1,17 +1,18 @@ .. _tutorial: ======== Tutorial ======== .. toctree:: :maxdepth: 2 introduction file-format repo object-store remote tag + porcelain conclusion diff --git a/docs/tutorial/introduction.txt b/docs/tutorial/introduction.txt index 184134d3..9fee9d86 100644 --- a/docs/tutorial/introduction.txt +++ b/docs/tutorial/introduction.txt @@ -1,16 +1,20 @@ .. _tutorial-introduction: Introduction ============ Like Git itself, Dulwich consists of two main layers; the so-called plumbing and the porcelain. The plumbing is the lower layer and it deals with the Git object database and the nitty gritty internals. The porcelain is roughly what you would expect to be exposed to as a user of the ``git`` command-like tool. -Dulwich has a fairly complete plumbing implementation, and only a somewhat -smaller porcelain implementation. The porcelain code lives in -``dulwich.porcelain``. For the large part, this tutorial introduces you to the -internal concepts of Git and the main plumbing parts of Dulwich. +Dulwich has a fairly complete plumbing implementation, and a more recently +added porcelain implementation. The porcelain code lives in +``dulwich.porcelain``. + + +For the large part, this tutorial introduces you to the internal concepts of +Git and the main plumbing parts of Dulwich. The last chapter covers +the porcelain. diff --git a/docs/tutorial/porcelain.txt b/docs/tutorial/porcelain.txt new file mode 100644 index 00000000..74d7048d --- /dev/null +++ b/docs/tutorial/porcelain.txt @@ -0,0 +1,34 @@ +Porcelain +========= + +The ``porcelain'' is the higher level interface, built on top of the lower +level implementation covered in previous chapters of this tutorial. The +``dulwich.porcelain'' module in Dulwich is aimed to closely resemble +the Git command-line API that you are familiar with. + +Basic concepts +-------------- +The porcelain operations are implemented as top-level functions in the +``dulwich.porcelain'' module. Most arguments can either be strings or +more complex Dulwich objects; e.g. a repository argument will either take +a string with a path to the repository or an instance of a ``Repo`` object. + +Initializing a new repository +----------------------------- + + >>> from dulwich import porcelain + + >>> repo = porcelain.init("myrepo") + +Clone a repository +------------------ + + >>> porcelain.clone("git://github.com/jelmer/dulwich", "dulwich-clone") + +Commit changes +-------------- + + >>> r = porcelain.init("testrepo") + >>> open("testrepo/testfile", "w").write("data") + >>> porcelain.add(r, "testrepo/testfile") + >>> porcelain.commit(r, "A sample commit")