Subversion vs. Mercurial
• Distributed repositories
• Branches are basically
clones inside the same
repository
• Non-linear history
• Revision numbers are
local
• Commits are offline
• Moving and renaming
is tracked
• Central repository
• Branches are copies
inside same directory
structure
• Global linear history
• Revisions numbers are
sequential and global
• Commits are online
• Moving and renaming
is a combination of
delete/add
Slide 3
Slide 3 text
Subversion workflow
• Check out working copy
o
• Make changes
o ...
o
• Commit changes
o "
• Update copy
o
Slide 4
Slide 4 text
Mercurial workflow
• Clone a repository
o
• Work, slave!
o ...
o " "
• Pull changes
o
o (if pull creates multiple heads)
• Push changes
o
Slide 5
Slide 5 text
Mercurial
• Commits are always local
• You can push multiple commits at a time
• Mercurial blocks a push where it would create
multiple heads in the remote
o In this case, pull changes, update, merge, commit and push
Slide 6
Slide 6 text
Working with repositories
organization/repo
user1/repo user2/repo user3/repo
user1-local/repo
pull
request
pull/push
pull pull
pull
Slide 7
Slide 7 text
History in Mercurial
head/
tip
Slide 8
Slide 8 text
History in Mercurial
head/
tip
head
Slide 9
Slide 9 text
History in Mercurial
–
head/
tip
Slide 10
Slide 10 text
Branches in Mercurial
• Repositories can be treated as branches
• When pulling, changes commited are added as a
nameless branch
• You can switch to a branch by using
• Merging and commiting preserves current branch
• To push a non-existant branch to remote, use
Slide 11
Slide 11 text
Pushing changes
• Always pull and update before pushing
o –
o hg merge (if two heads are created)
o
o
• Don‘t push to main repository directly!
Use Pull Requests.
Slide 12
Slide 12 text
Sharing changes offline
• You can run a local repository server to share
changes offline (via )
o
• Enables users to pull changes, but cannot push
Slide 13
Slide 13 text
Setting up your
environment
• Create SSH key for GitHub:
o
o – –
• create key named
o
• Copy the key to GitHub
• Set up SSH key mapping
o
•
Slide 14
Slide 14 text
Set up Mercurial
•
•
•
o
–
• Fork the base repository!
Slide 15
Slide 15 text
Check out source
•
•
•
o
Slide 16
Slide 16 text
Incoming and outgoing
changes
• To preview the incoming changes without pulling:
o
• To preview outgoing changes without pushing:
o
Slide 17
Slide 17 text
Working with GitHub
• Pull changes from base repository and update
o
• Create local changes
o
• Commit
o
• Verify outgoing changes and push
o
o
• If you‘re ready to push to base repository, create a pull
request