GTALUG Short Talk On Mercurial
-
Upload
myles-braithwaite -
Category
Technology
-
view
788 -
download
1
description
Transcript of GTALUG Short Talk On Mercurial
What is Revision Control
• Allows multiple people to collaborate on a file.
AppleOrangesCherriesMilkApple Pear ChineseNoodlesPomegranateStrawberriesBananas
$ rc add 2009-12-11.txt$ rc commit -m 'Added the Grocery List for Friday 11 Dec, 2009.'
$ rc logreversion: 1author: Myles Braithwaitesummary: Added the Grocery List for Friday 11 Dec, 2009.
AppleOrangesCherriesMilkChinese White Pear Apple Pear ChineseNoodlesPomegranateStrawberriesBananas
$ rc statusModified: 2009-12-11.txt$ rc commit -m "It's called a Chinese White Pear not a Apple Pear Chinese Fruit"
$ rc diff -r 1diff -r 1 2009-12-11.txt--- a/2009-12-11.txt Thu Dec 03 15:45:38+++ b/2009-12-11.txt Thu Dec 03 15:51:39@@ -2,7 +2,7 @@ Oranges Cherries Milk-Apple Pear Chinese Fruit+Chinese White Pear Noodles Pomegranate Strawberries
$ rc logreversion: 1author: Myles Braithwaitesummary: Added the Grocery List for Friday 11 Dec, 2009.
reversion: 2author: Other Personsummary: It's called a Chinese White Pear not a Apple Pear Chinese Fruit
• Attempt to merge changes between two commits.
AppleOrangesCherriesMilkChinese White PearNoodlesPomegranateStrawberriesBananasTea
$ rc commit -m 'Added tea to the list'
Apple @doneOranges @doneCherries @doneMilkChinese White PearNoodlesPomegranateStrawberriesBananas
$ rc commit -m 'Went to the Grocery store and picked up Apples, Oranges, and Cherries.'
The Repository is Out of Sync. Please merge the new changes.
$ rc mergeMerge was successful.$ rc commit -m 'Merging changes'
StrawberriesBananas<<< HEADTea (Chai)>>>><<<< 6Tea (Green)>>>>
MercurialMyles [email protected]@mylesb
History
• Matt Machall
• Originally developed for the Linux Kernel.
• For some reason Torvalds’ picked Git?
Quick Facts
• Implemented in the awesome Python programming language.
• But includes a binary diff written in C.
• Originally written to run on Linux.
• But it has been successfully ported to run natively on Mac OS X, Windows, and other Unix-like systems.
• Python (http://hg.python.org)
• Mozilla (http://hg.mozilla.org)
• OpenSolaris
• OpenJDK (http://hg.openjdk.java.net)
• OpenOffice.org
• More here: http://j.mp/ProjectUsingHg
Installation (Linux)# Debian or Ubuntu$ aptitude install mercurial
# Fedora$ yum install mercurial
# Gentoo$ emerge mercurial
# OpenSolaris$ pkg install SUNWmercurial
Installation (Windows)
• Download and install the official exe.
• Download TortoiseHg (http://tortoisehg.org)
• Integrates Mercurial directly into explorer.
Installation (Mac OS X)
• Install the DMG file.
Installation (PyPi)
$ easy_install mercurial
$ pip install mercurial
Installation from Source
$ wget http://mercurial.selenic.com/release/mercurial-1.4.1.tar.gz$ tar -xzf mercurial-1.4.1.tar.gz$ cd mercurial-1.4.1$ python setup.py build$ sudo python setup.py install$ hg --versionMercurial Distributed SCM (version 1.4.1)
$ $EDITOR ~/.hgrc
[ui]username = Myles Braithwaite <[email protected]>
$ export P_DIR=~/GroceryList$ $ # Create an empty repository on your$ # local machine.$ mkdir $P_DIR; cd $P_DIR$ hg init$$ # Clone a remote repository.$ hg clone ssh://hg.mb/grocery_list $P_DIRdestination directory: /home/m/GroveryList...3 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ echo 'Apple' > cat 2009-12-08.txt$ hg status? 2009-12-08.txt$ hg add 2009-12-08.txt$ hg statusA 2009-12-08.txt$ hg commit -m 'Added the grocery list for 9th Dec. 2009.'
$ hg statusM 2009-12-08.txt$ hg diffdiff -r 012549b5c017 2009-12-08.txt--- a/2009-12-08.txt 19:42:25+++ b/2009-12-08.txt 19:44:46@@ -1,1 +1,2 @@ Apples+Pizza$ hg commit -m 'I am hungry for some Pizza.'
$ hg log -l 2changeset: 14:848072d17be0tag: tipuser: Myles Braithwaitedate: 19:49:10summary: I am hungry for some Pizza
changeset: 13:012549b5c017user: Myles Braithwaitedate: 19:42:25summary: Added the grocery list for 9th Dec. 2009.
$ hg annotate 2009-12-08.txt 13: Apples14: Pizza15: Nuts16: Hot Chocolate Mix
$ hg tagstip 16:54c53457b1ac2009-12-04 9:d1361977c248$ hg tag 2009-12-08$ hg tagstip 17:21598a08291c2009-12-08 16:54c53457b1ac2009-12-04 9:d1361977c248
$ cat .hgtags d1361977c2... 2009-12-0454c53457b1... 2009-12-08
# If we cloned the repository.$ hg push
$ hg push ssh://hg.mb/grocery_list
$ hg pull ssh://hg.mb/grocery_listpulling from ssh://hg.mb/grocery_listsearching for changes...(run 'hg update' to get a working copy)$ hg update1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg log -l 2changeset: 20:6dfef8e8a348tag: tipuser: Other Personsummary: Remove some things fromthe list that were already entered on Friday' list.
changeset: 19:1564f5195566date: 16:30:18summary: Added a shopping list for Sat. 12 Dec. 2009
$ hg diff -r 19diff -r 1564f5195566 2009-12-12.odtBinary file 2009-12-12.odt has changed
$ # Using an extension we can call an$ # external program to run the diff.$ hg extdiff -p oodiff -r 19--- GroceryList.1565f5195566/2009-12-12.odt+++ GroveryList/2009-12-12.odt@@ -1,12 +1,4 @@
- Oranges- - Apples-- Bananas-- Cereal- Cherios
Beer
$ # To enable external diff's extension.$ $EDITOR .hg/hgrc[extensions]extdiff =
$ hg serve -n "Shopping List"
.hgignore
# use global syntax.syntax: glob*.pyc*.pyo*~
# switch to regular expressions syntax.syntax: regexp^\.pc/
Find out more...
• http://mercurial.selenic.com
Other cool stuff...
• Google Code (http://code.google.com/p)
• Bitbucket (http://bitbucket.org)