introduction to mercurial

47
Barcamp Scotland 2008 Introduction to Mercurial How to improve your source control. Tane Piper [email protected] http://digitalspaghetti.me.uk http://twitter.com/tanepiper February 2nd, 2008 Tane Piper [email protected] Introduction to Mercurial

Upload: digitalspaghetti

Post on 17-May-2015

4.453 views

Category:

Technology


0 download

DESCRIPTION

A short talk on Mercurial i gave at Barcamp Scotland 2008

TRANSCRIPT

Page 1: Introduction to Mercurial

Barcamp Scotland 2008Introduction to Mercurial

How to improve your source control.

Tane [email protected]

http://digitalspaghetti.me.ukhttp://twitter.com/tanepiper

February 2nd, 2008

Tane Piper [email protected] Introduction to Mercurial

Page 2: Introduction to Mercurial

Introduction

What Is Covered?

A (Short) History of Source Control

Distributed Source Control

Mercurial itself

How to import your project

Download from http://tinyurl.com/2spv4h

Tane Piper [email protected] Introduction to Mercurial

Page 3: Introduction to Mercurial

Introduction

What Is Covered?

A (Short) History of Source Control

Distributed Source Control

Mercurial itself

How to import your project

Download from http://tinyurl.com/2spv4h

Tane Piper [email protected] Introduction to Mercurial

Page 4: Introduction to Mercurial

Introduction

What Is Covered?

A (Short) History of Source Control

Distributed Source Control

Mercurial itself

How to import your project

Download from http://tinyurl.com/2spv4h

Tane Piper [email protected] Introduction to Mercurial

Page 5: Introduction to Mercurial

Introduction

What Is Covered?

A (Short) History of Source Control

Distributed Source Control

Mercurial itself

How to import your project

Download from http://tinyurl.com/2spv4h

Tane Piper [email protected] Introduction to Mercurial

Page 6: Introduction to Mercurial

Introduction

What Is Covered?

A (Short) History of Source Control

Distributed Source Control

Mercurial itself

How to import your project

Download from http://tinyurl.com/2spv4h

Tane Piper [email protected] Introduction to Mercurial

Page 7: Introduction to Mercurial

A (Short) History of Source Control I

SCCS (Source Code Control System)Marc Rochkind wrote at Bell Labs, in the early 1970s.

SCCS operated on individual files and every author had accessto a shared workspace on a single system.

It was common for people to lock files, and later forget tounlock them, preventing anyone else from modifying thosefiles without the help of an administrator.

Tane Piper [email protected] Introduction to Mercurial

Page 8: Introduction to Mercurial

A (Short) History of Source Control I

SCCS (Source Code Control System)Marc Rochkind wrote at Bell Labs, in the early 1970s.

SCCS operated on individual files and every author had accessto a shared workspace on a single system.

It was common for people to lock files, and later forget tounlock them, preventing anyone else from modifying thosefiles without the help of an administrator.

Tane Piper [email protected] Introduction to Mercurial

Page 9: Introduction to Mercurial

A (Short) History of Source Control I

SCCS (Source Code Control System)Marc Rochkind wrote at Bell Labs, in the early 1970s.

SCCS operated on individual files and every author had accessto a shared workspace on a single system.

It was common for people to lock files, and later forget tounlock them, preventing anyone else from modifying thosefiles without the help of an administrator.

Tane Piper [email protected] Introduction to Mercurial

Page 10: Introduction to Mercurial

A (Short) History of Source Control II

Dick Grune developed CVS (Concurrent Versions System).

CVS let developers work simultaneously and somewhatindependently in their own personal workspaces.

They had to merge their edits prior to committing changes tothe central repository.

Tane Piper [email protected] Introduction to Mercurial

Page 11: Introduction to Mercurial

A (Short) History of Source Control II

Dick Grune developed CVS (Concurrent Versions System).

CVS let developers work simultaneously and somewhatindependently in their own personal workspaces.

They had to merge their edits prior to committing changes tothe central repository.

Tane Piper [email protected] Introduction to Mercurial

Page 12: Introduction to Mercurial

A (Short) History of Source Control II

Dick Grune developed CVS (Concurrent Versions System).

CVS let developers work simultaneously and somewhatindependently in their own personal workspaces.

They had to merge their edits prior to committing changes tothe central repository.

Tane Piper [email protected] Introduction to Mercurial

Page 13: Introduction to Mercurial

A (Short) History of Source Control III

In 2001 Jim Blandy and Karl Fogel developed Subversion.

Subversion, does not stray from CVS’s centralisedclient/server model.

Added features such as multi-file atomic commits and betternamespace management.

At the same time Graydon Hoare was working on Monotone.

Featured cryptographic hashes as identifiers, and has anintegral notion of ”trust” for code from different sources.

Tane Piper [email protected] Introduction to Mercurial

Page 14: Introduction to Mercurial

A (Short) History of Source Control III

In 2001 Jim Blandy and Karl Fogel developed Subversion.

Subversion, does not stray from CVS’s centralisedclient/server model.

Added features such as multi-file atomic commits and betternamespace management.

At the same time Graydon Hoare was working on Monotone.

Featured cryptographic hashes as identifiers, and has anintegral notion of ”trust” for code from different sources.

Tane Piper [email protected] Introduction to Mercurial

Page 15: Introduction to Mercurial

A (Short) History of Source Control III

In 2001 Jim Blandy and Karl Fogel developed Subversion.

Subversion, does not stray from CVS’s centralisedclient/server model.

Added features such as multi-file atomic commits and betternamespace management.

At the same time Graydon Hoare was working on Monotone.

Featured cryptographic hashes as identifiers, and has anintegral notion of ”trust” for code from different sources.

Tane Piper [email protected] Introduction to Mercurial

Page 16: Introduction to Mercurial

A (Short) History of Source Control III

In 2001 Jim Blandy and Karl Fogel developed Subversion.

Subversion, does not stray from CVS’s centralisedclient/server model.

Added features such as multi-file atomic commits and betternamespace management.

At the same time Graydon Hoare was working on Monotone.

Featured cryptographic hashes as identifiers, and has anintegral notion of ”trust” for code from different sources.

Tane Piper [email protected] Introduction to Mercurial

Page 17: Introduction to Mercurial

A (Short) History of Source Control III

In 2001 Jim Blandy and Karl Fogel developed Subversion.

Subversion, does not stray from CVS’s centralisedclient/server model.

Added features such as multi-file atomic commits and betternamespace management.

At the same time Graydon Hoare was working on Monotone.

Featured cryptographic hashes as identifiers, and has anintegral notion of ”trust” for code from different sources.

Tane Piper [email protected] Introduction to Mercurial

Page 18: Introduction to Mercurial

Distributed Version Control

What is Distributed Version Control?

Tane Piper [email protected] Introduction to Mercurial

Page 19: Introduction to Mercurial

Distributed Version Control (DVCS)

Both git and Mercurial were announced in April 2005 toreplace the withdrawal of free BitKeeper VC software, whichwas used to control the Linux kernel.

git developed by Linus Torvalds to manage the Linux kernel.

Mercurial was also developed for kernel, but git won out.

Tane Piper [email protected] Introduction to Mercurial

Page 20: Introduction to Mercurial

Distributed Version Control (DVCS)

Both git and Mercurial were announced in April 2005 toreplace the withdrawal of free BitKeeper VC software, whichwas used to control the Linux kernel.

git developed by Linus Torvalds to manage the Linux kernel.

Mercurial was also developed for kernel, but git won out.

Tane Piper [email protected] Introduction to Mercurial

Page 21: Introduction to Mercurial

Distributed Version Control (DVCS)

Both git and Mercurial were announced in April 2005 toreplace the withdrawal of free BitKeeper VC software, whichwas used to control the Linux kernel.

git developed by Linus Torvalds to manage the Linux kernel.

Mercurial was also developed for kernel, but git won out.

Tane Piper [email protected] Introduction to Mercurial

Page 22: Introduction to Mercurial

An Example of the DVCS Model

Figure: An example of the Mercurial distributed model.

Tane Piper [email protected] Introduction to Mercurial

Page 23: Introduction to Mercurial

Simple description of the DVCS model

No repository is king - no ”central” repository except for oneagreed in a social fashion.

Can be thought of as ”the bittorrent of the DVCS world”,compaired to CVS/SVN model which is akin to a FTP.

Cloning repositories locally allows for more experimentation.

As simple to set up as typing ’hg init’.

Tane Piper [email protected] Introduction to Mercurial

Page 24: Introduction to Mercurial

Simple description of the DVCS model

No repository is king - no ”central” repository except for oneagreed in a social fashion.

Can be thought of as ”the bittorrent of the DVCS world”,compaired to CVS/SVN model which is akin to a FTP.

Cloning repositories locally allows for more experimentation.

As simple to set up as typing ’hg init’.

Tane Piper [email protected] Introduction to Mercurial

Page 25: Introduction to Mercurial

Simple description of the DVCS model

No repository is king - no ”central” repository except for oneagreed in a social fashion.

Can be thought of as ”the bittorrent of the DVCS world”,compaired to CVS/SVN model which is akin to a FTP.

Cloning repositories locally allows for more experimentation.

As simple to set up as typing ’hg init’.

Tane Piper [email protected] Introduction to Mercurial

Page 26: Introduction to Mercurial

Simple description of the DVCS model

No repository is king - no ”central” repository except for oneagreed in a social fashion.

Can be thought of as ”the bittorrent of the DVCS world”,compaired to CVS/SVN model which is akin to a FTP.

Cloning repositories locally allows for more experimentation.

As simple to set up as typing ’hg init’.

Tane Piper [email protected] Introduction to Mercurial

Page 27: Introduction to Mercurial

Mercurial Itself

Excellent support on Windows / Unix / MacOSX

Tools such as TortoiseHG for Windows, QCT, Push Me PullYou, etc make usage easy.

Functionality can be added through an extension API withhooks (e.g. pre and post commit).

Doesn’t pollute the namespace - keeps everything in one’.hg’ directory.

Provides it’s own web interface - hgweb (hgwebdir for acollection of repositories).

Tane Piper [email protected] Introduction to Mercurial

Page 28: Introduction to Mercurial

Mercurial Itself

Excellent support on Windows / Unix / MacOSX

Tools such as TortoiseHG for Windows, QCT, Push Me PullYou, etc make usage easy.

Functionality can be added through an extension API withhooks (e.g. pre and post commit).

Doesn’t pollute the namespace - keeps everything in one’.hg’ directory.

Provides it’s own web interface - hgweb (hgwebdir for acollection of repositories).

Tane Piper [email protected] Introduction to Mercurial

Page 29: Introduction to Mercurial

Mercurial Itself

Excellent support on Windows / Unix / MacOSX

Tools such as TortoiseHG for Windows, QCT, Push Me PullYou, etc make usage easy.

Functionality can be added through an extension API withhooks (e.g. pre and post commit).

Doesn’t pollute the namespace - keeps everything in one’.hg’ directory.

Provides it’s own web interface - hgweb (hgwebdir for acollection of repositories).

Tane Piper [email protected] Introduction to Mercurial

Page 30: Introduction to Mercurial

Mercurial Itself

Excellent support on Windows / Unix / MacOSX

Tools such as TortoiseHG for Windows, QCT, Push Me PullYou, etc make usage easy.

Functionality can be added through an extension API withhooks (e.g. pre and post commit).

Doesn’t pollute the namespace - keeps everything in one’.hg’ directory.

Provides it’s own web interface - hgweb (hgwebdir for acollection of repositories).

Tane Piper [email protected] Introduction to Mercurial

Page 31: Introduction to Mercurial

Mercurial Itself

Excellent support on Windows / Unix / MacOSX

Tools such as TortoiseHG for Windows, QCT, Push Me PullYou, etc make usage easy.

Functionality can be added through an extension API withhooks (e.g. pre and post commit).

Doesn’t pollute the namespace - keeps everything in one’.hg’ directory.

Provides it’s own web interface - hgweb (hgwebdir for acollection of repositories).

Tane Piper [email protected] Introduction to Mercurial

Page 32: Introduction to Mercurial

Mercurial Commands I

’hg init <name>’ - This initialises the local repository. Youcan do this command within the root folder too.

’hg add’ - This will add any files within the directorystructure to the local repository.

’hg commit’ - This will commit any changes to your localrepository.

’hg push’ - This will push any changes to your repository.

Tane Piper [email protected] Introduction to Mercurial

Page 33: Introduction to Mercurial

Mercurial Commands I

’hg init <name>’ - This initialises the local repository. Youcan do this command within the root folder too.

’hg add’ - This will add any files within the directorystructure to the local repository.

’hg commit’ - This will commit any changes to your localrepository.

’hg push’ - This will push any changes to your repository.

Tane Piper [email protected] Introduction to Mercurial

Page 34: Introduction to Mercurial

Mercurial Commands I

’hg init <name>’ - This initialises the local repository. Youcan do this command within the root folder too.

’hg add’ - This will add any files within the directorystructure to the local repository.

’hg commit’ - This will commit any changes to your localrepository.

’hg push’ - This will push any changes to your repository.

Tane Piper [email protected] Introduction to Mercurial

Page 35: Introduction to Mercurial

Mercurial Commands I

’hg init <name>’ - This initialises the local repository. Youcan do this command within the root folder too.

’hg add’ - This will add any files within the directorystructure to the local repository.

’hg commit’ - This will commit any changes to your localrepository.

’hg push’ - This will push any changes to your repository.

Tane Piper [email protected] Introduction to Mercurial

Page 36: Introduction to Mercurial

Mercurial Commands II

’hg pull’ - This will pull the content to your localrepository from the remote repository set in the config file.

’hg update’ - Updates and merges pulls to local repositorywhere no heads are created (i.e. if you have made no localchanges since your last pull).

’hg merge’ - This will merge any heads created bypushing/pulling from repositories.

’hg log’ - View a list of changesets.

Tane Piper [email protected] Introduction to Mercurial

Page 37: Introduction to Mercurial

Mercurial Commands II

’hg pull’ - This will pull the content to your localrepository from the remote repository set in the config file.

’hg update’ - Updates and merges pulls to local repositorywhere no heads are created (i.e. if you have made no localchanges since your last pull).

’hg merge’ - This will merge any heads created bypushing/pulling from repositories.

’hg log’ - View a list of changesets.

Tane Piper [email protected] Introduction to Mercurial

Page 38: Introduction to Mercurial

Mercurial Commands II

’hg pull’ - This will pull the content to your localrepository from the remote repository set in the config file.

’hg update’ - Updates and merges pulls to local repositorywhere no heads are created (i.e. if you have made no localchanges since your last pull).

’hg merge’ - This will merge any heads created bypushing/pulling from repositories.

’hg log’ - View a list of changesets.

Tane Piper [email protected] Introduction to Mercurial

Page 39: Introduction to Mercurial

Mercurial Commands II

’hg pull’ - This will pull the content to your localrepository from the remote repository set in the config file.

’hg update’ - Updates and merges pulls to local repositorywhere no heads are created (i.e. if you have made no localchanges since your last pull).

’hg merge’ - This will merge any heads created bypushing/pulling from repositories.

’hg log’ - View a list of changesets.

Tane Piper [email protected] Introduction to Mercurial

Page 40: Introduction to Mercurial

How Mercurial Changesets Work

Figure: A example of linear changesets. This is very common inrepositories from one developer and once branch.

Tane Piper [email protected] Introduction to Mercurial

Page 41: Introduction to Mercurial

Simultaneous Local Changesets

Figure: Two local repositories with different changeset histories.

Tane Piper [email protected] Introduction to Mercurial

Page 42: Introduction to Mercurial

Results of pulling a changeset into your local repository.

Figure: Pulling a remote repository’s tip into your local repository creates2 heads. These need to be merged before you can continue.

Tane Piper [email protected] Introduction to Mercurial

Page 43: Introduction to Mercurial

Results of merging heads.

Figure: Merging the two heads together creates a new head. This cannow be pushed or pulled to other repositories and merged with otherheads.

Tane Piper [email protected] Introduction to Mercurial

Page 44: Introduction to Mercurial

Thank you for listning.

Check out more about Mercurial at http://tinyurl.com/3xphcz

SHAMELESS PLUG - Follow the progress of MercurialFrontend at http://digitalspaghetti.me.uk

Comments welcome at [email protected]

You can download these slides fromhttp://hg.digitalspaghetti.me.uk/hgtalk

Tane Piper [email protected] Introduction to Mercurial

Page 45: Introduction to Mercurial

Thank you for listning.

Check out more about Mercurial at http://tinyurl.com/3xphcz

SHAMELESS PLUG - Follow the progress of MercurialFrontend at http://digitalspaghetti.me.uk

Comments welcome at [email protected]

You can download these slides fromhttp://hg.digitalspaghetti.me.uk/hgtalk

Tane Piper [email protected] Introduction to Mercurial

Page 46: Introduction to Mercurial

Thank you for listning.

Check out more about Mercurial at http://tinyurl.com/3xphcz

SHAMELESS PLUG - Follow the progress of MercurialFrontend at http://digitalspaghetti.me.uk

Comments welcome at [email protected]

You can download these slides fromhttp://hg.digitalspaghetti.me.uk/hgtalk

Tane Piper [email protected] Introduction to Mercurial

Page 47: Introduction to Mercurial

Thank you for listning.

Check out more about Mercurial at http://tinyurl.com/3xphcz

SHAMELESS PLUG - Follow the progress of MercurialFrontend at http://digitalspaghetti.me.uk

Comments welcome at [email protected]

You can download these slides fromhttp://hg.digitalspaghetti.me.uk/hgtalk

Tane Piper [email protected] Introduction to Mercurial