At my new job we use Mercurial (for the non-techies but still interested in sex this is Mercurial <– click that). I have used Git in the past and liked it but it’s been long so it was kinda re-learning the basics. I was happy to jump onto it – because I really really really wanted to forget all about SVN. I don’t think I will ever want to use it again.
I know now you are getting restless – because you probably are reading this because of the word ‘sex’ in the title! Fear not, I am gonna give you a nice way to understand Mercurial. After that you may never choose to use it or forever love it.
I figured it out that Mercurial is all about sex. To go with the story lets define some terms.
- Under mercurial everyone has their own repository.
- You may or may not choose to have a central repository. Kinda free to be alone.
- Working directory is a piece of shit. Mercurial remembers whats in your working directory (if you are ”committed’) and then can swap it out with 1 command. So, don’t feel bad about your jewel code in there – mercurial doesn’t care.
To elucidate lets take an example of a guy and girl who are trying to date. Lets call them John and Jane. Here is how I can explain the concepts behind mercurial.
- John wants to be in a relationship. He needs to initiate it and intend it: $hg init (the folder name could be- ‘one night stand’, ‘long term rel’)
- May be John saw his friends making out with their girl friends – so John want something similar: $hg clone
- John gotta work on himself. Build that 8-pack he has been thinking of and all those fat tires around his waist and neck: $hg add, $hg remove, $hg mv, $hg cp and finally committed to look good $hg commit
- It’s the same for Jane too.
- Everything is all about the local repo. It’s like this ideal person John and Jane wants to be. It’s like seeing themselves in mirror and updating themselves: $hg update
- $hg status – state of mind. John drunk and horny. Jane depressed and flirty. Pick a vice.
- Now the fun starts – John and Jane are dating.
- John wants to take Jane to dinner at his parents place! (I know lame). $hg pull
- Jane wants to control John and tell him what she like and dislikes : $hg push
- Once they meet after 6pm and both are needy. Irrespective of whether they pushed or pulled you would end up with 2 heads. Imagine John and Jane lying down on a bed next to each other. You see 2 heads right? If not run : $hg heads. Well for the adventurous one it’s possible to have more than 2 heads -but don’t be such a sicko!
- Now the most fun part – once in bed they gotta do something: $hg merge – Woo Hoo. It starts with a lonely init and ends with a climatic merge!
- There are some other stuff which might help –
- John wants to check whose his parents are : $hg parents
- Jane checks herself out in the mirror and see what’s happening. $hg diff
- $hg revert – Jane wiping her make up off.
- $hg rollback – 1 chance for both Jane and John to cheat on each other and rollback.
- $hg backout – I think this might be about saying goodbye. Not sure.