Branching may be cheap in DVCSs from the technical perspective, but sometimes it’s other factors that make it a pain. For example, the environment setup procedure could be very tedious, or you may be unable to use hardlinks (Windows) and your branches are too large. The bzr-loom plugin comes in handy in these situations. A very simple example follows:
## Install bzr-loom using `bzr branch lp:bzr-loom` in your .bazaar/plugins/
# Create a new repository
$ bzr init bzr
$ cd bzr
# Create a new file
$ echo initial > first
# Check it in
$ bzr add first
added first
$ bzr ci -m "initial"
Committing to: /home/tro/temp/bzr/
added first
Committed revision 1.
$ cat first
initial
# Set the branch nick specifically. This is the initial development "thread".
$ bzr nick initial
# Create a loom. From this point on, you have to have the plugin to interact with this repo directly
$ bzr loomify
# Only one thread exists right now
$ bzr show-loom
=>initial
# Add a new thread (acts as another branch inside the current directory)
$ bzr create-thread feature-1
# Add a new file
$ echo "second file" > second
$ bzr add second
added second
$ bzr ci -m "+second"
Committing to: /home/tro/temp/bzr/
added second
Committed revision 2.
# Switch back to the initial dev thread. Note how "second" disappears, since it is in another thread.
$ bzr down-thread
All changes applied successfully.
Moved to thread 'initial'.
$ bzr show-loom
feature-1
=>initial
$ ls
first
# Switch to feature-1
$ bzr up-thread # this would do a merge, if any new changes were made in "initial"
$ ls
first second
# Edit first
$ echo "edit in feature-1 thread" >> first
$ cat first
initial
edit in feature-1 thread
$ bzr ci -m "useless text meant to illustrate merging between threads"
# At this point pretend that we are satisfied with the changes in "feature-1"
# and want to merge them into "initial". Go there.
$ bzr down-thread
$ ls
first
$ bzr merge -r thread:feature-1 .
+N second
M first
All changes applied successfully.
# Merged changes from feature-1 to initial
$ ls
first second
$ cat first
initial
edit in feature-1 thread
$ cat second
second file
This gives you a limited git-like ability to spawn off new branches in the current directory.