Bazaar (Bzr)
Bazaar (bzr) is a distributed version control system focused on ease of use and flexibility. This guide covers basic to advanced operations for managing code repositories.
Installation
macOS
brew install bzr
bzr --version
Linux/Ubuntu
sudo apt-get update
sudo apt-get install bzr
Windows
choco install bazaar
# Or download from https://launchpad.net/bzr/
Initial Setup
Configure User
# Set user identity
bzr whoami "John Doe <john@example.com>"
# View current user
bzr whoami
# Configure editor
export EDITOR=vim
bzr config editor=vim
Basic Repository Operations
Initialize Repository
# Create new repository
bzr init my-project
cd my-project
# Clone existing repository
bzr branch https://launchpad.net/myapp myapp
bzr clone https://launchpad.net/myapp
# Create shared repository
bzr init-repo repo-name
cd repo-name
bzr init branch1
bzr init branch2
Check Status
# Show changes
bzr status
# Show changes with details
bzr status --verbose
# Show file changes
bzr diff
# Show specific file changes
bzr diff filename.txt
# Check who changed what
bzr blame filename.txt
Committing Changes
Add and Commit
# Add new file
bzr add filename.txt
# Add multiple files
bzr add file1.txt file2.txt
# Add all changes
bzr add
# Remove file
bzr remove filename.txt
# Rename file
bzr rename oldname.txt newname.txt
# Move file
bzr move file.txt directory/
# Commit changes
bzr commit -m "Fix login bug"
# Commit specific files
bzr commit file.txt -m "Update config"
# Commit with verbose message
bzr commit -m "Detailed commit message" --verbose
Viewing History
# Show commit log
bzr log
# Show last N commits
bzr log -n 5
bzr log --last 5
# Show commits for file
bzr log filename.txt
# Show commits from author
bzr log --author="John Doe"
# Show with patches
bzr log -p
# Show commits by date
bzr log --revision "2025-03-01..2025-03-31"
# Show specific revision
bzr log -r 42
# Show as graph
bzr log --graph
# Show authors and dates
bzr log --long --show-ids
Branching
Creating Branches
# Create branch from current
bzr branch . ../branch-name
# Create branch at specific path
bzr branch /path/to/repo /path/to/branch
# Create light-weight branch
bzr branch --lightweight
# List branches in repository
bzr branches
# List all branches
bzr branches -r remote://location
Working with Branches
# Switch to branch
cd ../branch-name
# Show parent branch
bzr config parent_location
# Set parent branch
bzr config parent_location = ../main-branch
# Update from parent
bzr update
# Check missing commits
bzr missing
bzr missing --theirs
bzr missing --mine
Merging
Merge Operations
# Merge from branch
bzr merge ../other-branch
# Merge specific revision
bzr merge ../branch -r 42
# Preview merge
bzr merge --preview ../other-branch
# Merge and commit
bzr merge ../other-branch
bzr commit -m "Merge other-branch"
# Abort merge
bzr revert
Resolving Conflicts
# Show conflicts
bzr status
# View conflicted file
cat filename.txt.conflict
# Mark as resolved
bzr resolve filename.txt
# Resolve all
bzr resolve --all
# Take ours
bzr resolve --take-this filename.txt
# Take theirs
bzr resolve --take-other filename.txt
Publishing and Sharing
Push and Pull
# Push to remote
bzr push
# Push to specific location
bzr push sftp://host/path/repo
# Push new branch
bzr push sftp://host/path/repo --create-prefix
# Pull changes
bzr pull
# Pull from specific location
bzr pull sftp://host/path/repo
# Check outgoing changes
bzr outgoing
# Check incoming changes
bzr incoming
# Pull and update
bzr pull && bzr update
Setting Up Remote
# Configure default push location
bzr config push_location = sftp://host/repos/myapp
# Configure default pull location
bzr config parent_location = sftp://host/repos/main
# Create shared repository on server
bzr init-repo sftp://host/repos/myapp
bzr push sftp://host/repos/myapp/branch
# Clone branch locally
bzr branch sftp://host/repos/myapp/branch
Advanced Operations
Rebasing
# Rebase current branch
bzr rebase ../main-branch
# Rebase with conflicts
# ... resolve conflicts ...
bzr rebase --continue
# Abort rebase
bzr rebase --abort
Cherry-picking
# Cherry-pick specific commit
bzr merge ../branch -r 42 --cherry-pick
# Cherry-pick multiple commits
bzr merge ../branch -r 40..45 --cherry-pick
Tagging
# Create tag
bzr tag v1.0.0
# Create tag at specific revision
bzr tag -r 42 v1.0.0
# List tags
bzr tags
# Delete tag
bzr tag -d v1.0.0
# Show tag information
bzr log -r tag:v1.0.0
Shelving Changes
# Shelve current changes
bzr shelve
# Shelve with name
bzr shelve -s "WIP: feature"
# List shelved changes
bzr shelve --list
# Restore shelved changes
bzr unshelve
# Delete shelf
bzr unshelve -d
Undoing Changes
# Revert file to last committed
bzr revert filename.txt
# Revert all changes
bzr revert
# Revert to specific revision
bzr revert -r 40
# Undo last commit (keep changes)
bzr uncommit
# Undo last commit (discard changes)
bzr reset --hard -r -2
# Create commit that reverts change
bzr revert -r 40
bzr commit -m "Revert to revision 40"
Workflow Examples
Feature Branch Workflow
# Create feature branch
bzr branch . ../feature/auth
# Work on feature
cd ../feature/auth
echo "auth code" > auth.py
bzr add auth.py
bzr commit -m "Add authentication"
# Merge to main
cd ../main
bzr merge ../feature/auth
bzr commit -m "Merge feature/auth"
# Clean up
rm -rf ../feature/auth
Release Management
# Create release branch
bzr branch . ../release/1.0
cd ../release/1.0
# Make release commits
bzr commit -m "Bump version to 1.0"
bzr tag v1.0.0
# Merge back to main
cd ../main
bzr merge ../release/1.0
bzr commit -m "Merge release 1.0"
# Continue development
bzr commit -m "Start 1.1 development"
Useful Extensions
Enable Extensions
# In ~/.bazaar/bazaar.conf or project .bzr/branch.conf
[DEFAULT]
auto_update = True
[ALIASES]
ci = commit
co = checkout
Creating Aliases
# Create command aliases
bzr config aliases.ci = commit
bzr config aliases.co = checkout
bzr config aliases.br = branch
bzr config aliases.st = status
Troubleshooting
Common Issues
# Check repository integrity
bzr check
# Verify branch
bzr verify-signatures
# Update repository
bzr upgrade
# Recover from corruption
bzr recover
# Rebuild metadata
bzr reconcile
Resolving Conflicts
# Show all conflicts
bzr conflicts
# Mark manually resolved
bzr resolve --all
# Take specific version
bzr resolve --take-this filename.txt
bzr resolve --take-other filename.txt
# Use merge tool
bzr merge ../branch --merge-type weave
Performance
# Optimize repository
bzr optimize
# Verify performance
bzr check --expensive
# Check disk usage
bzr du
# Clean backup files
bzr clean-logs
Collaboration Tips
Code Review
# Create patch for review
bzr send -o mypatch.patch ../main-branch
# Apply patch
bzr patch < mypatch.patch
bzr commit -m "Applied patch from review"
# Test patch
bzr merge --preview < mypatch.patch
Shared Repository
# Create shared repo
bzr init-repo /shared/repos/project
# Work in shared repo
cd /shared/repos/project
bzr init branch1
bzr init branch2
# Each person works locally
bzr branch /shared/repos/project/branch1 ~/branch1-work
cd ~/branch1-work
bzr commit -m "My changes"
bzr push /shared/repos/project/branch1
Configuration File Example
# ~/.bazaar/bazaar.conf
[DEFAULT]
email = John Doe <john@example.com>
editor = vim
auto_update = True
create_signatures = never
send_strict = True
[ALIASES]
ci = commit
co = checkout
br = branch
st = status
di = diff
lo = log
Resources
Last updated: 2025-03-30