Bazaar Advanced
Advanced Bazaar (bzr) workflows for distributed teams, complex branching strategies, rebasing, cherry-picking, and sophisticated merge handling.
Advanced Branching Strategies
Mainline Development Model
# Central mainline branch
bzr init mainline
cd mainline
# Feature branches from mainline
bzr branch . ../feature/user-auth
bzr branch . ../feature/payments
bzr branch . ../feature/notifications
# Each feature developer works in isolation
cd ../feature/user-auth
# ... make changes ...
bzr commit -m "Implement user authentication"
# Merge feature back to mainline
cd ../mainline
bzr merge ../feature/user-auth
bzr commit -m "Merge user auth feature"
# Continue with other features
bzr merge ../feature/payments
bzr commit -m "Merge payments feature"
Release Branch Model
# Create release branch from main development
bzr branch ../develop ../release/1.0
cd ../release/1.0
# Only bug fixes and version bumps
bzr commit -m "Version 1.0.1 - bugfix"
bzr tag v1.0.1
# Merge fixes back to develop
cd ../develop
bzr merge -r tag:v1.0.1 ../release/1.0
bzr commit -m "Merge release 1.0.1 fixes"
# Continue main development
bzr commit -m "Start 1.1 development"
Integration Branch Pattern
# Main branch (stable)
bzr init main
# Development branch (bleeding edge)
bzr branch . ../develop
# Feature branches from develop
bzr branch ../develop ../feature/experiment
cd ../feature/experiment
# ... experimental changes ...
bzr commit -m "Try new approach"
# If successful, integrate to develop
cd ../develop
bzr merge ../feature/experiment
bzr commit -m "Merge experiment"
# Periodically integrate develop to main
cd ../main
bzr merge -r tag:latest-stable ../develop
bzr commit -m "Merge develop to stable"
bzr tag v-stable
Advanced Merge Strategies
Weave Merge Algorithm
# Use weave merging for text-heavy content
bzr merge ../other-branch --merge-type weave
# Weave is good for:
# - Documentation
# - Configuration files
# - Text-heavy content
Per-File Merge Strategies
# Different strategies for different files
bzr merge ../branch --merge-type directive
# In .bzr/branch/conflicts
# Use custom merge scripts for specific file types
Three-Way Merge
# Standard three-way merge (default)
bzr merge ../branch --merge-type merge3
# Combine with conflict resolution
bzr merge ../branch
# ... resolve conflicts ...
bzr resolve --all
bzr commit -m "Merge resolved"
Rebasing and Linear History
Interactive Rebase
# Rebase branch onto parent
bzr rebase ../main
# Rebase with conflict resolution
bzr rebase ../main
# ... resolve conflicts ...
bzr rebase --continue
# Abort rebase
bzr rebase --abort
# Rebase specific range
bzr rebase -r 40..50 ../main
Squashing Commits
# Multiple commits into one
bzr uncommit -r -3 # Undo last 3 commits
# Changes are preserved in working directory
bzr commit -m "Squashed: feature implementation"
# Or use reset
bzr reset --soft -r -3
bzr commit -m "Combined commits"
Cherry-picking Specific Commits
# Pick single commit
bzr merge ../branch -r 42 --cherry-pick
# Pick range of commits
bzr merge ../branch -r 40..45 --cherry-pick
# Pick non-contiguous commits
bzr merge ../branch -r 42 --cherry-pick
bzr merge ../branch -r 55 --cherry-pick
bzr merge ../branch -r 70 --cherry-pick
bzr commit -m "Cherry-picked specific fixes"
Distributed Team Workflows
Pull Request Workflow
# Developer creates feature branch
bzr branch lp:~dev/project/main ~dev/project/feature
# Make changes and push
cd ~/project/feature
bzr commit -m "Implement feature"
bzr push lp:~dev/project/feature
# Create merge proposal (on Launchpad)
bzr lp-propose-merge ../main
# Reviewer reviews code
bzr branch lp:~dev/project/feature /tmp/review
cd /tmp/review
bzr log -p
# After approval
bzr merge /tmp/review
bzr commit -m "Merge feature (approved by reviewer)"
Patch-based Collaboration
# Generate patch
bzr send -o feature.patch ../main
# Send patch via email
mail -a feature.patch reviewer@example.com < email-body.txt
# Reviewer applies patch
bzr patch < feature.patch
bzr diff # Verify changes
bzr commit -m "Applied patch from contributor"
# For complex changes, send incremental patches
bzr send -o feature-v2.patch ../main
Subteam Integration Model
# Main project
bzr init project-main
# Subteam maintains integration branch
bzr branch project-main team-integration
# Team members work on features
bzr branch team-integration team/feature-1
bzr branch team-integration team/feature-2
# Features merged to team integration
cd team-integration
bzr merge team/feature-1
bzr commit -m "Merge feature 1"
bzr merge team/feature-2
bzr commit -m "Merge feature 2"
# Team integration merged to main
cd project-main
bzr merge team-integration
bzr commit -m "Merge team work"
Complex Merge Scenarios
Handling Conflicting Merges
# Merge with known conflicts
bzr merge ../conflicting-branch
# View conflicts
bzr conflicts
# Resolve using tools
bzr resolve --show-base filename.txt
# Edit to keep changes from both
# Mark as resolved
bzr resolve filename.txt
# Complete merge
bzr commit -m "Merge with manual conflict resolution"
Octopus Merging
# Merge multiple branches at once
bzr merge ../branch1
bzr merge ../branch2
bzr merge ../branch3
bzr commit -m "Octopus merge of features"
Reverting Merges
# Identify problematic merge
bzr log --show-ids | grep "Merge"
# Revert entire merge
bzr revert -r 42
bzr commit -m "Revert problematic merge"
# Or create commit that undoes merge
bzr merge --reverse ../problem-branch
bzr commit -m "Undo merge of problem-branch"
Bisect for Debugging
# Start bisect to find bug
bzr bisect start
# Mark current as bad
bzr bisect bad
# Go to earlier version
bzr bisect good -r 30
# Test each intermediate version
bzr bisect bad # If bug exists
bzr bisect good # If works fine
# Repeat until found
# Bisect will tell you the culprit commit
# Reset bisect state
bzr bisect reset
Stash Advanced Usage
# Shelve with description
bzr shelve -s "WIP: refactor auth system"
# Shelve specific files
bzr shelve filename.txt
# List with details
bzr shelve --list --show-changeset
# Apply specific shelf
bzr shelve -A "WIP: refactor auth system"
# Delete all shelves
bzr shelve -D all
# Peek at shelf without applying
bzr shelve --list -p "shelf-name"
Tagging Strategies
Semantic Versioning Tags
# Tag releases
bzr tag v1.0.0 # Major.Minor.Patch
# Tag release candidates
bzr tag v1.0.0-rc1
bzr tag v1.0.0-rc2
# Tag pre-releases
bzr tag v1.0.0-alpha
bzr tag v1.0.0-beta
# Tag development versions
bzr tag v2.0.0-dev
# Use for releases
bzr log -r tag:v1.0.0
bzr branch -r tag:v1.0.0 release-branch
Milestone Tags
# Mark important commits
bzr tag milestone/api-complete
bzr tag milestone/feature-freeze
bzr tag milestone/rc1-ready
# Filter by pattern
bzr tags | grep "milestone/"
Performance Optimization
Repository Optimization
# Optimize repository structure
bzr optimize
# Optimize specific branch
cd branch
bzr optimize
# Check repository size
bzr du
# Shrink repository
bzr pack
# Rebuild indices
bzr reconcile
Caching Strategies
# Configure caching
bzr config cache_size = 512M
# Use shared repository
bzr init-repo large-project
cd large-project
bzr init branch1
bzr init branch2
# Branches share history
bzr branch branch1 branch1-clone # Fast clone
Migration and Conversion
Converting from Git
# Clone from Git
bzr branch git://github.com/user/repo myrepo
# Or import history
bzr fast-import input.fi
# Configure for Bazaar
cd myrepo
bzr whoami
bzr commit -m "Convert to Bazaar"
Exporting to Git
# Export as fast-export
bzr fast-export . > repo.fi
# Import in Git
cd /tmp/git-repo
git fast-import < repo.fi
Monitoring and Inspection
Detailed Log Analysis
# Show commits with full details
bzr log --show-ids --long --show-branch
# Export log to text
bzr log --long > history.txt
# Analyze changes per author
bzr log -u "John Doe" --long
# Count commits
bzr log | grep "^revision:" | wc -l
# Find large changes
bzr log -p | grep "^+++ " | sort | uniq -c | sort -rn
Blame and Annotate
# See who changed each line
bzr blame filename.txt
# With revision numbers
bzr blame --long filename.txt
# For specific lines
bzr blame filename.txt -r 1..10
Resources
Last updated: 2025-03-30