Quilt, a patch management system (how to survive with many patches)
Quilt is a nice tool to manage series of patches, and is particularly adapted to subversion (not very useful for git, the concept of patch series is integrated). It can manage dependant patches, edition, updating patches for a code change, etc.
Start by telling quilt where to store patches:
$ export QUILT_PATCHES=debian/patches
Quilt will create the directory automatically when creating the first patch.
Now, suppose we want to create a new patch, called my_nice_patch
:
$ quilt new my_nice_patch
Patch my_nice_patch is now on top
\On top\ ? quilt manages patches as a stack, so you will have to push patches to apply them, and pop to deapply.Now that we have a patch name, we have to mark the files we will modify in this patch:
$ quilt add reports.py gather.py
File reports.py added to patch my_nice_patch
File gather.py added to patch my_nice_patch
So far so good. Three commands, and we have done nothing :) Files can be modified using your favorite editor (subliminal hint: vim), as usual. At any moment, you can get the diff between your modifications and the unpatched files:
quilt diff
will print a standard diff.
At this point, you have finished your patch. If you look at the debian/patches directory, you’ll see .. nothing ! That’s because a patch has to be “refreshed” to be written to disk.
$ quilt refreshRefreshed patch my_nice_patch
The patch has been written to disk:
$ ls debian/patches/
my_nice_patch
series
The “series” files is an index of the patches, the other files are
the patches. quilt uses the standard “diff” format, so patch can be
used as usual (using diff -p1
).
To apply all patches:
quilt push -a
To deapply all patches:
quilt pop -a
So what is nice with quilt ? It handles gracefully merges, updates, etc. Suppose your patch was done for version x of the sources, and you update the sources. You can reapply patches using the same commands:
$ quilt push my_nice_patch
Applying patch my_nice_patch
patching file gather.py
patching file reports.py
Hunk #1 succeeded at 145 with fuzz 1 (offset 38 lines).
Now at patch my_nice_patch
Ok, the patch applied with some fuzz, but correctly. How do I update my patch for the new sources ? Well, as usual:
$ quilt refresh
Refreshed patch my_nice_patch
It wasn’t hard ?
This is the end of this introduction to quilt, which can do much more advanced things than this simple example ! See the documentation for more.
Links:
- Introduction to quilt (pdf)
- Installation:
apt-get install quilt