PreparationBranches

Preparation Branches

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.

However, other source control systems only ever allow you to march forward with changes: if you commit a mistake -- even if it is never shared -- your only choice is to commit yet another patch, preserving the original flaw forever. SVK, which adds distributed functionality to Subversion, has this weakness.

Darcs allows repairing mistakes before code is shared

Darcs recognizes that your preparation branch is a special phase in the code's life cycle. Since the code has 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 unrecord removes the record of a patch but leaves the changes in the working directory;
  • darcs obliterate completely removes a patch;
  • darcs amend adds more changes to an existing patch.

Providing tools to work with your preparation branch is just one of the innovative features of darcs. Darcs also supports [wiki:SpontaneousBranches Spontaneous Branches], which provide another kind of branch-like functionality, without having to create and merge a formal branch for a small task.