SlideShare ist ein Scribd-Unternehmen logo
1 von 74
Mercurial
Distributed Source Control
Presented by David Stockton for
Front Range PHP User Group
April 28, 2010
“If debugging is the process
of removing bugs, then
programming must be the
process of putting them in.”
	 	 	 - Anonymous
Source Control in a Nutshell
 A great way to avoid catastrophic mistakes with your
 code
 Essential - If your code is more than a few lines long
 and you’re not using source control, you must not think
 very highly of your work.
 If you’re not using source control, start now. Even CVS
 is better than no source control. (Not sure about VSS
 though)
Source Control in a Nutshell
 If you are working with a team (read, one or more other
 people) source control is essential
 If you’re working by yourself and you’ve ever made a
 mistake, source control is essential
 If you ever wished you could undo something you just
 did, source control is essential
 If you need to maintain different versions of the same
 code, source control is essential.
I could go on, but...
I could go on, but...


 The bottom line is...
I could go on, but...


 The bottom line is...

 Source control is absolutely
 essential!
Questions?



Questions about source control in general?
Goals of Source Control

Keep your source code safe
Allow you to look at different versions of your code
Allow multiple developers to work simultaneously
Allow multiple “branches” of code to be worked on at
the same time
Common/Popular Source
Control Tools
CVS
SVN (Subversion)
ClearCase
Perforce
Microsoft Visual SourceSafe
Git
Mercurial
Common/Popular Source
Control Tools
BitKeeper
Telelogic Synergy
Visual Studio Team System
StarTeam
RCS
Tons of others...
Types of Source Control


Client Server Model (CVS, SVN, etc)
Distributed (Git, Mercurial)
Mercurial


 Distributed Version Control System
 Works the way you want it instead of forcing you to use
 it in a certain way
 Used by lots of big projects
Who uses Mercurial?
Adium
Audacious
BitBucket
Growl
Linux HA
LinuxTV
Who uses Mercurial?
Mozilla
Netbeans
Mutt
OpenOffice
OpenJDK
OpenSolaris
How does it work?


Probably not the way you’d think if you’ve used CVS or
SVN or other client server VCS
(Version Control System)
How it’s different
 No central server
   ... or at least not one that’s required
 Works on changesets, not file or repository versions
 Changesets allow merges (shudder) to be simple
   This is a good thing since you’ll be merging a lot
   Learn to not be afraid of the merge
What else?

Doing a checkout gives you a full copy of the repository
  Including all changes, etc
Lose a server?
  Just clone another copy of the repository
What can you do with it?

Pretty much anything
Clone a repository to try out some experimental code
  If it works, keep it
  If not, delete it, no harm done
    And no evidence of your failed attempt
What can you do with it?

Work on a plane (and still check in code)
Collaborate with a colleague in a coffee shop
Pick and choose what you want in your repository
Push, pull and clone from other repositories
Make your VCS work how
you do!
Work on the road
Work from home
Work from work
Work from a plane
Work from a train
Work in an automobile (if you’re not driving)
#1 Awesome Thing


Branches are easy
... But they’re pretty easy in CVS and SVN too
Branches
If you’re working on Feature A and I am working on
Feature B, we’ve essentially branched
Two or more people working on code based on the
same thing creates branches
Named branches
Unnamed branches
Branches by cloning
#2 Awesome Thing

Branches being easy is great, but only if...
Merges are super easy!
Most merges handled automatically
Merge conflicts can be handled by a tool of your choice
  I like kdiff3
#3 Awesome Thing


No network? No problem
Work from anywhere
Collaborate with a colleague in the middle of nowhere
Installation
 Mercurial is cross platform with excellent support on
 Windows, Linux and Mac
 http://mercurial.selenic.com/
 Download binary for Windows or Mac
 ... or
   apt-get install mercurial
   yum install mercurial
   ermerge mercurial
   pkg install SUNWmercurial
Create a new Repository
What’d that do?
You now have a working
repository
If you don’t do command line there are other ways
IDE Integration - Eclipse, NetBeans, IntelliJ, Emacs,
Vim, TextMate, Visual Studio
Windows integration with TortoiseHg
Build/Management tools with Hg support:
CruiseControl, JIRA, Trac, Maven, Redmine, Hudson,
ant, etc
Add some code

Use ‘hg add’ to tell Mercurial about the files you want it
to track
Use ‘hg commit’ to tell Mercurial to check in code
  hg ci
  hg com
Adding and Committing
Look at the repository
Look at the repository
Make some more changes
Easy peasy...
Enter developer #2
Developer 2 Commits
What does that commit look
like?
Pretty much the same
Why?
Luke Skywalker
has his own
repository
How can I get Luke’s
Change?
Use ‘hg push’ from Luke’s instance
Use ‘hg pull’ on my instance to Luke’s instance
What’d that do?
What does it do to me?
Where are the changes?
Pushes do not
affect the working
copy
Why?
Updating the workspace could make me lose my work
How to see those changes?


Use ‘hg up’
Update your own
workspace
Let’s mix it up


 Dave makes a change to cookie to specify flour
 amount
 Luke makes a change to cookie to add eggs
A matter of timing...
Dave commits changes
Luke commits changes
But then...



 Don’t use -f to force... Don’t do it...
Let’s merge
Quick recap

First check-in goes in
Second check-in based on same code needs merge
‘hg pull’ + ‘hg merge’ took a fraction of a second
Merge was correct
Luke now needs to commit the merge and push back
to Dave’s server
Merge Check-in
And it now looks like...
Still too easy...

 Let’s try a merge conflict...
 Dave needs more flour in the recipe
   Also, Dave hasn’t updated his workspace with the
   merge results
 Luke wants to use cake flour
Merge conflict in the making
Now the fun part
Luke uses the force and does a check in and push
before Dave does a check-in
Here comes trouble...
 Dave tries to commit




 ... And it works ...
But... it created a new head
To get Luke’s changes...
Merge 2 heads into 1
All that junk is kdiff3 launching. I should fix that...
Merge in kdiff3
 Notice that the eggs part was automatically resolved
Merge completed
Commit the merge
What’d that do?
Crazy branch/merges

The example to the right was done with
just 5 users but I was purposely trying
to make lots of weird branch merge
situations occur.
Command overview
hg clone - clone a repository
hg merge - merge changes together
hg add - tell Mercurial to start caring about some files
hg commit - commit a new changeset
hg push - send your changesets to another server
hg pull - retrieve changesets from another server
Command overview cont...
hg update - Update your local workspace with the stuff
from hg pull
hg annotate - show which changeset is responsible for
each line in a file
hg diff - show the differences between files in your
workspace and the committed file
hg export - dump the header and diffs for one or more
changesets
Command overview cont...

hg forget - Forget the specified files (remove from
repository, not from workspace) when you commit
hg log - show revision history
hg remove - delete file and remove from repository
when you commit
hg serve - simple http server to show the repository
(useful for coffee shop working)
hg addremove - add all new files, remove deleted files

hg backout - reverse effect of earlier changeset

hg bisect - search changesets (DEMO)

hg branch - set or show branch names

hg branches - list all branches

hg copy - mark file as copied for next commit (DEMO)

hg heads - show repository or branch heads
hg help - Where I’m getting this list of commands

hg identify - identify the working copy

hg incoming - show new changesets in source

hg init - create a new repository

hg outgoing - show changesets not in destination

hg parents - show parents of working directory or
revision
Command overview cont...
hg status - Show what’s going to happen when you
commit
hg summary - Summarize state of working directory

hg paths - show aliases for remote repositories

hg rename - rename a file (same as hg copy + hg
remove) (DEMO)

hg tag - tag a revision

hg tags - show tags in repository
Holy crap...


 That wasn’t even all the commands
 Or all the coolness
As time permits...

 hg bisect demo
 hg copy demo
 hg rename demo
 hg mq - Patching, orthogonal mutable changesets
Other sweet awesomeness


Hooks
Attic
ACL
Excellent Resources

Quick and easy overview:
http://hginit.com - Joel Spolsky’s explanation of
Mercurial
Mercurial: The Definitive Guide
Available online at http://hgbook.red-bean.com/read/
Or buy from Amazon.com or O’Reilly Media
Questions?

Weitere ähnliche Inhalte

Was ist angesagt?

Quick Introduction to git
Quick Introduction to gitQuick Introduction to git
Quick Introduction to gitJoel Krebs
 
Version Control History and Git Basics
Version Control History and Git BasicsVersion Control History and Git Basics
Version Control History and Git BasicsSreedath N S
 
Gitlab flow solo
Gitlab flow soloGitlab flow solo
Gitlab flow soloviniciusban
 
Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for ArtistsDavid Newbury
 
A Practical Introduction to git
A Practical Introduction to gitA Practical Introduction to git
A Practical Introduction to gitEmanuele Olivetti
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hubVenkat Malladi
 
Git and GitHub for Documentation
Git and GitHub for DocumentationGit and GitHub for Documentation
Git and GitHub for DocumentationAnne Gentle
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Gitatishgoswami
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git TutorialSage Sharp
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to GitLukas Fittl
 
Virtualization, Containers, Docker and scalable container management services
Virtualization, Containers, Docker and scalable container management servicesVirtualization, Containers, Docker and scalable container management services
Virtualization, Containers, Docker and scalable container management servicesabhishek chawla
 

Was ist angesagt? (20)

Quick Introduction to git
Quick Introduction to gitQuick Introduction to git
Quick Introduction to git
 
Version Control History and Git Basics
Version Control History and Git BasicsVersion Control History and Git Basics
Version Control History and Git Basics
 
Gitlab flow solo
Gitlab flow soloGitlab flow solo
Gitlab flow solo
 
Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for Artists
 
GitHub
GitHubGitHub
GitHub
 
A Practical Introduction to git
A Practical Introduction to gitA Practical Introduction to git
A Practical Introduction to git
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hub
 
Presentacion git
Presentacion gitPresentacion git
Presentacion git
 
Git and GitHub for Documentation
Git and GitHub for DocumentationGit and GitHub for Documentation
Git and GitHub for Documentation
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Git basics
Git basicsGit basics
Git basics
 
Git for beginners
Git for beginnersGit for beginners
Git for beginners
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
 
Migrating To GitHub
Migrating To GitHub  Migrating To GitHub
Migrating To GitHub
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Git vs svn
Git vs svnGit vs svn
Git vs svn
 
Svn Basic Tutorial
Svn Basic TutorialSvn Basic Tutorial
Svn Basic Tutorial
 
Git basic
Git basicGit basic
Git basic
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
 
Virtualization, Containers, Docker and scalable container management services
Virtualization, Containers, Docker and scalable container management servicesVirtualization, Containers, Docker and scalable container management services
Virtualization, Containers, Docker and scalable container management services
 

Andere mochten auch

Distributed Version Control (DVCS) With Mercurial
Distributed Version Control (DVCS) With MercurialDistributed Version Control (DVCS) With Mercurial
Distributed Version Control (DVCS) With MercurialTed Naleid
 
Mercurial DVCS
Mercurial DVCSMercurial DVCS
Mercurial DVCSHosam Aly
 
Mercurial: Beginners (v1)
Mercurial: Beginners (v1)Mercurial: Beginners (v1)
Mercurial: Beginners (v1)Michael Wales
 
4. hg init – a mercurial tutorial by tortoise hg merging
4. hg init – a mercurial tutorial by tortoise hg   merging4. hg init – a mercurial tutorial by tortoise hg   merging
4. hg init – a mercurial tutorial by tortoise hg mergingMickey SJ Lee
 
5. hg init – a mercurial tutorial by tortoise hg repository architecture
5. hg init – a mercurial tutorial by tortoise hg   repository architecture5. hg init – a mercurial tutorial by tortoise hg   repository architecture
5. hg init – a mercurial tutorial by tortoise hg repository architectureMickey SJ Lee
 
Mercurial intro
Mercurial introMercurial intro
Mercurial introRealNitro
 
Mercurial DVCS presentation to DevJam 11/4/2009
Mercurial DVCS presentation to DevJam 11/4/2009Mercurial DVCS presentation to DevJam 11/4/2009
Mercurial DVCS presentation to DevJam 11/4/2009Ted Naleid
 
3. hg init – a mercurial tutorial by tortoies hg fixing goofs
3. hg init – a mercurial tutorial by tortoies hg   fixing goofs3. hg init – a mercurial tutorial by tortoies hg   fixing goofs
3. hg init – a mercurial tutorial by tortoies hg fixing goofsMickey SJ Lee
 
2. hg init – a mercurial tutorial by tortoies hg setting up for a team
2. hg init – a mercurial tutorial by tortoies hg   setting up for a team2. hg init – a mercurial tutorial by tortoies hg   setting up for a team
2. hg init – a mercurial tutorial by tortoies hg setting up for a teamMickey SJ Lee
 

Andere mochten auch (12)

Mercurial
MercurialMercurial
Mercurial
 
Mercurial
MercurialMercurial
Mercurial
 
Distributed Version Control (DVCS) With Mercurial
Distributed Version Control (DVCS) With MercurialDistributed Version Control (DVCS) With Mercurial
Distributed Version Control (DVCS) With Mercurial
 
Mercurial DVCS
Mercurial DVCSMercurial DVCS
Mercurial DVCS
 
Mercurial: Beginners (v1)
Mercurial: Beginners (v1)Mercurial: Beginners (v1)
Mercurial: Beginners (v1)
 
4. hg init – a mercurial tutorial by tortoise hg merging
4. hg init – a mercurial tutorial by tortoise hg   merging4. hg init – a mercurial tutorial by tortoise hg   merging
4. hg init – a mercurial tutorial by tortoise hg merging
 
5. hg init – a mercurial tutorial by tortoise hg repository architecture
5. hg init – a mercurial tutorial by tortoise hg   repository architecture5. hg init – a mercurial tutorial by tortoise hg   repository architecture
5. hg init – a mercurial tutorial by tortoise hg repository architecture
 
Mercurial intro
Mercurial introMercurial intro
Mercurial intro
 
The Mercurial SCM
The Mercurial SCMThe Mercurial SCM
The Mercurial SCM
 
Mercurial DVCS presentation to DevJam 11/4/2009
Mercurial DVCS presentation to DevJam 11/4/2009Mercurial DVCS presentation to DevJam 11/4/2009
Mercurial DVCS presentation to DevJam 11/4/2009
 
3. hg init – a mercurial tutorial by tortoies hg fixing goofs
3. hg init – a mercurial tutorial by tortoies hg   fixing goofs3. hg init – a mercurial tutorial by tortoies hg   fixing goofs
3. hg init – a mercurial tutorial by tortoies hg fixing goofs
 
2. hg init – a mercurial tutorial by tortoies hg setting up for a team
2. hg init – a mercurial tutorial by tortoies hg   setting up for a team2. hg init – a mercurial tutorial by tortoies hg   setting up for a team
2. hg init – a mercurial tutorial by tortoies hg setting up for a team
 

Ähnlich wie Mercurial Distributed Version Control

Cloudops fundamentals management, tdd, test driven design, continuous integra...
Cloudops fundamentals management, tdd, test driven design, continuous integra...Cloudops fundamentals management, tdd, test driven design, continuous integra...
Cloudops fundamentals management, tdd, test driven design, continuous integra...Bret Piatt
 
Devops interview questions 2 www.bigclasses.com
Devops interview questions  2  www.bigclasses.comDevops interview questions  2  www.bigclasses.com
Devops interview questions 2 www.bigclasses.combigclasses.com
 
No Hugging, No Learning
No Hugging, No LearningNo Hugging, No Learning
No Hugging, No LearningOlaf Alders
 
Cfgmgmt Challenges aren't technical anymore
Cfgmgmt Challenges aren't technical anymoreCfgmgmt Challenges aren't technical anymore
Cfgmgmt Challenges aren't technical anymoreJulien Pivotto
 
Continuous Integration: How I stopped guessing if that merge was bad
Continuous Integration: How I stopped guessing if that merge was badContinuous Integration: How I stopped guessing if that merge was bad
Continuous Integration: How I stopped guessing if that merge was badJoe Ferguson
 
Source Code Management Slides
Source Code Management SlidesSource Code Management Slides
Source Code Management Slidesdaschuck
 
WordCamp Belfast DevOps for Beginners
WordCamp Belfast DevOps for BeginnersWordCamp Belfast DevOps for Beginners
WordCamp Belfast DevOps for BeginnersStewart Ritchie
 
Random Ruby Tips - Ruby Meetup 27 Jun 2018
Random Ruby Tips - Ruby Meetup 27 Jun 2018Random Ruby Tips - Ruby Meetup 27 Jun 2018
Random Ruby Tips - Ruby Meetup 27 Jun 2018Kenneth Teh
 
Jbossworld Presentation
Jbossworld PresentationJbossworld Presentation
Jbossworld PresentationDan Hinojosa
 
Front-End Modernization for Mortals
Front-End Modernization for MortalsFront-End Modernization for Mortals
Front-End Modernization for Mortalscgack
 
Front end-modernization
Front end-modernizationFront end-modernization
Front end-modernizationdevObjective
 
PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy...
PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy...PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy...
PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy...Andrey Karpov
 
Migraine Drupal - syncing your staging and live sites
Migraine Drupal - syncing your staging and live sitesMigraine Drupal - syncing your staging and live sites
Migraine Drupal - syncing your staging and live sitesdrupalindia
 
Austin Web Architecture
Austin Web ArchitectureAustin Web Architecture
Austin Web Architecturejoaquincasares
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Fabrice Bernhard
 
Future proofing design work with Web components
Future proofing design work with Web componentsFuture proofing design work with Web components
Future proofing design work with Web componentsbtopro
 
Enhance your Agility with DevOps
Enhance your Agility with DevOpsEnhance your Agility with DevOps
Enhance your Agility with DevOpsEdureka!
 

Ähnlich wie Mercurial Distributed Version Control (20)

Cloudops fundamentals management, tdd, test driven design, continuous integra...
Cloudops fundamentals management, tdd, test driven design, continuous integra...Cloudops fundamentals management, tdd, test driven design, continuous integra...
Cloudops fundamentals management, tdd, test driven design, continuous integra...
 
Devops interview questions 2 www.bigclasses.com
Devops interview questions  2  www.bigclasses.comDevops interview questions  2  www.bigclasses.com
Devops interview questions 2 www.bigclasses.com
 
Git Makes Me Angry Inside
Git Makes Me Angry InsideGit Makes Me Angry Inside
Git Makes Me Angry Inside
 
Power Of Zero
Power Of ZeroPower Of Zero
Power Of Zero
 
No Hugging, No Learning
No Hugging, No LearningNo Hugging, No Learning
No Hugging, No Learning
 
Cfgmgmt Challenges aren't technical anymore
Cfgmgmt Challenges aren't technical anymoreCfgmgmt Challenges aren't technical anymore
Cfgmgmt Challenges aren't technical anymore
 
Continuous Integration: How I stopped guessing if that merge was bad
Continuous Integration: How I stopped guessing if that merge was badContinuous Integration: How I stopped guessing if that merge was bad
Continuous Integration: How I stopped guessing if that merge was bad
 
Source Code Management Slides
Source Code Management SlidesSource Code Management Slides
Source Code Management Slides
 
WordCamp Belfast DevOps for Beginners
WordCamp Belfast DevOps for BeginnersWordCamp Belfast DevOps for Beginners
WordCamp Belfast DevOps for Beginners
 
Random Ruby Tips - Ruby Meetup 27 Jun 2018
Random Ruby Tips - Ruby Meetup 27 Jun 2018Random Ruby Tips - Ruby Meetup 27 Jun 2018
Random Ruby Tips - Ruby Meetup 27 Jun 2018
 
Jbossworld Presentation
Jbossworld PresentationJbossworld Presentation
Jbossworld Presentation
 
Front-End Modernization for Mortals
Front-End Modernization for MortalsFront-End Modernization for Mortals
Front-End Modernization for Mortals
 
Front end-modernization
Front end-modernizationFront end-modernization
Front end-modernization
 
Front end-modernization
Front end-modernizationFront end-modernization
Front end-modernization
 
PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy...
PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy...PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy...
PVS-Studio Now Supports Any Build System under Windows and Any Compiler. Easy...
 
Migraine Drupal - syncing your staging and live sites
Migraine Drupal - syncing your staging and live sitesMigraine Drupal - syncing your staging and live sites
Migraine Drupal - syncing your staging and live sites
 
Austin Web Architecture
Austin Web ArchitectureAustin Web Architecture
Austin Web Architecture
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
 
Future proofing design work with Web components
Future proofing design work with Web componentsFuture proofing design work with Web components
Future proofing design work with Web components
 
Enhance your Agility with DevOps
Enhance your Agility with DevOpsEnhance your Agility with DevOps
Enhance your Agility with DevOps
 

Mehr von David Stockton

Phone calls and sms from php
Phone calls and sms from phpPhone calls and sms from php
Phone calls and sms from phpDavid Stockton
 
The Art of Transduction
The Art of TransductionThe Art of Transduction
The Art of TransductionDavid Stockton
 
Using queues and offline processing to help speed up your application
Using queues and offline processing to help speed up your applicationUsing queues and offline processing to help speed up your application
Using queues and offline processing to help speed up your applicationDavid Stockton
 
Intermediate OOP in PHP
Intermediate OOP in PHPIntermediate OOP in PHP
Intermediate OOP in PHPDavid Stockton
 
Building APIs with Apigilty and Zend Framework 2
Building APIs with Apigilty and Zend Framework 2Building APIs with Apigilty and Zend Framework 2
Building APIs with Apigilty and Zend Framework 2David Stockton
 
Intermediate OOP in PHP
Intermediate OOP in PHPIntermediate OOP in PHP
Intermediate OOP in PHPDavid Stockton
 
Hacking sites for fun and profit
Hacking sites for fun and profitHacking sites for fun and profit
Hacking sites for fun and profitDavid Stockton
 
Common design patterns in php
Common design patterns in phpCommon design patterns in php
Common design patterns in phpDavid Stockton
 
Intermediate oop in php
Intermediate oop in phpIntermediate oop in php
Intermediate oop in phpDavid Stockton
 
Hacking sites for fun and profit
Hacking sites for fun and profitHacking sites for fun and profit
Hacking sites for fun and profitDavid Stockton
 
Hacking sites for fun and profit
Hacking sites for fun and profitHacking sites for fun and profit
Hacking sites for fun and profitDavid Stockton
 
Increasing code quality with code reviews (poetry version)
Increasing code quality with code reviews (poetry version)Increasing code quality with code reviews (poetry version)
Increasing code quality with code reviews (poetry version)David Stockton
 
Tame Your Build And Deployment Process With Hudson, PHPUnit, and SSH
Tame Your Build And Deployment Process With Hudson, PHPUnit, and SSHTame Your Build And Deployment Process With Hudson, PHPUnit, and SSH
Tame Your Build And Deployment Process With Hudson, PHPUnit, and SSHDavid Stockton
 
Regular expressions and php
Regular expressions and phpRegular expressions and php
Regular expressions and phpDavid Stockton
 

Mehr von David Stockton (19)

Phone calls and sms from php
Phone calls and sms from phpPhone calls and sms from php
Phone calls and sms from php
 
The Art of Transduction
The Art of TransductionThe Art of Transduction
The Art of Transduction
 
Using queues and offline processing to help speed up your application
Using queues and offline processing to help speed up your applicationUsing queues and offline processing to help speed up your application
Using queues and offline processing to help speed up your application
 
Intermediate OOP in PHP
Intermediate OOP in PHPIntermediate OOP in PHP
Intermediate OOP in PHP
 
Building APIs with Apigilty and Zend Framework 2
Building APIs with Apigilty and Zend Framework 2Building APIs with Apigilty and Zend Framework 2
Building APIs with Apigilty and Zend Framework 2
 
API All the Things!
API All the Things!API All the Things!
API All the Things!
 
Intermediate OOP in PHP
Intermediate OOP in PHPIntermediate OOP in PHP
Intermediate OOP in PHP
 
Hacking sites for fun and profit
Hacking sites for fun and profitHacking sites for fun and profit
Hacking sites for fun and profit
 
Beginning OOP in PHP
Beginning OOP in PHPBeginning OOP in PHP
Beginning OOP in PHP
 
Common design patterns in php
Common design patterns in phpCommon design patterns in php
Common design patterns in php
 
Intermediate oop in php
Intermediate oop in phpIntermediate oop in php
Intermediate oop in php
 
Grokking regex
Grokking regexGrokking regex
Grokking regex
 
Hacking sites for fun and profit
Hacking sites for fun and profitHacking sites for fun and profit
Hacking sites for fun and profit
 
Hacking sites for fun and profit
Hacking sites for fun and profitHacking sites for fun and profit
Hacking sites for fun and profit
 
Increasing code quality with code reviews (poetry version)
Increasing code quality with code reviews (poetry version)Increasing code quality with code reviews (poetry version)
Increasing code quality with code reviews (poetry version)
 
Tame Your Build And Deployment Process With Hudson, PHPUnit, and SSH
Tame Your Build And Deployment Process With Hudson, PHPUnit, and SSHTame Your Build And Deployment Process With Hudson, PHPUnit, and SSH
Tame Your Build And Deployment Process With Hudson, PHPUnit, and SSH
 
Regular expressions and php
Regular expressions and phpRegular expressions and php
Regular expressions and php
 
PHP 5 Magic Methods
PHP 5 Magic MethodsPHP 5 Magic Methods
PHP 5 Magic Methods
 
FireBug And FirePHP
FireBug And FirePHPFireBug And FirePHP
FireBug And FirePHP
 

Kürzlich hochgeladen

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 

Kürzlich hochgeladen (20)

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 

Mercurial Distributed Version Control

  • 1. Mercurial Distributed Source Control Presented by David Stockton for Front Range PHP User Group April 28, 2010
  • 2. “If debugging is the process of removing bugs, then programming must be the process of putting them in.” - Anonymous
  • 3. Source Control in a Nutshell A great way to avoid catastrophic mistakes with your code Essential - If your code is more than a few lines long and you’re not using source control, you must not think very highly of your work. If you’re not using source control, start now. Even CVS is better than no source control. (Not sure about VSS though)
  • 4. Source Control in a Nutshell If you are working with a team (read, one or more other people) source control is essential If you’re working by yourself and you’ve ever made a mistake, source control is essential If you ever wished you could undo something you just did, source control is essential If you need to maintain different versions of the same code, source control is essential.
  • 5. I could go on, but...
  • 6. I could go on, but... The bottom line is...
  • 7. I could go on, but... The bottom line is... Source control is absolutely essential!
  • 8. Questions? Questions about source control in general?
  • 9. Goals of Source Control Keep your source code safe Allow you to look at different versions of your code Allow multiple developers to work simultaneously Allow multiple “branches” of code to be worked on at the same time
  • 10. Common/Popular Source Control Tools CVS SVN (Subversion) ClearCase Perforce Microsoft Visual SourceSafe Git Mercurial
  • 11. Common/Popular Source Control Tools BitKeeper Telelogic Synergy Visual Studio Team System StarTeam RCS Tons of others...
  • 12. Types of Source Control Client Server Model (CVS, SVN, etc) Distributed (Git, Mercurial)
  • 13. Mercurial Distributed Version Control System Works the way you want it instead of forcing you to use it in a certain way Used by lots of big projects
  • 16. How does it work? Probably not the way you’d think if you’ve used CVS or SVN or other client server VCS (Version Control System)
  • 17. How it’s different No central server ... or at least not one that’s required Works on changesets, not file or repository versions Changesets allow merges (shudder) to be simple This is a good thing since you’ll be merging a lot Learn to not be afraid of the merge
  • 18. What else? Doing a checkout gives you a full copy of the repository Including all changes, etc Lose a server? Just clone another copy of the repository
  • 19. What can you do with it? Pretty much anything Clone a repository to try out some experimental code If it works, keep it If not, delete it, no harm done And no evidence of your failed attempt
  • 20. What can you do with it? Work on a plane (and still check in code) Collaborate with a colleague in a coffee shop Pick and choose what you want in your repository Push, pull and clone from other repositories
  • 21. Make your VCS work how you do! Work on the road Work from home Work from work Work from a plane Work from a train Work in an automobile (if you’re not driving)
  • 22. #1 Awesome Thing Branches are easy ... But they’re pretty easy in CVS and SVN too
  • 23. Branches If you’re working on Feature A and I am working on Feature B, we’ve essentially branched Two or more people working on code based on the same thing creates branches Named branches Unnamed branches Branches by cloning
  • 24. #2 Awesome Thing Branches being easy is great, but only if... Merges are super easy! Most merges handled automatically Merge conflicts can be handled by a tool of your choice I like kdiff3
  • 25. #3 Awesome Thing No network? No problem Work from anywhere Collaborate with a colleague in the middle of nowhere
  • 26. Installation Mercurial is cross platform with excellent support on Windows, Linux and Mac http://mercurial.selenic.com/ Download binary for Windows or Mac ... or apt-get install mercurial yum install mercurial ermerge mercurial pkg install SUNWmercurial
  • 27. Create a new Repository
  • 29. You now have a working repository If you don’t do command line there are other ways IDE Integration - Eclipse, NetBeans, IntelliJ, Emacs, Vim, TextMate, Visual Studio Windows integration with TortoiseHg Build/Management tools with Hg support: CruiseControl, JIRA, Trac, Maven, Redmine, Hudson, ant, etc
  • 30. Add some code Use ‘hg add’ to tell Mercurial about the files you want it to track Use ‘hg commit’ to tell Mercurial to check in code hg ci hg com
  • 32. Look at the repository
  • 33. Look at the repository
  • 34. Make some more changes
  • 38. What does that commit look like? Pretty much the same Why? Luke Skywalker has his own repository
  • 39. How can I get Luke’s Change? Use ‘hg push’ from Luke’s instance Use ‘hg pull’ on my instance to Luke’s instance
  • 41. What does it do to me? Where are the changes? Pushes do not affect the working copy Why? Updating the workspace could make me lose my work
  • 42. How to see those changes? Use ‘hg up’ Update your own workspace
  • 43. Let’s mix it up Dave makes a change to cookie to specify flour amount Luke makes a change to cookie to add eggs
  • 44. A matter of timing...
  • 47. But then... Don’t use -f to force... Don’t do it...
  • 49. Quick recap First check-in goes in Second check-in based on same code needs merge ‘hg pull’ + ‘hg merge’ took a fraction of a second Merge was correct Luke now needs to commit the merge and push back to Dave’s server
  • 51. And it now looks like...
  • 52. Still too easy... Let’s try a merge conflict... Dave needs more flour in the recipe Also, Dave hasn’t updated his workspace with the merge results Luke wants to use cake flour
  • 53. Merge conflict in the making
  • 54. Now the fun part Luke uses the force and does a check in and push before Dave does a check-in
  • 55. Here comes trouble... Dave tries to commit ... And it works ...
  • 56. But... it created a new head
  • 57. To get Luke’s changes...
  • 58. Merge 2 heads into 1 All that junk is kdiff3 launching. I should fix that...
  • 59. Merge in kdiff3 Notice that the eggs part was automatically resolved
  • 63. Crazy branch/merges The example to the right was done with just 5 users but I was purposely trying to make lots of weird branch merge situations occur.
  • 64. Command overview hg clone - clone a repository hg merge - merge changes together hg add - tell Mercurial to start caring about some files hg commit - commit a new changeset hg push - send your changesets to another server hg pull - retrieve changesets from another server
  • 65. Command overview cont... hg update - Update your local workspace with the stuff from hg pull hg annotate - show which changeset is responsible for each line in a file hg diff - show the differences between files in your workspace and the committed file hg export - dump the header and diffs for one or more changesets
  • 66. Command overview cont... hg forget - Forget the specified files (remove from repository, not from workspace) when you commit hg log - show revision history hg remove - delete file and remove from repository when you commit hg serve - simple http server to show the repository (useful for coffee shop working)
  • 67. hg addremove - add all new files, remove deleted files hg backout - reverse effect of earlier changeset hg bisect - search changesets (DEMO) hg branch - set or show branch names hg branches - list all branches hg copy - mark file as copied for next commit (DEMO) hg heads - show repository or branch heads
  • 68. hg help - Where I’m getting this list of commands hg identify - identify the working copy hg incoming - show new changesets in source hg init - create a new repository hg outgoing - show changesets not in destination hg parents - show parents of working directory or revision
  • 69. Command overview cont... hg status - Show what’s going to happen when you commit hg summary - Summarize state of working directory hg paths - show aliases for remote repositories hg rename - rename a file (same as hg copy + hg remove) (DEMO) hg tag - tag a revision hg tags - show tags in repository
  • 70. Holy crap... That wasn’t even all the commands Or all the coolness
  • 71. As time permits... hg bisect demo hg copy demo hg rename demo hg mq - Patching, orthogonal mutable changesets
  • 73. Excellent Resources Quick and easy overview: http://hginit.com - Joel Spolsky’s explanation of Mercurial Mercurial: The Definitive Guide Available online at http://hgbook.red-bean.com/read/ Or buy from Amazon.com or O’Reilly Media

Hinweis der Redaktion