Revision Control With Darcs
OSDC::Israel::2006
Feb 26, 2006
Hi
- I'm going to talk about Darcs
- At the end of this talk you'll either
- Or knowing why you aren't
- (or you have fallen asleep)
Introduction
- Darcs gives any project two things:
- Unlimited undo
- History management
- Revision control system
- David's Advanced Revision Control System
Revision Control Systems
- These tools have been around for centuries
- Well... decades, but that's still a lot
- ... But I like Darcs the most
A project
- Book
- Program
- Website
- ... Anything with files
Project Evolution
- Change your mind about this or that
People working on a project
A project with revision control
Why Darcs?
- Or more directly:
- Why not CVS or SVN?
- SVK/Arch users - keep your mouth shut for a second
Why Darcs?
Why not CVS
Why not SVN
- But still sucks
- Centralized
- Sequential
- No cherry picking
Why not SVK/Arch
- If you know SVK, Arch, etc then you already know most of Darcs
- But stick around, you might like it
Getting started with Darcs
- Darcs has binary packages
- Darcs is written in Haskell
- Compiled by GHC
- Not very common
- But pretty portable
- Audrey's Learning Haskell talk is the next one in this room
Getting started with Darcs
- Create your project directory
- Run darcs init
- This creates _darcs
- Storage data directory
- drwxr-xr-x 7 nothingm nothingm 238 Feb 26 12:12 _darcs
What's new?
- The file is new
- darcs whatsnew --look-for-adds
- whatsnew shows unrecorded changes
Record a change
- darcs record --look-for-adds
- No more unrecorded changes
Change logs
- Some flags:
- --summary (or -s) summarizes the files changed
- --verbose (or -v) shows the actual diffs
- --patches (or -p) lets you filter
Short summary of the basics
- darcs init creates a revision data storage
- darcs whatsnew checks whether there are changes to record
- darcs record records changes into the storage
- darcs changes exposes recorded changes
Sharing changes with others
Getting a repository
- from:
- local path
- http://.../
- host:path (ssh)
- to:
Getting a repository
- darcs get project project_copy
- project_copy is cloned from project
- It has everything in project
- No data loss even if you rm -rf project
- ...except for unrecorded changes
- In Darcs every working directory is a full repository!
Putting a repository
- darcs put /to/
- to can be:
- host:path (ssh)
- a local path
- from is current directory
Local commits
- record does not move patches between repositories
- To share changes we sync respoitories
Syncing Repositories
- darcs pull and darcs push
- Like get and put but incremental
- You can always push or pull to or from anywhere
- Repositories are just sets of applied patches
The Theory of Patches
- David's name for Darcs's core algorithm
- Patches in darcs are commutative:
- They have no chronological order
Patch Dependencies
- A patch contains two parts:
- Metadata (which files have changed and how)
- Textual delta (the actual differences)
- Patch A introduces one line...
- To apply patch B we first need to apply patch A
- That's a Patch Dependency
Patch Dependencies
- Patch dependencies form a Directed Acyclic Graph
- Patches can be applied in any order
- ...as long as they don't depend on each other
Adding Explicit Dependencies
Cherry Picking
- Taking just the patches you want (the yummy cherries)
- ...and their direct dependencies
- Most other systems enforce an order to patches
Sharing Summary
- Every working directory is a fully versioned repository
Sharing Summary
- Theory of Patches allows cherry picking
- First apply it's dependencies
- Patches are otherwise unordered
Send
- What if you want to push to
- darcs send is like darcs push, but through email
Send
- Whenever you send to a repo...
- Darcs reads _prefs/email in that repo
- And send a patch to that email instead
Apply
- darcs apply applies patch emails
- send/apply always go together
Tag
- A patch with no content that depends on all the other patches
Conflict Resolution
- Darcs will refuse to apply a conflicting patch
- See the manual for external merge recipes
Conflict Resolution
- A merge patch depends on two conflicting patches
- And contains a diff that merges them
- The conflicting parts are overridden by the merge
A Darcs Workflow
- darcs-stable - where releases are made
- darcs-unstable - where new stuff is added
- darcs-conflicts - experimental
- Fix bugs anywhere - then move them around
- Mainline, Branch Promotion
- You get both anyway - Simple!
Unrecord
- Removes a patch from history
- But working files remain edited
- darcs record to rerecord it
- DO NOT UNRECORD CHANGES THAT HAVE BEEN SHARED
Obliterate
- Like darcs unrecord; darcs revert
- And completely removes it from history
- Unless you have the patch in another repo
Configuration Files
- prefs/defaults contains default command line options
- email - what to darcs send to
- author - what to darcs record as
- boring - patterns to skip in --look-for-adds
- binaries - patterns to automatically treat as binary
Configuration Layout
- Darcs has a hierarchal configuration
- Command line options override _darcs/prefs
- _darcs/prefs overrides ~/.darcs
What's More?
- Many useful options
- Commands you can easily find (diff, add, rm, mv)
- Automated testing support
Getting help
Thank You