 Good morning. So how many of you have heard about mercurial? Great one, two. Okay. So yeah, it's a version control system, just like get, but it's more powerful and fast than get. So let's dive into mercurial. So this session will be like more of a demo so that you guys can, most of you guys have used version control systems like mostly all of you have used get over here. So let's dive into mercurial and see how it's better than get another version control systems and how we can use the use it. So let's start it. Sorry. Yeah. So let's start with creating a repository and so let's create a repo. Okay. So now to initialize a mercurial repo, just like get in it, you do HG in it. And this is now a mercurial repo. Let's commit a change. Okay. So now you have a file in your repository named A and you're written hello over here. If you do, so it's hello here. But to start to tell mercurial to start tracking your file, you need to add it just like not similar to get in get you do get add but in mercurial, there is no staging area like in get you make changes add them to the staging area and then commit them. In mercurial, there is no staging area. You just need to start tracking the file at in the beginning. So in mercurial, you will just do HG at it. Okay. So a already tracked. So by doing add, you are just starting to track that file. Okay. So now we have tracked the file. You can see the diff and we have hello. Let's commit that. Okay. So let's have more commits over here. Equal world to a and a to b. Okay. So the diff doesn't show b now because it's not all tracked. We need to add it to get it tracked. So let's add b and you can see it's in the diff over there. So now if what if you want to just like commit the changes of b not of not of a. So you can do HG come. You can change do that interactively. Examine changes to a. Yeah, record. You don't want to record changes to a still. Okay. No changes to b. Yeah. You want to record it. Yeah. Oh. So it's added b. Okay. So still the change to a lies in your diff. So it's like you can do all the things which you can do with the help of staging area. So let's have. So now about like how to view the history like yesterday Christian was talking about bisects and rebase and all. So let's do all that also. So this is the law commands helps you to see the history log. So the log you can see that we have two chainsets. One is added a one is added b. Let's have more chainsets. So I will just change the current, commit the current changes which are there. So it will be to a and then. Okay. So coming from the get while all of you are used to branches like get branch master get get branch original and everything like so in mercurial to if you want to make a branch it's quite easy to understand how mercurial works just understand how a graph works. Here you can see who is the rest of the part. Yeah. So yeah. So now you can see it. So yeah. So now you can see that the graphs looks like you have three chainsets one on the one on the another. So now to create a branch. So you can just update yourself. So it was the it is the current graph which we are working. Now if you want to create a branch now how can we create a branch either we can create a branch from two like branches are like things like if you there is a root node and their branches coming from here and here. So if you want to create a branch starting from one you can just update to one and create a new commit. So let's update to one at the up is a command or update is a command where you can update to existing commits like your working directories on commit number two. So if you will do if you will print a it's if you will print a it's hello world but if you update to commit number one it's commit number one and when you will print a it's hello because you have updated to an all older commit. Did you just notice something different from the get I didn't copy the hash of the commit. There is a revision number revision numbers exist in mercurial yeah and people use them people love them love revision numbers you will see through the whole demo that why revision numbers are so helpful like I don't need to copy the whole hash. So like I am on now revision number one let's let me change something. So let me add a so I add here so this yeah added world in new line okay so created a new head. So the commit is telling me that it has created a new head and when you will look through the log you will see there is a branch over there and now these are two branches. So like these are two heads you can look into the heads you can look into all the heads by using HG heads. So you can see there are two heads now if you want to merge it or rebase it. So let's start with rebase get people are afraid of repase and I will show you how easy rebasing is in mercurial. So you want to rebase two on the top of three or three on the top of two like let's say I want to rebase two on the top of three. So I will do HG rebase my source is two I want to rebase two on the top of three my source is two my destination is three slash the three okay and enter okay okay. So it created no changes like there was no changes different from two to three and repasing it like the two and three changes were similar let's create a different change. So okay so let's commit it okay. Now log looks like this now we want to rebase three on four similarly HG rebase source three destination four and after this the three will be placed on the four. So you can see when I press enter and this so now the change as a added world in new line is on the top of added world to be. So it's rebased you can rebase whole the branches on one on the other or like merge things so it's easy in comparison to get people don't rebase in get very like usually they are afraid of rebasing. So you can rebase easily in mercurial you just have to pass the source and destination you can pass the root node of the whole branch and the place where you want to rebase it and the whole branch will be rebased on the top of the destination commit. So this is about rebase and merge and everything. So okay so enabling extensions the rebase command which I used is not in the core mercurial if you will download mercurial and do HG rebase it will say rebase command not found. So basically what we at mercurial things that we should not provide users with options by which they can like hit on their own leg like rebase is a very useful command but it also like does something which might not be user friendly at some places like users can mess up with rebase using rebase command like they can rebase one thing on the another and like do things which are crazy and like end up in a place which is hard to recover. So that's why we have these commands in the extensions and we can easily enable extensions. We have a lot of extensions if shipped with the core like let me show you so these are the list of extensions like if I will so we have a lot of extensions shipped with core these are all the extensions shipped with core like a history large files patch bomb patch bomb is extension which emails your patches the large files like yesterday one good guy was talking about large files we have this large files from long ago rebase shelf strip and we have a lot of extensions which are shipped with core. So how to enable these extensions simply you can do yeah this was where we were working so to enable an extension you just need to edit a small line in your hgrc your hgrc is a file where you have just like bash rc you place the settings of your bash in hgrc you place the settings of your mercurial so you can have per repo hgrc and even in my global hgrc I will show you my global hgrc so it's like you I've set my UI name extensions so in extent again so yeah so I've set my username faces faces is an different thing we will talk about it later alias is like I've alized few things like whenever I'd output log it should be it should show me a graph instead of a simple commands and in extensions enabled patch bomb here so enabling extension is easy you just need to place the extension name and the path to the extension in case the extension is shipped with core you just need not need to put any path it will automatically detect the path and in case the extension is out of the core just like I have two extensions enabled here you need to just place the path and you can easily use the extension so it's using the extension is very much easy in mercurial so let's talk about the powerful features which are there in mercurial it's they are history editing features like if you are working or working for an organization and you send a series of patches and you and the reviewer told you like I like it's a series of six patches and like I have some review in second patch and you need to change it I will review in third patch and you need to change it what you do in the current world if you're not using mercurial what you do like maybe rebase a man and everything like it's or maybe most like some people just make new commits and push them they don't know how to edit history or they don't have like few weapons to edit the history so we mercurial we at mercurial have a lot of options to edit the history so first we will talk about the evolve extension so let's get so first we'll talk about evolve extension so evolve extension is a very powerful trouble-free history editing extension so I have enabled the evolve extension you can also enable you just download the source code add it into your hgrc and just use it so I will show you how to you how evolve extension is powerful so for example let me update to the parent yeah so for example I have four commits so I want to just let me see just like if you want to see we what commits are there you can just do 2g export 1 0 1 3 4 no 2 5 okay 3 5 okay 4 5 so the first commits was hello the second was hey the world and world so for example you need to just change the first commit you need to change the first commit which was like added a and you added a hello into the a so if you want to just change it to hey what you will do so in using evolve you will just update to that let's make a new tab so using update you can evolve to you can update to that commit okay so we are updated to that commit if you will see a it's hello we want to change it to hey so let's open it so change it to hey okay the def is there you want to amend it into the first commit like you want this change to be in this commit so just do amend and like it's the the commit is there so yeah so the seventh commit is now yeah okay the seventh commit is now I added a in the I added hey in the for a if I but it makes few changes unstable what is this so it made this changes like this was our all older commit which is denoted using x we edited it and new commit is there we just want to rebase it for example if you want to just edit the who added this one also let's add it add added this fourth this first commit all the fourth commit also this one and in we wrote hey there let's change it to hello so if we want to just we want to update to fourth commit yeah so let's update to fourth commit we see B is a world and edit world to be okay so we want to change this one first one or maybe we can change into this okay let's change into this way so I opened B I just removed the this line and change it to hello and okay and I did amend okay so now when you will see the log you will have like okay so it looks scary now you don't know what's happening over here and you don't have idea of it so there is a command hg evolve all which will fix all these things like rebase the things which should be there remove this cross commits and everything and it will give you the working directory or the history which you wanted so it nothing to evolve on the okay so I need to update also I need to update one okay okay so here is a merge conflict and I need to change it to okay so it's saying like on the base on the base commit you add hey and the next commit you add hello world so you need to change the first commit to hello okay so let's look at the log now okay so now you have the same log which was there but you have you will have the changes edited in the history let's see the numbers are 7 10 12 13 7 10 12 13 and you can see that I we change the hello from hey the history changed and this is hey and in the next line we change this from hello this hey to hello world earlier what we did was this commit was like only world like we added only world over here we edited the commit and this became hello world and this commit is like which commit is this wait I did world in a new line okay yeah so this is a that is sorry so the history is edited I guess just okay so like maybe I just to merge something wrong so that's why that world is popping up there so this is the wall extension you can like edit commits behind beneath the stack and do powerful history editing things and related things which you like which you can't do in other version control systems and you have very easy commands left so let's talk about the next one next one is HG absorb like it's a very powerful commander I'm like you haven't heard about such type of history editing tool till now so let's talk about this okay let's make a new repo because so okay so let's create commits okay I want to add a touch the okay so okay so I have three three commits in which I in the first comment I added a and I wrote a to it so okay so all three commits are similar just they are adding different files and with hello in it okay so suppose this was a project that you need to make five commits and five files and write hello in it okay then now for a now suppose what the person who gave you this assignment and come to and say that okay instead of hello I want hello world and this are like thousands of commits and you are like what I now I am going to add world in all these commits no obviously no so there is a feature absorb which you can easily use and do these things like let's see how it works first of all so for example I want to just add world in all these files and it should be it should be there like when I did it it should be here like I did I added hello world not just hello and it should be there present in every commit okay so this one is very easy so let's output everything and okay let's add a add world to each one of them I have added world to a to b into c and this is diff okay so I need this diff to get absorbed in those commits and this world to be present there okay so first of all I need to enable the absorb extension which I have commented out so this enable the x okay so now what I need is like these things should be absorbed in in this like it should not be only hello this should be hello world so what I do is sorry what I do is g absorb and three of three chunks applied and when I will sorry the revision numbers must have changed so the revision numbers are now three four five and when I do three four five it's like wow you added hello world you added hello world and you added hello world so it's like you this is one example of where you are doing history editing absorb works like it takes changes from your working directory which were there in your edge diff and absorb those changes where they should be like it knows where this certain chain should go and where the that certain chain should go so it works like this you can like it can go into the same file with different chunks like if you have it if you have same file and you have two commits which are dealing with different chunks and you need to get absorbed in the same file in to do two different commits absorb works like that also in case you have ambiguous things to apply evolve absorb leaves them in your working directory so this was about absorb it's a extension still not shipped with core because it needs some of like grinding and refining to be shipped with core but it's like a awesome extension which I haven't seen with any another version control system so let's talk further so this was about absorb it absorbs your okay five minutes okay two minutes so this one was about absorb which absorbs your working directory changes into commits it's a very nice history editing tool next one like more powerful tools to help you we have rev sets so rev sets are a functional language for selecting changes or revisions in mercurial so just let me show you so so in mercurial you can do like I want the revisions which are authored by this person which are like ancestors of this like I want like okay so I want the HG export I want the parent I want to see the parent of four so what is the parent of four so I'll do parent of four and it's the parent of four is three and yeah it's three over here so that like you can query revisions according to a functional language which you have over here like well say you do in databases like select star from this this this so we have a functional language which it's very powerful when you work in daily life with revisions and search for change sets which are present there so you have a lot of sorry so you have a lot of features over there like you can you can see which ancestors authors and like there is a lot I am running out of time similarly there is file sets you can see which files are modified on a certain change and like if you want if you have a diff and you have a large if you want only see like modified files you can use the file set and it will return the files which were only modified not I did not delete it and it will like pass on to like so these rev sets and file sets are like query type things and they query the repository and returns you things and you can pass them on to the other commands like log export and everything so this was about rev sets so questions there are more things in the slides so but I am running out of time questions any questions anybody have any questions like how to move your current project from gate to mercurial or anything like how where I can host a mercurial repository I have a question yeah if all your references are integers and numbers and you have others who are working on the same mercurial yeah project how do you how do you merge those changes okay so his question is like revision numbers are there in mercurial some how like a people work someone who is working there have some revision number I also have reason so the revision number concept is a local thing like I have revision numbers over here when I push them the hash goes the change the things works similar to get the hash is there it will it get pushed there so revision numbers are numbered locally like I might be having like when I absorbed or used if all the revision numbers grew up like they the numbers were not just still 0 1 2 3 they were 4 5 6 so when he will pull those chainsets might be like there are already 10 revisions in his working directory and they will be like 11 12 13 so revision numbers are not constant they are not connected to a certain chain set like just like hash there is a hash of a chain set but there is not a revision number of a chain set it depends on the repository where you are working and how how many of other how other how many other chainsets are there so it's not connected to a revision it's used it's very useful when you are working on the local direct local copy copy and you need to pass numbers instead of hashes so it's useful in that case yeah I think if there's anything else we can we can take it out of the session so okay so thank you yeah thank you very much for giving your presentation thank you