Posts tagged 'porcelain'

Porcelain in Dulwich

porcelain” is the term that is usually used in the Git world to refer to the user-facing parts. This is opposed to the lower layers: the plumbing.

For a long time, I have resisted the idea of including a porcelain layer in Dulwich. The main reason for this is that I don’t consider Dulwich a full reimplementation of Git in Python. Rather, it’s a library that Python tools can use to interact with local or remote Git repositories, without any extra dependencies.

dulwich has always shipped a ‘dulwich’ binary, but that’s never been more than a basic test tool - never a proper tool for end users. It was a mistake to install it by default.

I don’t think there’s a point in providing a dulwich command-line tool that has the same behaviour as the C Git binary. It would just be slower and less mature. I haven’t come across any situation where it didn’t make sense to just directly use the plumbing.

However, Python programmers using Dulwich seem to think of Git operations in terms of porcelain rather than plumbing. Several convenience wrappers for Dulwich have sprung up, but none of them is very complete. So rather than relying on external modules, I’ve added a “porcelain” module to Dulwich in the porcelain branch, which provides a porcelain-like Python API for Git.

At the moment, it just implements a handful of commands but that should improve over the next few releases:

from dulwich import porcelain

r = porcelain.init("/path/to/repo")
porcelain.commit(r, "Create a commit")
porcelain.log(r)

comments.