versionControl/vcs.tex
changeset 83 c52c9a615356
parent 81 3d20090b7cbd
child 84 535151a16560
equal deleted inserted replaced
82:1d623f8d52a3 83:c52c9a615356
   128   \begin{block}{From a blog post}
   128   \begin{block}{From a blog post}
   129     ``Version control (or source control) is nothing more arcane than keeping copies of ones work as one make changes to it.''
   129     ``Version control (or source control) is nothing more arcane than keeping copies of ones work as one make changes to it.''
   130   \end{block}
   130   \end{block}
   131   \pause
   131   \pause
   132   \begin{block}{}
   132   \begin{block}{}
   133     It is better to use these tools rather then wasting creativity to invent VCS which have files with names like \begin{color}{red}{prog1.py, prog2.py}\end{color} or \begin{color}{red}prog-old.py, prog.py.\end{color}
   133     It is better to use these tools rather than wasting creativity to invent VCS which have files with names like \begin{color}{red}{prog1.py, prog2.py}\end{color} or \begin{color}{red}prog-old.py, prog.py.\end{color}
   134   \end{block}
   134   \end{block}
   135 \end{frame}
   135 \end{frame}
   136 
   136 
   137 \begin{frame}
   137 \begin{frame}
   138   \frametitle{Motivation behind such tools}
   138   \frametitle{Motivation behind such tools}
   141   \item To collaborate effectively on a project.
   141   \item To collaborate effectively on a project.
   142   \item \begin{color}{red}``To err is Human''\end{color} \pause for recovery we have ``Version Control''
   142   \item \begin{color}{red}``To err is Human''\end{color} \pause for recovery we have ``Version Control''
   143   \end{itemize}
   143   \end{itemize}
   144 \end{frame}
   144 \end{frame}
   145 
   145 
   146 \begin{frame}
   146 %% Introduction to how logs are managed in VCS.
   147   \frametitle{How is done What is done?}
   147 %% A analogy in logs and day-to-day life?
       
   148 \begin{frame}[fragile]
       
   149   \frametitle{How does it work?}
       
   150   It can roughly be related to Computer/Video Games.
       
   151   \begin{itemize}
       
   152   \item We play games in stages.
       
   153   \item We pass a stage/task- \begin{color}{red}we SAVE the game.\end{color}
       
   154   \item We resume playing from there onwards.
       
   155   \item In-case we want to replay or revisit some particular stage, we start from position we saved earlier.
       
   156   \item Even we can change the course of play henceforth.
       
   157   \end{itemize}
       
   158 \end{frame}
       
   159 
       
   160 \begin{frame}[fragile]
       
   161   \frametitle{Better way to say:}
       
   162   \begin{center}
       
   163     \includegraphics[height=2.5in,width=2.5in, interpolate=true]{mario}
       
   164   \end{center}  
       
   165   \emphbar{VCS provides power to save and resume from a stage.}
       
   166 \end{frame}
       
   167 
       
   168 \begin{frame}
       
   169   \frametitle{How is it done?}
   148   \begin{itemize}
   170   \begin{itemize}
   149   \item It keeps track of changes you make to a file. You can improvise, revisit, and amend.
   171   \item It keeps track of changes you make to a file. You can improvise, revisit, and amend.
   150   \item All procedure is logged/recorded, so you and others can follow the development cycle.
   172   \item All procedure is logged/recorded, so you and others can follow the development cycle.
   151   \end{itemize}  
   173   \end{itemize}  
   152 \end{frame}
   174 \end{frame}
   171   \item git
   193   \item git
   172   \end{itemize}
   194   \end{itemize}
   173   \inctime{10}
   195   \inctime{10}
   174 \end{frame}
   196 \end{frame}
   175 
   197 
   176 % Introduction to jargons 
   198 % Introduction to jargon 
   177 \section{Learning the Lingo!}
   199 \section{Learning the Lingo!}
   178 
   200 
   179 \begin{frame}
   201 \begin{frame}
   180   \frametitle{Common jargons: Basic setup}
   202   \frametitle{Common jargon: Basic setup}
   181   \begin{itemize}
   203   \begin{itemize}
   182   \item Repository(repo):\\
   204   \item Repository(repo):\\
   183         The folder with all files.
   205         The folder with all files.
   184   \item Server:\\
   206   \item Server:\\
   185         Machine with main inventory/repo.
   207         Machine with main inventory/repo.
   192   \frametitle{Actions}
   214   \frametitle{Actions}
   193   \begin{itemize}
   215   \begin{itemize}
   194   \item Add:\\
   216   \item Add:\\
   195     Adding file into the repo for the first time.
   217     Adding file into the repo for the first time.
   196   \item Version:\\
   218   \item Version:\\
   197     Version number of a file.
   219     Version number(Die Hard 4.0).
   198   \item Head/Tip:\\
   220   \item Head/Tip:\\
   199     The latest revision of the repo.
   221     Most recent revision/stage.
   200   \item Check out/Clone:\\
   222   \item Check out/Clone:\\
   201     Initial download of repo onto machine.
   223     Initial download of working copy.
   202   \item Commit:\\
   224   \item Commit:\\
   203     Recording a change.
   225     Saving(recording) a change.
   204   \item Change log/History:\\
   226   \item Change log/History:\\
   205     List of changes made to repo.
   227     List of all past changes.
   206   \end{itemize}
   228   \end{itemize}
   207 \end{frame}
   229 \end{frame}
   208 
   230 
   209 \begin{frame}
   231 \begin{frame}
   210   \frametitle{Actions cont...}
   232   \frametitle{Actions cont...}
   211   \begin{itemize}
   233   \begin{itemize}
   212   \item Branch:\\
   234   \item Branch:\\
   213     Separate local copy of repo for bug fixing, testing.
   235     Separate local copy for bug fixing, testing.
   214   \item Diff/Change:\\
   236   \item Diff/Change:\\
   215     Finding the differences in a file in two versions.
   237     Changes made in a file in two different versions.
   216   \item Merge (or patch):\\
   238   \item Merge (or patch):\\
   217     Apply the changes to file, to make it up-to-date.
   239     Appling the changes to file, to make it up-to-date.
   218   \item Conflict:\\
   240   \item Conflict:\\
   219     When merging a file is not obvious.
   241     When merging a file is not obvious.
   220   \item Resolve:\\
   242   \item Resolve:\\
   221     Fixing the conflict manually.
   243     Fixing the conflict manually.
   222   \end{itemize}
   244   \end{itemize}
   225 % Types of Version Controls
   247 % Types of Version Controls
   226 \section{Types of VCS}
   248 \section{Types of VCS}
   227 
   249 
   228 \begin{frame}
   250 \begin{frame}
   229   \frametitle{Types:}
   251   \frametitle{Types:}
   230   Based on way of managing the repo there are two types of VCS:
   252   Based on ways of managing the repo there are two types of VCS:
   231   \begin{itemize}
   253   \begin{itemize}
   232   \item Centralized VCS\\
   254   \item Centralized VCS\\
   233     cvs, svn falls under this category.
   255     cvs, svn fall under this category.
   234   \item Distributed VCS\\
   256   \item Distributed VCS\\
   235     hg, bzr, git follows this methodology.
   257     hg, bzr, git follows this methodology.
   236   \end{itemize}
   258   \end{itemize}
   237   \emphbar{We would be covering \typ{hg}}
   259   \emphbar{We would be covering \typ{hg}}
   238 \end{frame}
   260 \end{frame}
   242     \includegraphics[height=.75in, interpolate=true]{mercurial}
   264     \includegraphics[height=.75in, interpolate=true]{mercurial}
   243   \begin{itemize}
   265   \begin{itemize}
   244   \item Easy to learn and use.
   266   \item Easy to learn and use.
   245   \item Lightweight.
   267   \item Lightweight.
   246   \item Scales excellently.
   268   \item Scales excellently.
   247   \item Based on Python.
   269   \item Written in Python.
   248   \end{itemize}
   270   \end{itemize}
   249   \inctime{10}
   271   \inctime{10}
   250 \end{frame}
   272 \end{frame}
   251 
   273 
   252 % Initializing the repo, cloning, committing changes, pushing, pulling to repo.
   274 % Initializing the repo, cloning, committing changes, pushing, pulling to repo.
   328 $ hg clone Fevicol Fevicol-pull
   350 $ hg clone Fevicol Fevicol-pull
   329 updating working directory
   351 updating working directory
   330 0 files updated, 0 files merged, 
   352 0 files updated, 0 files merged, 
   331 0 files removed, 0 files unresolved
   353 0 files removed, 0 files unresolved
   332   \end{lstlisting}
   354   \end{lstlisting}
   333   \inctime{15}
   355   \inctime{20}
   334 \end{frame}
   356 \end{frame}
   335 
   357 
   336 %% Should we here stress on how are distribute VCS have 
   358 %% Should we here stress on how are distribute VCS have 
   337 %% different approach then centralized ones? Maybe a pic
   359 %% different approach then centralized ones? Maybe a pic
   338 %% or some other graphical representation.
   360 %% or some other graphical representation.
   339 
       
   340 %% Introduction to how logs are managed in VCS.
       
   341 %% A analogy in logs and day-to-day life?
       
   342 \begin{frame}[fragile]
       
   343   \frametitle{How does it work?}
       
   344   It can roughly be related to Computer/Video Games.
       
   345   \begin{itemize}
       
   346   \item We play games in stages.
       
   347   \item We pass a stage/task- We save the game.
       
   348   \item We resume playing from that point.
       
   349   \item In-case we want to replay or revisit some particular stage, we have it saved.
       
   350   \item Even we can change the course of play henceforth.
       
   351   \end{itemize}
       
   352 \end{frame}
       
   353 
       
   354 \begin{frame}[fragile]
       
   355   \frametitle{Better way to say:}
       
   356   \begin{center}
       
   357     \includegraphics[height=2.5in,width=2.5in, interpolate=true]{mario}
       
   358   \end{center}  
       
   359   \emphbar{\typ{hg} provides power to save and resume from a stage.}
       
   360 \end{frame}
       
   361 
       
   362 \begin{frame}[fragile]
   361 \begin{frame}[fragile]
   363   \frametitle{Revisiting saved points:history/logs}
   362   \frametitle{Revisiting saved points:history/logs}
   364   In \typ{hg}, the difference between consecutive stages is termed as changeset.\\
   363   In \typ{hg}, the difference between consecutive stages is termed as changeset.\\
   365   Once we have saved stages, we need a mechanism to review and access them, for that use \typ{log} command.
   364   Once we have saved stages, we need a mechanism to review and access them, for that use \typ{log} command.
   366   \begin{lstlisting}
   365   \begin{lstlisting}
   390 \end{lstlisting}
   389 \end{lstlisting}
   391   tip/latest changes can be seen via:
   390   tip/latest changes can be seen via:
   392   \begin{lstlisting}
   391   \begin{lstlisting}
   393 $ hg tip    
   392 $ hg tip    
   394   \end{lstlisting} %%$
   393   \end{lstlisting} %%$
   395   \inctime{10}
   394   \inctime{5}
   396 \end{frame}
   395 \end{frame}
   397 
   396 
   398 \begin{frame}[fragile]
   397 \begin{frame}[fragile]
   399   \frametitle{Advancing through state:status}
   398   \frametitle{Advancing through a stage:status}
   400   We often need to add/delete some files from directory(repo). The structure keeps on evolving, and tools for handling them are needed.\\
   399   We often need to add/delete some files from directory(repo). The structure keeps on evolving, and tools for handling them are needed.\\
   401   We will use the Fevicol repo we created earlier.
   400   We will use the Fevicol repo we created earlier.
   402   \begin{lstlisting}
   401   \begin{lstlisting}
   403 $ cd Fevicol
   402 $ cd Fevicol
   404 $ hg log
   403 $ hg log
   406 ? feviStick.py
   405 ? feviStick.py
   407   \end{lstlisting} %%$
   406   \end{lstlisting} %%$
   408   \typ{st} (aka status) is command to show changed files in the working directory.\\
   407   \typ{st} (aka status) is command to show changed files in the working directory.\\
   409 \end{frame}
   408 \end{frame}
   410 
   409 
       
   410 %% track record is confusing for some. Duma have some doubts :(
   411 \begin{frame}[fragile]
   411 \begin{frame}[fragile]
   412   \frametitle{Adding files}
   412   \frametitle{Adding files}
   413   "?" indicates that these file are aliens to track record.\\
   413   "?" indicates that these file are aliens to track record.\\
   414   \typ{add} command is available to add new files to present structure.
   414   \typ{add} command is available to add new files to present structure.
   415   \begin{lstlisting}
   415   \begin{lstlisting}
   434 summary:     First commit.    
   434 summary:     First commit.    
   435   \end{lstlisting}
   435   \end{lstlisting}
   436 \end{frame}
   436 \end{frame}
   437 
   437 
   438 \begin{frame}[fragile]
   438 \begin{frame}[fragile]
   439   \frametitle{More basic operations}
   439   \frametitle{Other operations}
       
   440   \typ{hg} supports basic file-management functions like copy, remove, rename etc.
   440   \begin{lstlisting}
   441   \begin{lstlisting}
   441 $ hg cp feviStick.py pidiLite.py
   442 $ hg cp feviStick.py pidiLite.py
   442 $ hg rename pidiLite.py feviCol.py
   443 $ hg rename pidiLite.py feviCol.py
   443 $ hg st
   444 $ hg st
   444 A feviCol.py
   445 A feviCol.py
   445 $ hg ci -u "Shantanu <shantanu@fossee.in>" 
   446 $ hg ci -u "Shantanu <shantanu@fossee.in>" 
   446         -m "Added feviCol.py."
   447         -m "Added feviCol.py."
   447 $ hg tip| grep summary 
   448 $ hg tip| grep summary 
   448 summary:     Renamed feviStick.py.
   449 summary:     Added feviCol.py.
   449   \end{lstlisting} %$
   450   \end{lstlisting} %$
   450 %% Other commands which can be handy are \typ{cp}, \typ{remove}, \typ{revert} etc.
   451 %% Other commands which can be handy are \typ{remove}, \typ{revert} etc.
   451   \inctime{10}
   452   \inctime{10}
   452 \end{frame}
   453 \end{frame}
   453 
   454 
   454 % Introduction to concepts of branches, merging patch?
   455 % Introduction to concepts of branches, merging patch?
   455 \section{Sharing and Collaborating}
   456 \section{Sharing and Collaborating}
   456 
   457 
   457 \begin{frame}[fragile]
   458 \begin{frame}[fragile]
   458   \frametitle{Distributing changes}
   459   \frametitle{Distributing changes}
   459   As this repo is self-contained, hence changeset just created are local and are not propagated to previously cloned Fevicol-pull.
   460   \begin{itemize}
       
   461   \item All directory-structure(repo) are self-contained.
       
   462   \item Changes created are local.
       
   463     \begin{itemize}
       
   464     \item Until we sync. previously cloned repos.
       
   465     \end{itemize}
       
   466   \end{itemize}
   460   \begin{lstlisting}
   467   \begin{lstlisting}
   461 $ hg pull 
   468 $ hg pull 
   462 pulling from /home/baali/Fevicol
   469 pulling from /home/baali/Fevicol
   463 requesting all changes
   470 requesting all changes
   464 adding changesets
   471 adding changesets
   469   \end{lstlisting} %$
   476   \end{lstlisting} %$
   470 \end{frame}
   477 \end{frame}
   471 
   478 
   472 \begin{frame}[fragile]
   479 \begin{frame}[fragile]
   473   \frametitle{Pulling changesets cont...}
   480   \frametitle{Pulling changesets cont...}
   474   As pointed by previous command output, hg \typ{pull} does not(by default) update current directory. It just imports changesets. To add all these changesets one have to update using \typ{up} command:
   481   \typ{pull} command doesn't update current directory, it just imports changesets. To add all these changes, use \typ{up}:
   475   \begin{lstlisting}
   482   \begin{lstlisting}
   476 $ cd Fevicol-pull
   483 $ cd Fevicol-pull
   477 $ ls -a
   484 $ ls -a
   478 .  ..  .hg
   485 .  ..  .hg
   479 $ hg up
   486 $ hg up
   480 2 files updated, 0 files merged, 
   487 2 files updated, 0 files merged, 
   481 0 files removed, 0 files unresolved
   488 0 files removed, 0 files unresolved
   482 $ ls -a
   489 $ ls -a
   483 .  ..  feviCol.py  feviStick.py  .hg    
   490 .  ..  feviCol.py  feviStick.py  .hg    
   484   \end{lstlisting}
   491   \end{lstlisting}
   485 \end{frame}
   492   \pause
   486 
   493   \emphbar{Why \typ{pull} and \typ{up} are needed separately?}
   487 \begin{frame}[fragile]
   494 \end{frame}
   488   \frametitle{Making changes across the repos}
   495 
   489   \begin{lstlisting}
   496 \begin{frame}[fragile]
   490 $ Fevicol-clone/
   497   \frametitle{Making changes across branches}
       
   498   \begin{lstlisting}
       
   499 $ cd Fevicol-pull/
   491   \end{lstlisting} %$
   500   \end{lstlisting} %$
   492   Lets edit and correct the feviStick.py 
   501   Lets edit and correct the feviStick.py 
   493 \begin{lstlisting}
   502 \begin{lstlisting}
   494 $ echo "print 'Ab no more Chip Chip'" 
   503 $ echo "print 'Ab no more Chip Chip'" 
   495         > feviStick.py
   504         > feviStick.py
   496 $ hg st
   505 $ hg st
   497 M feviStick.py
   506 M feviStick.py
   498 \end{lstlisting}
   507 \end{lstlisting}
   499   'M' sign indicates that Mercurial has noticed change.\\
   508   'M' sign indicates that \typ{hg} has noticed change.\\
   500 \end{frame}
   509 \end{frame}
   501 
   510 
   502 \begin{frame}[fragile]
   511 \begin{frame}[fragile]
   503   \frametitle{Revisiting changes}
   512   \frametitle{Revisiting changes}
   504 To revisit changes made earlier use \typ{diff} command:
   513   To view changes made \typ{hg} provides \typ{diff}:
   505 \begin{lstlisting}
   514 \begin{lstlisting}
   506 $ hg diff
   515 $ hg diff
   507 diff -r a7912d45f47c feviStick.py
   516 diff -r a7912d45f47c feviStick.py
   508 --- a/feviStick.py   Sun Aug 23 22:34:35 2009 +0530
   517 --- a/feviStick.py   Sun Aug 23 22:34:35 2009 +0530
   509 +++ b/feviStick.py   Sun Aug 23 22:47:49 2009 +0530
   518 +++ b/feviStick.py   Sun Aug 23 22:47:49 2009 +0530
   510 @@ -1,1 +1,1 @@
   519 @@ -1,1 +1,1 @@
   511 -print 'Yeh Fevicol ka Majboot jod hai'
   520 -print 'Yeh Fevicol ka Majboot jod hai'
   512 +print 'Ab no more Chip Chip'
   521 +print 'Ab no more Chip Chip'
   513   \end{lstlisting} %$
   522   \end{lstlisting} %$
   514   These changes are not logged until you commit them.\\
   523 \end{frame}
       
   524 
       
   525 \begin{frame}[fragile]
       
   526   \frametitle{Saving the changes}
       
   527   We have to commit these changes.
   515   \begin{lstlisting}
   528   \begin{lstlisting}
   516 $ hg ci -u "Shantanu <shantanu@fossee.in>" 
   529 $ hg ci -u "Shantanu <shantanu@fossee.in>" 
   517       -m "Changed tagline for feviStick.py."
   530       -m "Changed tagline for feviStick.py."
   518   \end{lstlisting} %$
   531   \end{lstlisting} %$
   519 \end{frame}
   532 \end{frame}
   520 
   533 
   521 \begin{frame}[fragile]
   534 \begin{frame}[fragile]
   522   \frametitle{Syncing two repos}
   535   \frametitle{Syncing two repos}
   523   Now to bring both the repos to same stage one have to \typ{push} changes.
   536   To bring both the repos at same stage we have to \typ{push} differences.
   524   \begin{lstlisting}
   537   \begin{lstlisting}
   525 $ hg push 
   538 $ hg push 
   526 pushing to /home/baali/Fevicol
   539 pushing to /home/baali/Fevicol
   527 searching for changes
   540 searching for changes
   528 adding changesets
   541 adding changesets
   530 adding file changes
   543 adding file changes
   531 added 1 changesets with 1 changes to 1 files
   544 added 1 changesets with 1 changes to 1 files
   532   \end{lstlisting} %$
   545   \end{lstlisting} %$
   533 \end{frame}
   546 \end{frame}
   534 
   547 
   535 
       
   536 \begin{frame}[fragile]
   548 \begin{frame}[fragile]
   537   \frametitle{Syncing cont...}
   549   \frametitle{Syncing cont...}
   538   Same as pulling, pushing wont update the main repo by default. Try running following command:
   550   Same as pulling, pushing wont update the main directory by default.
   539   \begin{lstlisting}
   551   \begin{lstlisting}
   540 $ cd Fevicol
   552 $ cd Fevicol
   541 $ hg tip    
   553 $ hg tip    
   542 $ cat feviStick.py
   554 $ cat feviStick.py
   543   \end{lstlisting}
   555   \end{lstlisting}
   555   We consider scenario, two person on one project, both have local copies, and one among them is main branch.\\
   567   We consider scenario, two person on one project, both have local copies, and one among them is main branch.\\
   556   \begin{center}
   568   \begin{center}
   557     \includegraphics[height=1in, interpolate=true]{scenario}
   569     \includegraphics[height=1in, interpolate=true]{scenario}
   558   \end{center}  
   570   \end{center}  
   559 \end{frame}
   571 \end{frame}
   560 
       
   561 
   572 
   562 \begin{frame}[fragile]
   573 \begin{frame}[fragile]
   563   \frametitle{Making changes to one of repo}
   574   \frametitle{Making changes to one of repo}
   564   \begin{lstlisting}
   575   \begin{lstlisting}
   565 $ cd Fevicol-pull
   576 $ cd Fevicol-pull
   568 $ hg st
   579 $ hg st
   569 M feviStick.py
   580 M feviStick.py
   570 $ hg ci -u "Shantanu <shantanu@fossee.in>" 
   581 $ hg ci -u "Shantanu <shantanu@fossee.in>" 
   571      -m "Updated tag line for feviCol.py."
   582      -m "Updated tag line for feviCol.py."
   572 $ hg tip| grep changeset
   583 $ hg tip| grep changeset
   573 changeset:   4:caf986b15e05
   584 changeset:   3:caf986b15e05
   574   \end{lstlisting} %$
   585   \end{lstlisting} %$
   575 \end{frame}
   586 \end{frame}
   576 
   587 
   577 \begin{frame}[fragile]
   588 \begin{frame}[fragile]
   578   \frametitle{In the meanwhile, other repo is ...}
   589   \frametitle{In the meanwhile, other repo is ...}
   584 $ hg st
   595 $ hg st
   585 A firstAdd.py
   596 A firstAdd.py
   586 $ hg ci -u "Shantanu <shantanu@fossee.in>"
   597 $ hg ci -u "Shantanu <shantanu@fossee.in>"
   587         -m "Added firsAdd.py."
   598         -m "Added firsAdd.py."
   588 $ hg tip|grep changeset
   599 $ hg tip|grep changeset
   589 changeset:   4:fadbd6492cc4    
   600 changeset:   3:fadbd6492cc4    
   590   \end{lstlisting}
   601   \end{lstlisting}
       
   602 \end{frame}
       
   603 
       
   604 %%\hspace*{-0.5in} 
       
   605 
       
   606 \begin{frame}[fragile]
       
   607   \frametitle{Situation}
       
   608   \begin{columns}
       
   609     \column{0.5\textwidth}    
       
   610     \begin{block}{\center{main directory}}
       
   611       \includegraphics[height=2in, interpolate=true]{main}
       
   612     \end{block}
       
   613     \column{0.5\textwidth} 
       
   614     \begin{block}{\center{cloned directory}}
       
   615       \includegraphics[height=2in, interpolate=true]{clone}
       
   616     \end{block}
       
   617   \end{columns}
   591 \end{frame}
   618 \end{frame}
   592 
   619 
   593 \begin{frame}[fragile]
   620 \begin{frame}[fragile]
   594   \frametitle{Merging}
   621   \frametitle{Merging}
   595   \begin{lstlisting}
   622   \begin{lstlisting}