Archive for April, 2013

JLSN – Basic Mercurial usage

April 21, 2013 Leave a comment

I have been using Subversion for a long time for version control but I wanted to learn something new. So picked Mercurial since some guys I know seem to love it. As usual I am just keeping this here for future reference. One thing I learnt was not to try to map svn commands to hg commands. I just approached this like someone who has never used a version control system before. My notes below

# Copy existing repository
# Over the network use the url
$hg clone

# Always a good idea to keep a copy of the original repository
$hg clone hello my-hello
$cd my-hello

# Give a view of the history of changes in the repository
$hg log

# View a specific revision
$hg log -r 3
$hg log -r 1 -r 4
$hg log -r 2:4
$hg log -r 4:2

# More verbose log
$hg log -v r 3

# Get the description and content of the change.
$hg log -v -p -r 2

# Add a new line to hello.c
printf("Hello again\n");

# What does Mercurial know about the files in the repository
$hg status

# See what has changed
$hg diff
$ cd ../
$hg clone hello hello-pull

# How to pull changes in another repository(my-hello) into yours(hello-pull)
$cd hello-pull
$hg pull ../my-hello

# To pull specific changes specify the revision number or the change set number
# NB Pull does not make changes. It just tells you what has been changed.
# Update the working directory to the state it was in at any revision in the 
# history of the reposity. If no revision is specified it updates tip.
$hg update 
$hg update -r2
$hg update tip

# To pull and update tip
$hg pull -u

# To find out what revision the working directory is at
$hg parents

# Pushing changes from your repository (my-hello) 
# to another repository (hello-push)
$cd ..
$hg clone hello hello-push
$cd my-hello

# Find out what changes will be pushed to the other repository
$hg outgoing ../hello-push

# Do the actual push
$hg push

# NB. Not possible to update the working directory in the repository being pushed.
# One reason could be that someone is working on some stuff and you updating 
# their stuff will not be fun.

# To start a new project
$cd ..
$hg init myproject
$less goodbye.c
#include <stdio.h>

int main(){
    return 0;

$mv goodbye.c myproject/
$hg add
$hg status
$hg commit -m "Initial Commit"
$hg log

Mercurial: The Definitive Guide by Bryan O’Sullivan

Also read:

Stop the Hollyweb!

April 17, 2013 Leave a comment

Stop the Hollyweb! No DRM in HTML5.

Categories: Interesting Tags:

Interesting – Python, ‘yeild’ and ‘generators’ explained

April 16, 2013 Leave a comment
Categories: Interesting, python