A “Preparation Branch” is a way to describe branch-like functionality that distributed source control systems offer. In its simplest form, it refers to the ability to prepare for a merge with a remote repository by committing several changes locally first.
Centralized source control systems like Subversion only ever allow you to march forward with changes: if you commit a mistake your only choice is to commit yet another patch, preserving the original flaw forever. On the other hand, Git, Mercurial and Bazaar offer you the same possibility to prepare your branch before sending your changes.
If you have a repository with patches that have been shared with no one else, it is safe to change history. Yes, darcs can change history. This gives you options to pick a workflow that best suits you:
- Unrecord a mistake patch and record another that includes the fix, sending a cleaner history upstream.
- Amend a patch you’ve made with additional changes.
- Continue to work in the legacy way, sharing both your mistake patch and the fix.
The darcs commands to use in a preparation branch are simple and interactive, prompting you to select one or more patches from a list of recent work:
darcs unrecordremoves the record of a patch but leaves the changes in the working directory;
darcs obliteratecompletely removes a patch;
darcs amendadds more changes to an existing patch.
Contrary to Git, Mercurial and Bazaar, Darcs does not have a “rebase” command. However, darcs’ usual process of merging is basically the same thing as rebasing: it rewrites patches into a linear history. (There is also work to make a “destructive” rebase command, see http://bugs.darcs.net/issue938 .)
Darcs also supports Spontaneous Branches, which provide another kind of branch-like functionality, without having to create and merge a formal branch for a small task.
- Forgiveness in Version Control, by Martin Pool
- “darcs gets a reasonably good balance between allowing people to undo mistakes, and protecting them from accidentally losing work.”