versionControl/vcs.tex
changeset 77 708e1f6a9a89
child 78 216f6670abfd
equal deleted inserted replaced
76:814fb2d7c1d0 77:708e1f6a9a89
       
     1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
     2 % Version Control Systems
       
     3 %
       
     4 % Author: FOSSEE 
       
     5 % Copyright (c) 2009, FOSSEE, IIT Bombay
       
     6 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
     7 
       
     8 \documentclass[14pt,compress]{beamer}
       
     9 
       
    10 \mode<presentation>
       
    11 {
       
    12   \usetheme{Warsaw}
       
    13   \useoutertheme{infolines}
       
    14   \setbeamercovered{transparent}
       
    15 }
       
    16 
       
    17 \usepackage[english]{babel}
       
    18 \usepackage[latin1]{inputenc}
       
    19 %\usepackage{times}
       
    20 \usepackage[T1]{fontenc}
       
    21 
       
    22 % Taken from Fernando's slides.
       
    23 \usepackage{ae,aecompl}
       
    24 \usepackage{mathpazo,courier,euler}
       
    25 \usepackage[scaled=.95]{helvet}
       
    26 
       
    27 \definecolor{darkgreen}{rgb}{0,0.5,0}
       
    28 
       
    29 \usepackage{listings}
       
    30 \lstset{language=Python,
       
    31     basicstyle=\ttfamily\bfseries,
       
    32     commentstyle=\color{red}\itshape,
       
    33   stringstyle=\color{darkgreen},
       
    34   showstringspaces=false,
       
    35   keywordstyle=\color{blue}\bfseries}
       
    36 
       
    37 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
    38 % Macros
       
    39 \setbeamercolor{emphbar}{bg=blue!20, fg=black}
       
    40 \newcommand{\emphbar}[1]
       
    41 {\begin{beamercolorbox}[rounded=true]{emphbar} 
       
    42       {#1}
       
    43  \end{beamercolorbox}
       
    44 }
       
    45 \newcounter{time}
       
    46 \setcounter{time}{0}
       
    47 \newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}}
       
    48 
       
    49 \newcommand{\typ}[1]{\lstinline{#1}}
       
    50 
       
    51 \newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}}  }
       
    52 
       
    53 %%% This is from Fernando's setup.
       
    54 % \usepackage{color}
       
    55 % \definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
       
    56 % % Use and configure listings package for nicely formatted code
       
    57 % \usepackage{listings}
       
    58 % \lstset{
       
    59 %    language=Python,
       
    60 %    basicstyle=\small\ttfamily,
       
    61 %    commentstyle=\ttfamily\color{blue},
       
    62 %    stringstyle=\ttfamily\color{orange},
       
    63 %    showstringspaces=false,
       
    64 %    breaklines=true,
       
    65 %    postbreak = \space\dots
       
    66 % }
       
    67 
       
    68 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
    69 % Title page
       
    70 \title[Version Control Systems]{SEES: Version Control Systems}
       
    71 
       
    72 \author[FOSSEE] {FOSSEE}
       
    73 
       
    74 \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
       
    75 \date[]{}
       
    76 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
    77 
       
    78 %\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo}
       
    79 %\logo{\pgfuseimage{iitmlogo}}
       
    80 
       
    81 
       
    82 %% Delete this, if you do not want the table of contents to pop up at
       
    83 %% the beginning of each subsection:
       
    84 \AtBeginSubsection[]
       
    85 {
       
    86   \begin{frame}<beamer>
       
    87     \frametitle{Outline}
       
    88     \tableofcontents[currentsection,currentsubsection]
       
    89   \end{frame}
       
    90 }
       
    91 
       
    92 \AtBeginSection[]
       
    93 {
       
    94   \begin{frame}<beamer>
       
    95     \frametitle{Outline}
       
    96     \tableofcontents[currentsection,currentsubsection]
       
    97   \end{frame}
       
    98 }
       
    99 
       
   100 % If you wish to uncover everything in a step-wise fashion, uncomment
       
   101 % the following command: 
       
   102 %\beamerdefaultoverlayspecification{<+->}
       
   103 
       
   104 %%\includeonlyframes{current,current1,current2,current3,current4,current5,current6}
       
   105 
       
   106 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   107 % DOCUMENT STARTS
       
   108 \begin{document}
       
   109 
       
   110 \begin{frame}
       
   111   \maketitle
       
   112 \end{frame}
       
   113 
       
   114 % CREATING TOC 
       
   115 \begin{frame}
       
   116   \frametitle{Outline}
       
   117   \tableofcontents
       
   118   % You might wish to add the option [pausesections]
       
   119 \end{frame}
       
   120 
       
   121 % Introduction to course-need of version control, history, options available.
       
   122 \section{Introduction}
       
   123 
       
   124 \begin{frame}
       
   125   \frametitle{What is Version Control?}
       
   126   \begin{block}{From a blog post}
       
   127     ``Version control (or source control) is nothing more arcane than keeping copies of ones work as one make changes to it.''
       
   128   \end{block}
       
   129   \pause
       
   130   \begin{block}{}
       
   131     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}ass1.py, ass2.py.\end{color}
       
   132   \end{block}
       
   133 \end{frame}
       
   134 
       
   135 \begin{frame}
       
   136   \frametitle{Motivation behind such tools}
       
   137   \begin{itemize}
       
   138   \item Track the history and evolution of a program.
       
   139   \item To collaborate effectively on a project.
       
   140   \item \begin{color}{red}``To err is Human''\end{color} \pause for recovery we have ``Version Control''
       
   141   \end{itemize}
       
   142 \end{frame}
       
   143 
       
   144 \begin{frame}
       
   145   \frametitle{How is done What is done?}
       
   146   \begin{itemize}
       
   147   \item It keeps track of changes you make to a file. You can improvise, revisit, and amend.
       
   148   \item all procedure is logged/recorded, so you and others can follow the development cycle.
       
   149   \end{itemize}  
       
   150 \end{frame}
       
   151 
       
   152 \begin{frame}
       
   153   \frametitle{Do we really need this?}
       
   154   \emphbar{For team of people working remotely(even different computers/machines) on a project use of version control is inevitable!}
       
   155   \emphbar{For single person: managing projects and assignments becomes easy}
       
   156   \pause
       
   157   \emphbar{Its a good habit!}
       
   158 \end{frame}
       
   159 
       
   160 \begin{frame}
       
   161   \frametitle{Whats on the menu!}
       
   162   \begin{itemize}
       
   163   \item cvs(Concurrent Version System)
       
   164   \item svn (Subversion)
       
   165   \item hg (Mercurial)
       
   166   \item bzr (Bazaar)
       
   167   \item git
       
   168   \end{itemize}
       
   169 \end{frame}
       
   170 
       
   171 % Introduction to jargons 
       
   172 \section{Learning the Lingo!}
       
   173 
       
   174 \begin{frame}
       
   175   \frametitle{Common jargons: Basic setup}
       
   176   \begin{itemize}
       
   177   \item Repository(repo):\\
       
   178         The folder with all files.
       
   179   \item Server:\\
       
   180         Machine with main inventory/repo.
       
   181   \item Client:\\
       
   182         Local machines with copy of main repo.
       
   183   \end{itemize}
       
   184 \end{frame}
       
   185 
       
   186 \begin{frame}
       
   187   \frametitle{Actions}
       
   188   \begin{itemize}
       
   189   \item Add:\\
       
   190     Adding file into the repo for the first time.
       
   191   \item Version:\\
       
   192     Version number of a file.
       
   193   \item Head/Tip:\\
       
   194     The latest revision of the repo.
       
   195   \item Check out/Clone:\\
       
   196     Initial download of repo onto machine.
       
   197   \item Commit:\\
       
   198     Recording a change.
       
   199   \item Change log/History:\\
       
   200     List of changes made to repo.
       
   201   \end{itemize}
       
   202 \end{frame}
       
   203 
       
   204 \begin{frame}
       
   205   \frametitle{Actions cont...}
       
   206   \begin{itemize}
       
   207   \item Branch:\\
       
   208     Separate local copy of repo for bug fixing, testing.
       
   209   \item Diff/Change:\\
       
   210     Finding the differences in a file in two versions.
       
   211   \item Merge (or patch):\\
       
   212     Apply the changes to file, to make it up-to-date.
       
   213   \item Conflict:\\
       
   214     When merging a file creates a contradict.
       
   215   \item Resolve:\\
       
   216     Fixing the conflict manually.
       
   217   \end{itemize}
       
   218 \end{frame}
       
   219 
       
   220 % Types of Version Controls
       
   221 \section{Types of VCS}
       
   222 
       
   223 \begin{frame}
       
   224   \frametitle{Types:}
       
   225   Based on way of managing the repo there are two types of VCS:
       
   226   \begin{itemize}
       
   227   \item Centralized VCS
       
   228   \item Distributed VCS
       
   229   \end{itemize}
       
   230 \end{frame}
       
   231 
       
   232 \begin{frame}
       
   233   \frametitle{Why hg?}
       
   234   \begin{itemize}
       
   235   \item Easy to learn and use.
       
   236   \item Lightweight.
       
   237   \item Scales excellently.
       
   238   \item Based on Python.
       
   239   \end{itemize}
       
   240 \end{frame}
       
   241 
       
   242 % Initializing the repo, cloning, committing changes, pushing, pulling to repo.
       
   243 \section{Getting Started}
       
   244 
       
   245 \begin{frame}[fragile]
       
   246   \frametitle{Getting comfortable:}
       
   247   Try following commands:
       
   248   \begin{lstlisting}
       
   249     $ hg version    
       
   250     $ hg help
       
   251     $ hg help diff
       
   252   \end{lstlisting} %$
       
   253 \end{frame}
       
   254 
       
   255 \begin{frame}[fragile]
       
   256   \frametitle{Cloning a repo}
       
   257   Clone is used to make a copy of an existing repository. This repo can be both local or remote.
       
   258   \begin{lstlisting}
       
   259 $ hg clone http://hg.serpentine.com/tutorial/hello 
       
   260      localCopyhello
       
   261   \end{lstlisting}
       
   262   And we get a local copy of this repository. 
       
   263   \begin{lstlisting}
       
   264 $ ls localCopyhello/
       
   265 hello.c  Makefile
       
   266   \end{lstlisting}
       
   267 \end{frame}
       
   268 
       
   269 \begin{frame}[fragile]
       
   270   \frametitle{Creating a repo}
       
   271   To start a new repository \typ{hg} provides \typ{init} command.
       
   272   \begin{lstlisting}
       
   273 $ mkdir Fevicol
       
   274 $ cd Fevicol/
       
   275 $ echo "print 'Yeh Fevicol ka majboot 
       
   276               jod hai'" > feviStick.py
       
   277 $ ls -a
       
   278 .  ..  feviStick.py
       
   279 $ hg init
       
   280 $ ls -a
       
   281 .  ..  feviStick.py  .hg
       
   282   \end{lstlisting}
       
   283 \typ{.hg} folder will store the logs related to this repo.
       
   284 \end{frame}
       
   285 
       
   286 \begin{frame}[fragile]
       
   287   \frametitle{Cloning a local repo: Branching}
       
   288   All \typ{hg} repositories are self-contained, and independent which can be cloned. Like:
       
   289   \begin{lstlisting}
       
   290 $ hg clone localCopyhello newCopy
       
   291 updating working directory
       
   292 2 files updated, 0 files merged, 
       
   293 0 files removed, 0 files unresolved
       
   294   \end{lstlisting}
       
   295 or
       
   296   \begin{lstlisting}
       
   297 $ hg clone Fevicol Fevicol-pull
       
   298 updating working directory
       
   299 0 files updated, 0 files merged, 
       
   300 0 files removed, 0 files unresolved
       
   301   \end{lstlisting}
       
   302 \end{frame}
       
   303 
       
   304 \begin{frame}[fragile]
       
   305   \frametitle{History/Logs}
       
   306   To check out track record of a repo one has to use \typ{log} command.
       
   307   \begin{lstlisting}
       
   308 $ cd localCopyhello
       
   309 $ hg log    
       
   310   \end{lstlisting}
       
   311   The output of previous command have following fields:
       
   312   \begin{itemize}
       
   313   \item changeset: identifiers for the changeset.
       
   314   \item user: person who creates the changeset.
       
   315   \item date: The date and time of creation of changeset.
       
   316   \item summary: The one line description of changeset.
       
   317   \end{itemize}
       
   318 \end{frame}
       
   319 
       
   320 \begin{frame}[fragile]
       
   321   \frametitle{History/Logs cont...}
       
   322 By default it returns complete logs of all changes. To make it selective try:
       
   323 \begin{lstlisting}
       
   324   $ hg log -r 3
       
   325   $ hg log -r 2:4
       
   326 \end{lstlisting}
       
   327 To see tip/latest commit history use:\\
       
   328 \typ{$ hg tip} %$
       
   329 \end{frame}
       
   330 
       
   331 \begin{frame}[fragile]
       
   332   \frametitle{Adding files}
       
   333   We will revisit the Fevicol repo we created earlier.
       
   334   \begin{lstlisting}
       
   335 $ cd Fevicol
       
   336 $ hg log
       
   337 $ hg status
       
   338 ? feviStick.py
       
   339   \end{lstlisting} %$
       
   340   "?" sign in front of name indicates that this file is not yet part of track record. \typ{add} command is used to add new files to repo.
       
   341   \begin{lstlisting}
       
   342 $ hg add feviStick.py
       
   343 $ hg st
       
   344 A feviStick.py
       
   345   \end{lstlisting}
       
   346 \end{frame}
       
   347 
       
   348 \begin{frame}[fragile]
       
   349   \frametitle{Committing changes}
       
   350   \typ{hg} uses \typ{commit} (alias \typ{ci}) command to make changes logged. So after adding a file, we have to commit it also by:
       
   351   \begin{lstlisting}
       
   352 $ hg ci -u "Shantanu <shantanu@fossee.in>" 
       
   353         -m "First commit."
       
   354 $ hg log
       
   355 changeset:   0:84f5e91f4de1
       
   356 tag:         tip
       
   357 user:        Shantanu <shantanu@fossee.in>
       
   358 date:        Fri Aug 21 23:37:13 2009 +0530
       
   359 summary:     First commit.    
       
   360   \end{lstlisting}
       
   361 \end{frame}
       
   362 
       
   363 \begin{frame}[fragile]
       
   364   \frametitle{More basic operations}
       
   365   \begin{lstlisting}
       
   366 $ hg rename feviStick.py feviCol.py
       
   367 $ hg st
       
   368 A feviCol.py
       
   369 $ hg ci -u "Shantanu <shantanu@fossee.in>" 
       
   370         -m "Renamed feviStick.py."
       
   371 $ hg tip
       
   372 changeset:   1:d948fb4137c5
       
   373 tag:         tip
       
   374 user:        Shantanu <shantanu@fossee.in>
       
   375 date:        Sat Aug 22 00:11:25 2009 +0530
       
   376 summary:     Renamed feviStick.py.
       
   377   \end{lstlisting}
       
   378 %% Other commands which can be handy are \typ{cp}, \typ{remove}, \typ{revert} etc.
       
   379 \end{frame}
       
   380 
       
   381 % Introduction to concepts of branches, merging patch?
       
   382 \section{Sharing and Collaborating}
       
   383 
       
   384 \begin{frame}[fragile]
       
   385   \frametitle{Distributing changes}
       
   386   As this repo is self-contained, hence changeset just created are local and are not propagated to previously cloned Fevicol-pull.
       
   387   \begin{lstlisting}
       
   388 $ hg pull 
       
   389 pulling from /home/baali/Fevicol
       
   390 requesting all changes
       
   391 adding changesets
       
   392 adding manifests
       
   393 adding file changes
       
   394 added 2 changesets with 2 changes to 2 files
       
   395 (run 'hg update' to get a working copy)
       
   396   \end{lstlisting} %$
       
   397 \end{frame}
       
   398 
       
   399 \begin{frame}[fragile]
       
   400   \frametitle{Pulling changesets cont...}
       
   401   as last line of previous command suggest, 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:
       
   402   \begin{lstlisting}
       
   403 $ cd Fevicol-pull
       
   404 $ ls -a
       
   405 .  ..  .hg
       
   406 $ hg up
       
   407 2 files updated, 0 files merged, 
       
   408 0 files removed, 0 files unresolved
       
   409 $ ls -a
       
   410 .  ..  feviCol.py  feviStick.py  .hg    
       
   411   \end{lstlisting}
       
   412 \end{frame}
       
   413 
       
   414 \begin{frame}[fragile]
       
   415   \frametitle{Making changes across the repos}
       
   416   \typ{$ cd Fevicol-clone/}\\ %$
       
   417   Lets edit and correct the feviStick.py 
       
   418 \begin{lstlisting}
       
   419 $ echo "print 'Ab no more Chip Chip'" 
       
   420         > feviStick.py
       
   421 $ hg st
       
   422 M feviStick.py
       
   423 \end{lstlisting}
       
   424   'M' sign indicates that Mercurial has noticed change.\\
       
   425 \end{frame}
       
   426 
       
   427 \begin{frame}[fragile]
       
   428   \frametitle{Revisiting changes}
       
   429 To look back at the changes made there is \typ{diff} command:
       
   430 \begin{lstlisting}
       
   431 $ hg diff
       
   432 diff -r a7912d45f47c feviStick.py
       
   433 --- a/feviStick.py   Sun Aug 23 22:34:35 2009 +0530
       
   434 +++ b/feviStick.py   Sun Aug 23 22:47:49 2009 +0530
       
   435 @@ -1,1 +1,1 @@
       
   436 -print 'Yeh Fevicol ka Majboot jod hai'
       
   437 +print 'Ab no more Chip Chip'
       
   438   \end{lstlisting} %$
       
   439   These changes are not logged until you commit them.\\
       
   440   \begin{lstlisting}
       
   441 $ hg ci -u "Shantanu <shantanu@fossee.in>" 
       
   442       -m "Changed tagline for feviStick.py."
       
   443   \end{lstlisting} %$
       
   444 \end{frame}
       
   445 
       
   446 \begin{frame}[fragile]
       
   447   \frametitle{Syncing two repos}
       
   448   Now to bring both the repos to same stage one have to \typ{push} changes.
       
   449   \begin{lstlisting}
       
   450 $ hg push 
       
   451 pushing to /home/baali/Fevicol
       
   452 searching for changes
       
   453 adding changesets
       
   454 adding manifests
       
   455 adding file changes
       
   456 added 1 changesets with 1 changes to 1 files
       
   457   \end{lstlisting} %$
       
   458 \end{frame}
       
   459 
       
   460 
       
   461 \begin{frame}[fragile]
       
   462   \frametitle{Syncing cont...}
       
   463   Same as pulling, pushing wont update the main repo by default. Try running following command:
       
   464   \begin{lstlisting}
       
   465 $ hg tip    
       
   466 $ cat feviStick.py
       
   467   \end{lstlisting}
       
   468   \typ{tip} shows latest changeset, but content of file are not updated. We have to use \typ{up} on main branch
       
   469   \begin{lstlisting}
       
   470 $ hg up
       
   471 1 files updated, 0 files merged, 0 files removed, 0 files unresolved    
       
   472   \end{lstlisting} %$
       
   473 \end{frame}
       
   474 
       
   475 \begin{frame}[fragile]
       
   476   \frametitle{Merging}
       
   477 
       
   478 \end{frame}
       
   479 
       
   480 \begin{frame}[fragile]
       
   481   \frametitle{}
       
   482 
       
   483 \end{frame}
       
   484 
       
   485 % Steps to follow to make life easier. How to avoid/handle manual merges.
       
   486 \section{Work flow: DOS and DON'Ts}
       
   487 
       
   488 \begin{frame}
       
   489   \frametitle{Suggested Readings:}
       
   490   \begin{itemize}
       
   491   \item \url{http://hgbook.red-bean.com/}
       
   492   \item \url{http://karlagius.com/2009/01/09/version-control-for-the-masses/}
       
   493   \item Articles related to version control available on \url{http://betterexplained.com/}
       
   494   \item \url{http://en.wikipedia.org/wiki/Revision_control}
       
   495   \item \url{http://wiki.alliedmods.net/Mercurial_Tutorial}
       
   496   \end{itemize}
       
   497 \end{frame}
       
   498 \end{document}