 Good morning everybody, hope for a reasonably comfortable time let us try and make it more comfortable by covering more useful day to day stuff. The plan for today is we will discuss version control followed by test driven development. The idea of putting version control first is throughout the day we will use what we learnt in the version control for the rest of the stuff. Originally we had planned to do it the other way then it was my oversight I should have originally planned it this way, my mistake so I said we will do it this way and I strongly urge you also when you teach this course in your classes to do version control earlier so that your students can use this. This is something very important I want to leave you with let me tell you a story from my school days I started life in a tumble medium school and ended up in English medium at a future point of time or the later point of time and we had students who had done convent which means they are studied in English medium from much younger age looking at my beard you can imagine that was pretty long back and not too many English medium schools were around that would be correct because I am talking of the mid 60s got a few probably were in bond in the room. So the tumble medium guys used to get together because the English medium guys will talk in English you could barely write but sooner or later we figured out the guys can talk but they were not really strong in the fundamentals at least we tumble medium guys like to think so because it boosted our ego. So one of the jokes one of my best friends he was the joke of the wit of the class he came up with was one of these English medium boys writes the English exam and goes home his father asked him how was your date we had a good English exam dad but I missed one question which question was that they had asked what is the past participle of thing what did you do thought thought thought thought and wrote thunk. So in that sense the guy could use the word thought but never connected to the other things the same way many of the tools we teach many of us have a similar compartment in our head this is for teaching this is something I use I very very strongly urge you to remove that limitation the tools you use we taught here are usable day in and day out of your professional life as a teacher and if you do any research work as part of your research work and if you are writing any articles as part of writing articles take latex for example similarly version control and similarly python just to give you are the bad scripts for example do not put them in a separate compartment as subject matter to be taught they are extremely useful and usable tools to give you an example from yesterday you might have noticed I was sitting next to professor Kandan yesterday right professor Kandan was looking for one tech file he had prepared few tech presentations he wanted to pick some slides from an earlier presentation now professor Kandan so the world live it and breathe tech and they live and breathe presentations so every other day he is presenting to some audience somewhere so there were hundreds of tech files in his directory so how does he locate that file he wanted so you learnt about grep so he said you know what I can grep for that file but there will be many such files what I need is a chronological listing of all these tech files which contain that phrase he looked at me and said how do I do this I typed a one liner which used grep cut and back ticks and ls-lrt is that good I will remember this this is one of the reasons why I am very passionate about repeating this point if you do not see what is before your nose this will remain something you teach but you look at text processing as what you do day in and day out that is what you do you find you look for something you call some phrases some data from two different files put it together this approach of using tools is something that should permeate your way of doing things day in and day out to give you another of my favorite jokes for this how many of you are fond of Laurel and Hardy movies I am I love them so there is a you know who Laurel and Hardy is I suppose okay there are one of the famous 20s Hollywood comic duo Laurel is very thin and Hardy is very stout and they are thick friends they generally get into trouble together and model their way out of trouble that is the literally the script for every one of their movies and whatever Hardy does ultimately we end up in disaster and trouble Laurel is a lot better he will always start with it there is no ending in trouble it starts in trouble so in one of those movies they are caught in the depression Laurel and Hardy made a lot of their movies during the American depression when everybody had was jobless was without food running around all over the place so they will have one car everything of their life will be in that car they will be going from place to place hoping to find some work and food they will have a placard will work for food types so their movies made a big hit because they are related to what was happening at that time anyway in one of the scenarios they will end up in a construction site and they will get some work so as is usual in these scenarios the man who hires will make Hardy the boss and say you get all these fellows to work and these all have to be done and he will go away so Hardy will happily come and say there will be huge pile of bricks move this bricks from here to there Laurel will make the same as trademark face pick up one brick walk put it come back pick up one more week you will do it for five times Hardy will come back in his rounds you will say pick up a shawl hit him on his head tongue and say use this Laurel will be thank you put the shawl here take one brick put it on the shawl and walk that's how we use tools the shawl is not meant to be held here and carry one brick at a time please look at all the tools we are teaching we have taught in a very holistic sense they were not picked up by some syllabus forming committee which was no clue what is being done by people using computers day and layout of their lives the content was designed by myself professor Prabhu and Madhu and we use these day for our jobs and we three do very very different jobs Prabhu is predominantly into building new systems for aerospace data processing and that's humongous amounts of data processing parallelization of algorithms very large volume and data sets visualization of huge amounts of data that's his fault and in addition he works on Mayavi which is probably the world's best open source 3D visualization kit Madhu was in no works in the electrical side and he has a few other areas of interest I am an application developer and trainer for example I teach people fresh engineers for their first job my typically every other day I'll give them an assignment they have to write a Python program which I have to grade I can't automate the grading because it is not enough to say it works not work I would read through the code and give them some useful comments so what do I do I'll open the code in my editor make some comments with a special tag two hashes followed by a colon then I'll write something and if I see one mistake for which I believe some marks from 10 if each question has 10 marks has to be reduced I'll say this is this minus 2 for this mistake and plus 1 for this idea finally I'll have so these will have hash hash colon grade plus 1 minus 1 finally hash hash colon final grade with a lot of comments my directory will be full of this and I will ensure each person names is answer with his name hyphen whatever that's the name of the file then I write a bash script which will assemble this into a file a person name followed by the comments I have given whatever grade it will total up print the final grade I have a grade sheet ready bash Python latech I have my report automated this is not to say how good I am it is how good to explain to you how good the tools are you start thinking in terms of using the tools then you will find you are doing things very very much differently the same way as we talked about yesterday about why open source is important because it engenders a certain mindset similarly using these tools is important because of the mindset your automatically you start doing things better okay version control is one such what is the idea behind version control to quote yet another tried saying change is the only permanent thing in life whatever you want to do somebody will come and ask for a change if you have a boss chances are very high he has a exact opposite opinion of what you should be doing then what you did if you have two bosses they too will have exactly different opinions of what you should be doing between each other and you so this is true for documents this is true for code so whatever we are discussing as by way of version control is true for anything you want to build be it a document be it a program traditionally we discuss version control in the context of code but nothing restricts it to be used only for code in fact there is lot more profit lot more use for us to use version control for documents to give you a simple example let's say there is a syllabus version 1 going back and forth version 2 version 3 added changed now after about three weeks of back and forth you want to know something you want to answer questions such as what was the difference between version 3 and version 4 how do you answer such a question normally you can't what will you do because you would have edited the same file or you would have overwritten one file or if you are a little meticulous you would have called the file version 1 version 2 and sometimes you would have edited version 1 with 1.1 detail sometimes you would have called it version 1.1 because we are not consistent that way or somebody else would have edited and sent you back now you what do you save it as you will save it in the same name or save it as Ashokan does us so effectively you are caught in this thought thought thought and wrote tongue technology version control answers helps you answer these questions comfortably what is version control essentially the tool takes over maintaining different versions tracking what is the change plus builds tools on top so that you can do things like you know what I want whatever changes we did in version 2 3 and 5 I want a document which incorporates all changes made in version 2 3 and 5 but not 4 you can produce such a document automatically so these are the reasons why we look at using version control is the idea clear and we would expect you to use it almost automatically now there are two clearly different ways of looking at version control the our goal in introducing this in the syllabus is for you to use it as a personal system but it can be done at a lot bigger level let me explain what I mean by a personal system and let's add on what is the larger picture personal system is the scenario just now we described you have a few documents you want to keep track of changes that's it some changes may come from others but you are not really worried about working with a team of people on the same document which is true most of the time if it is documents for source code though there is a slightly different story different people will edit different parts of the source code but for documents most of the time in our day-to-day work we are responsible for the document others may suggest changes but we have to make them and maintain them so somebody may ask for a can you add this can you remove this type we are going to do it so this is the simpler use case we will talk about this first and explain how to do it the more complex interesting use case is what is called distributed collaborative uses there there is a central repository again it doesn't matter whether it's a code or document and different people work on it there is a very funny way there's no real central repository but for convenience we think of it as a repository so what you do you want to do something you make a copy you make changes as you see fit and then you say okay push it back to the central repository the changes get in somebody else then picks up they get the new version if they have picked up before after you pulled your copy and before you updated they will get the older one but the system will want them somebody has edited afterwards when you check it back in someone else picking up later can either get the later version previous version so all these are additional features available let's take the case of the most famous distributed development known in the world the Linux kernel millions of lines of code thousands and thousands of contributors and a few commitors how does it work same way anybody can copy the code make your own changes but when you push it back somebody reviews it and finally it gets patched in so there is a copy of the Linux kernel source code with everybody there is one repository different people load it update it push it back the system is maintained this is the more complex use case the tools we teach will make both very easy to use but we will focus more on the simpler use case let's formally define what is a version control system version control system is a software tool that gives you a mechanism to track changes made to files over time note the general comment files could be documents could be code it keeps it does it by keeping copies of the files what's a big deal I also keep copies but you name them but you don't care about naming them here there is always as far as you are concerned it shows you only one copy but it keeps everything else with the mechanism to pull back earlier versions this is our what we call home group version control system you have one one two three you have four files let's say I have written a C program which is split into three files each one will have a different version you would have made changes so we do another two things we have huge bodies of code commented why we comment code comment out code we don't know you may need it later but in a version control system you don't bother you simply delete it why you can pull it get it back the next time so the code represents current thing in this homebrew system you have an ID 1 ID 2 PDA 1 PD 2 now which particular combination is the final built system nobody knows so this is what we do and the problems like we already noticed are name and changes what is the meaning of ID 1 and ID 2 what is the difference there is no real way to find out other than physically reading the two files I mean what were the changes made from one to two what are the changes made from two to three knowing the difference between one and three is not just enough what is the history of the changes you can't find obviously if you're talking of hundred files there is no way you will ever be able to do this and manage forget hundred even ten this is a good example to remember if any of you play video games you know you can save the state somewhere continue to play you know you have three lives you save it then you go do something experimental and you get blasted you come back restart from there washing control idea is very similar you save all known good states we happily that someone else will keep track of the good states the specific tool we are going to use is mercurial one of the major reasons being it's one of the easiest to use modern distributed version control systems in fact today you will find 80% of the people end up using either mercurial or get both are similar built with two different philosophies built in very very different styles but mercurial for us has one more advantage it's written in Python which means it also is an excellent example of good Python code if you want to read how to build complex systems mercurial code is one of the considered one of the best written examples for you to study now we presume there is a repository with you sorry the mercurial has already been installed so what is that we will do let's highlight the steps then we will go through that ourselves first you need a repository what is a repository it is mercurial way of saying this area or this combination of documents files is something I am supposed to be responsible for you will have hundreds of files in the thousands of files in hundreds of directories all over your system so you have to start by saying I want this to be one I want to track you can have multiple repositories for example you will have different tasks you may be part of one committee where in the college you are maintaining maybe you are responsible for the technical festival again peak R this that there will be 10 documents flying around you obviously don't want to confuse that with something else so we can have any number of repositories so we need to know how to create a repository let's try and list out based on common sense what we need then see what the commands are we need to be able to create a repository then you must be able to add a file to the repository correct this is my repository and now this contains this file I must be able to say that then you must be able to make changes to it if there are multiple files you must be able to check the status what state are these files and what state could they be in they could be just created modified but not updated please remember the repository is a logically distinct entity it contains all the files when you are working on you are working on a copy so if there will be a difference of state between the copy and the repository so that you should be able to find out update this is about all we need to know 80% of your work will be involving these four five things to do correct all other things are the paradox other 20% which may or may not be interesting or useful but will be used once in a while we will go through a set of steps okay since we are going to do it in a particular order I suggest you look at it and then repeat it in your own system then we will discuss each of the steps very unimaginative I create a new directory called VC obviously that's a terrible name you should be using something which is more relevant to the project you do okay now we have an empty directory yes technically a repository is a directory for each repository you have to have a separate directory because this is where you will be bringing in files and so on and the version control system will keep hidden files and that name is the same so you create two repositories in the same directory you will have a problem yeah that's an important point maybe I should have made it a lot more clearly every repository is a separate directory so you create a new directory and there you initialize instantiate a repository alright so as you can see this is empty this directory is empty right let's convince ourselves it's really empty there are no hidden files even okay now we create a repository by HG init the commands are always HG followed by an action okay and if you ever come across git it will be identical git followed by an action the key difference is HG is a single file git is some 10 20 different files but they are equally easy to use okay let's do HG init what happened nothing happened which is typical of the Unix philosophy if you have nothing to say don't say it HG init succeeded that's it you will rarely if you have looked at Linux and bash this is something you will find many commands won't tell you anything copy command you want to copy a to be it will copy if you're used to the old DOS and Windows way of doing things it will give you one blow on trumpet and say three files copy none of that will there is nothing to say don't say it so HG init succeeded so there is nothing to tell you you wanted me to do something I've done it but exactly what was done a hidden directory not hidden by a great technology but by convention with the dot as the first character of the name of the directory has been created this is to show you what is happening so that you understand something happened when HG init was done but it is a very bad idea to go poke directly inside the directory alright in other words when you learn how to drive a car you do it by looking at the steering not by taking a cutting player and manipulating the steering column right same way you rather use the steering so use the commands don't try to go directly and do anything in there now what happened that's a repository which means mercurial can track changes in other words you have told mercurial in this directory I will make some changes and you are expected to keep track how does mercurial know that this is a repository so is there a master list of all repositories somewhere no if there is a dot HG file HG directory then it's a repository so when you run a HG command it will check whether there is a dot HG file that's all so he does not remember everything that happened everywhere in under mercurial all that is inside HG okay so now let's add a document which document we created one python file yesterday the curve script right not exactly a great thing but let's use it to make changes I will so I start by copying now my directory has this file please wait don't do many things till don't do piecemeal when a logical action is complete you could do that I have just copied it so that I have something to work with now please remember this is now not tracked it simply happens to be physically located in the same directory because mercurial knows what it is tracking only by bookkeeping data it writes inside that dot HG directory and we have not told anything to it always told mercurial so far is there will be a depository here depository here fine copied a file into that directory well we started by saying there is a directory associated with each repository a directory on the repository or two distinct entities now I actually want this file to be part of the repository in other words I want mercurial to take over management of different versions of this file how do I do that HG add now we have told mercurial I want you to keep an eye on this fellow actually it is a little weaker than that what we have told mercurial see that chap remember that fellow I want to tell you something about him that's all we have said it is not yet tracking it simply is said I tell you something about it that's all we have said now let us look at what is the status of the repository you see a before that it says okay I mean told something about this to watch out now we actually say you know put it into the repository say HG please don't type yet commit it's fairly easy to remember the commands you don't have to memorize them yes that it is added we'll give you a list of status in a minute we'll give you a list of status in a minute just want to do a quick bird's eye view then go back and fill up the plan so if you say commit it will actually complain what do you mean commit I don't know who wants to commit if you're not going to tell me who's going to commit I'm not going to commit so this tells you okay mercurial expect things to be done in a certain way what do you mean by commit actually register into the repository the changes made to the repository so far what change have we made we've added a file to the repository now we are like I said earlier we only said keep track of this fellow I want to tell you something about him now we are saying I want you to commit all changes it's saying who are you first what's your authority because one of the tracking is who made what changes so how do we say who the user is there are many ways but the simplest way to start with since the error occurred in commit type hg help boom it goes this big so we don't want this big a help not very useful let's look at hg help commit many things have gone up so we'll probably use manhg so you can see these are the commands we just showed you add and we are struggling in it and add and we are still figuring out commit so let's look at commit to understand there are lots of commands as you can see but it complains something about a user we see an option to commit you are supposed to say hg commit minus you are minus minus user name okay okay let's keep this open in one and say hg commit minus minus user since you are running it for the first time it is telling us please select an editor we need an editor because every commit you are supposed to commit with a message not really message essentially a summary of this is what I did this time so that you have to type and for that it requires to use an editor so it allows you to in unix there is a way to keep track of all the changes you do using a diary or script or something in in Linux is it there yeah there is that that's essentially what all commands you did on the screen that's what you're talking all the transactions how do you record it yeah there is a remember I remember I know it I used it okay I have also used it but many years ago I thought yeah if I initiate that for many people will actually be something will take after five minutes yes but you will also easily find out script works yeah script you say script I said script yeah and hit enter then it will do but that's essentially logging it's a log logging whatever you did on the screen idea is you can replay later that's right okay let's get back here we are it is asking you to select an editor and it's also giving you a hint if you don't know what an editor is the easiest fellow is nano but then we are not at least going to settle for nanos we'll buy a BMW okay now again you see it gives you a set of this is a file ignore all this this is simply an editor okay this is the commit message now there is a default commit message it is giving you idea is you can simply delete a few things and some stuff is already typed now if you have made a mistake and you don't want to commit you don't make any message now it will not commit which you can read it says enter commit message lines beginning with HG colon or remove leave message empty to about commit if I close the file now this is the message file commit will be about it let's do that that's it about it due to empty commit message in other words you can't push a change in without making a comment about what you're pushing okay so let's start again but notice this time it doesn't ask you what editor to use it's already tracked it inside that he dot HG directory it has made a comment somewhere that this Johnny prefers to use emacs now typically what one will do is delete these three okay this is the message I want to give I don't understand this branch-grant business so I will delete this I believe is a reasonable set of things to say for my comment it's me and I have added this curve underscore script dot pi to the repository now again you see no message then about that it had something to tell you I have about it now it has committed everything is fine so nothing to tell you so it won't tell you now let us look at status nothing to tell you everything is fine in other words nothing hanging around there is no uncommitted file there is no half way commands earlier what did we say may or not of this fellow I want to tell you something about it so mercurial made a note and it said you told me something you will tell me something you haven't said it now there is nothing there is no pending business so as far as mercurial concerns status is fine nothing to tell you but actually we have made changes to this how do I look at that how do I look at what changes have been made how do you think what do you think is likely to be the command make a guess a G let's try log that's all this change set number don't bother about it because it's something it is internally keeping track summary this is the summary I typed so now I learn actually I don't have to leave that user Pashokan there as a comment it is not really useful because anyway the log is keeping track of who made the change so okay next time we write a comment we will not add it now let's make some changes make some changes to what to the file we are interested in this is the file actually there is a mistake in this I was showing you many things but that SP is should be changed to sci-fi right so let's change it to sci-fi but again mercurial won't complain when you save edit that's not their department now mercurial tells you boss you told me to track some Johnny that Johnny has changed him for modified he's doing something suspicious so after you make a change to the file mercurial when you ask it for status says modified now let's look at the log no change in the log because log tracks changes to the repository what all you have done to a file in the repository status is because you can decide not to make this change this is simply telling you compared to what I have in the repository the file you have here there is a change that's all but the repository is log states what all happened to the repository status tells you what is the state difference if any between the content of the repository and your copy so where is this my copy business your copy is in the directory where is your repository it's also in a complicated way in the directory itself which is why I was a little reluctant to commit to directory equal to repository but let's stay here for a minute to understand log tracks what all happened at different points of time in the repository you have a copy of those files in your personal directory let us say that the difference between the current state of those files and the state in the repository is what status tracks so if they are the same status as nothing to tell you but log will always have something to tell you because log is list of all things that happen to the repository well status is the difference between the current file you have on hand and the repository so it is modified now what do I do actually this is a useful change so I want to commit it correct so how do we commit that we already know they should be familiar now to give to help to be helpful it gives you changed so now I know this user pasokin is not really required so changed is not very useful instead I will say replaced SP dot psi pi dot now look at the log you see two log entries original creation this is the latest look at status nothing to say because copy you have on the repository or in sync there is no difference now we are literally done with 80% of what you need to know about mercurial and version control this is all that's there to work you can change it I'll tell you you have to read the manual there is a there are three ways I think you can in move in a g command line you can change it can change it for a session or I think you have to walk into the dot hg and it which is not a recommended way I'll tell you the method in a minute just have to look up the manual I never changed it I know it can be done but I have never done it all right this is what you'll be doing 80% of the time in it add commit what else we said we need to do log gives you history of changes update we saw commit adding something to repository is add we saw that that's all this is the most useful use case as an individual now it is like having an automatic backup for yourself what do you mean I removed that file I had now what is the status was there is something missing you're supposed to have a file or in other words the repository has something which you don't have how do I get it like I guess the nicest thing about the command line is recover is a meaningful command but it seems to be talking of something obligated not what do you want sorry let's try that boom restore seems to really make it angry what is it saying these are the basic commands add annotate clone commit diff export forget that's a forget command in it log merge pull pull changes from the specified source that looks interesting right let's try pull so how do I get it back clone okay I'm going to do something else I'm going to create another directory I created a new directory and then said clone the repository in VC so if you delete that entire directory with the HG nothing can be done the reason I did it this way is to show you something to lead you on to the next thing now let's look at what is here so you have a directory called VC inside this that contains curve script even though remember the directory didn't have VC in it sorry curve script in it right the VC directory didn't have it but in a clone it the repository recreates a file and puts it back now let's also look at you see there is a dot HG even in this VC directory but also note in the original VC directory which we just now vacated to come here there is no dot pi file so when I clone I'm not copying a directory I'm recreating a working directory and the repository that's why the command is clone that's why you can't just do a CP and expect to get it let's take a minute we did this on the local machine we talked about distributed collaborative thing there instead of from VC you will put it somewhere on the web and do that's it so you start becoming part of a project by running HG clone so you have a local copy make changes commit do add then push pull all of that to interact with that but you are not going to do that most of the time want to work in a single repository so let's go back to I've gone back to my old repository recreated it so that we can revert to what we are doing so this is the state of the repository so even if you delete everything by mistake as long as the dot HG file is there you can get back everything which is the whole idea and so far you have been fiddling around with a single file but obviously the same thing holds for multiple files we'll see that in a minute but let's keep things simple we did with a single file let's summarize by looking at these slides see what you have to say we'll go through this HG unit creates a fresh repository it essentially creates a dot HG directory inside that directory where you create it HG status sorry if the session is oh yes 100% I should have thought of it I should have shown it to you anyway I'll remember for the next workshop thanks there is nothing magical about it it simply in dot HG it has written everything it requires in a certain sense the implementation is nothing very esoteric whatever you have done there is a copy being kept inside dot HG unit command does this status tells you this you can say HG help commit we saw that how to get and the status code we ask this question when you look at status M says there is a change between the repository copy and the current copy A says in the current directory working directory something has been added that which is not there in the repository or says you have removed something here she says clean I haven't seen clean so far question we saw that exclamation mark question mark says not tracked what do you mean by not tracked I says ignored lot of things for a status let's go back and do something to see what can be done okay let me create a file okay I made a note of Samir's idea now that is there in the current directory so what does the current directory have it has two files now let's try HG status question mark why question mark it's not tracked what do you mean not tracked we haven't told mercurial you are interested in it but it happens to exist in the directory so question mark if you have not told anything it will put a question mark if you have told it will say you have told me to keep an eye if it is but please note the curve script is not up because its status is the same it's in sync now this is on I like adding I can say don't bother with this fellow in which case it will show as I question mark says you haven't told me anything A says you have told me to keep an eye I says you have told me not to bother okay so in your multiple files you will see different statuses all right so question mark can move to A or I this can go to when it is missing where is it missing in the current directory it's there in the repository if you actually want to remove in the repository also you have to give an HG command HG remove command at which case it will say okay I will remove from the repository and then the status will be not exclamation mark but R says there is a file there in the repository that file is not there in the current directory and you have told me to remove that fellow in the repository also but not yet removed like add does not add remove will not remove you have to commit to make the action happen all changes to the repository have to be done by issuing the commit command add remove tell you what you plan to do to the repository commit says do whatever I have told you to do so it's always a two-stage process HG add followed by HG commit HG remove followed by HG commit understood one addition in this slide instead of opening an editor you want to type something you can say HG minus you name minus M within quotes you can type the commit message there itself so that way you don't open up the editor and all that generally not recommended accepting for very minor things you fixed a comma or a full stop or one swelling mistake other than these things it's a good idea to write reasonably detailed explanations because that's what status will tell you that's what the log will tell you okay okay how do I have to type minus you my name every time when it is my personal repository there is a dot HGRC file where you can set the editor also can be set there okay HGRC is in the op section in HGRC you can create username you notice the HGRC file consists of what is this Python code so the when you run HGRC actually what has happened is it just executes this Python code this is Python code only this is the standard these days many Python packages use the configuration file is nothing but Python code with minor changes okay in HGRC there is a section called UI in that there is a editor but your bash environment variable editor itself is enough you have to create one an apple you have to create one or it's not simpler simply say export editor equal to WIMP you wanted WIMP right I thought you are a Emacs person okay fine if you say export editor equal to WIMP in your dot bash RC it will in other words all edit all commands that look for an editor generally use the environment variable dollar editor to check which is the editor to be used okay let's verify that works what the editor I used was Emacs right I am adding notes now let's look at status notes is added so to open nano it has opened a new editor huge both are extremely powerful editors okay they both new key thing is power both are extremely powerful editors and it's a very good idea to learn one of them very well and it's a very good idea not to ask such questions with the other guy they will fight because it's almost religion there are many religions in the Linux world Emacs versus WIMP KDE versus like that but at a technical level there is certain class of different Emacs is a modeless editor meaning whatever you type is either a command or gets added to the buffer VA is an editor with a mode in other words when you type I in Emacs it will either make something happen or put I in the buffer right since I is a normal character it will only end up in the buffer but in VA or WIM depending on the current mode if you are in the command mode I is actually a command if you are in the entry mode I actually adds to this so the same key can result in two different actions that's what you call a mode an editor with modes and VA is the canonical example of an editor with modes now some people can't even ever accept that it's very difficult for them the advantage is of using a mode approaches it will work on very simple keyboards and VA was designed in the era of very very simple keyboards putting it the other way around and a disadvantage with Emacs of the world is for every command you want a keystroke you have to find some keystroke which is not ever going to be entered into a file control XP control XS to save a file in VA you will hit escape now we are in the command mode say colon W that saves a file because the mode is changed you can use ordinary keys but in a modeless editor you have to use keys which normally won't end up as being required or control character so that's a key operational difference other than that if you use either editor well you are way ahead of anybody else one of the two is a very good addition to your tool but using it well is something which takes a lot of effort and time to give you a very simple example in VA it is child's play to replace one word with another word only in those lines where a third word occurs those sort of things are child's play I'm sure equally in Emacs people can do something it's very easy to write there are add-on tools which have been written so you can type a few letters and it will automatically if you have if you create a latex documents you know there is this begin itemize end itemize you have to type so much so with a simple key you can ensure there is a begin itemize end itemize and the cluster ends in the middle with a item you know begin itemize end itemize item that much can be typed in one key stroke that much is possible all right so I don't know whether you notice this I simply did this obviously it's only for a session you can add it to your bash RC bash profile whatever your yeah then it's permanent all right this already we did it's a very good idea this we didn't focus on really to have a certain structure for your commit messages I simply type on or two lines so good idea to type one line as a summary and long longer paragraph it will the status by default will always log by default will always show the that one line this tells you some of the other things that you can do once you have started adopting a version control let's say you have made a lot of changes to the current file you realize this whole new algorithm you are trying to implement is totally wrong now you can do undo undo undo undo in your editor if your editor has undo or you can exit the file say a G robot all or you can robot a file name so that it only rewards that single file so this is the advantage of using version control to do certain stuff these are minor advantages commit commit is a reference point it's always commit is a reference point thanks last changes from the last commit that's because if you look at your status what does your status say modified compared to what compared to previous commit for example if I go back let's do that to understand thanks for that instructive question let's do something which should be interesting these are the files and what change did you make we made this from this is actually the version of the file which was there before right it only tell you modified it will tell you actually you have now gone back to the earlier version because the reference point is always the last commit now you see it has saved the file and got you back what it was earlier let's look at so sci-fi instead of SP because you said revert all the changes the SP is here so if you made a large number of changes in the editor you decide no I want to start with that again you can do it at the version control level rather than an editor level but I rarely use but some people share by it I generally don't find the need for it okay we'll take a stop here what I suggest create a directory right and choose a problem okay let's look at diff and then do that sorry I wanted to talk about this okay I don't want the script to show I wanted to save so how do I save it says this line was added this line was deleted what is all this the plus says that line was added minus says that line was deleted it is giving you context simply saying this line was added this line was deleted sometimes is not meaningful unfortunately I played around with the last line so the only context it can give is lines before normally it will give you few lines before and a few lines after but since I edited the last line it was showing me these are their last four lines these were the original and this is the change made so diff allows you to see what is the change made okay now let's also look at you can check the difference between specific versions diff gave between the last two but if you have a large number of changes I haven't created large number of changes but you can see it's fairly straightforward HG diff R1 R2 says between revision 1 and revision 2 by default diff will give you between what is here and the committed one but you can also look for the changes between two commits like R02 tells you the log for those two and so on so you can use version numbers to track changes okay this will probably be 95% of what you will ever do as a individual repository handling person in North Korea let's remember commands are very simple in it to create a new repository add to say I want to keep track of this from now on commit to finalize the changes revert revert the changes from between to the previous commit diff helps you see the what is actual difference log tells you the list of changes that are made and with multiple files you can see different files also will be given in the log it's a very simple system instead of trying to remember the commands you should try to look at the actions because the manual is a little confusing because it goes through systematically all the options so it's a overwhelming thing instead look at what is my workflow what do I do and look at what are the commands I need whenever you come across a new situation at that time you read the manual and try to figure out which command and add it to your repository your personal repository of knowledge don't try to read the manual for all options you will fairly find it next impossible to learn something that way you start with in it add commit and every time you need to use a new command you need a new command look it up