versionControl/vcs.tex
changeset 79 d6dd6541a887
parent 78 216f6670abfd
child 80 e5dcba8a6b13
equal deleted inserted replaced
78:216f6670abfd 79:d6dd6541a887
   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}ass1.py, ass2.py.\end{color}
   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}
   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}
   145 
   145 
   146 \begin{frame}
   146 \begin{frame}
   147   \frametitle{How is done What is done?}
   147   \frametitle{How is done What is done?}
   148   \begin{itemize}
   148   \begin{itemize}
   149   \item It keeps track of changes you make to a file. You can improvise, revisit, and amend.
   149   \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.
   150   \item All procedure is logged/recorded, so you and others can follow the development cycle.
   151   \end{itemize}  
   151   \end{itemize}  
   152 \end{frame}
   152 \end{frame}
   153 
   153 
   154 \begin{frame}
   154 \begin{frame}
   155   \frametitle{Do we really need this?}
   155   \frametitle{Do we really need this?}
   156   \emphbar{For team of people working remotely(even different computers/machines) on a project use of version control is inevitable!}
   156   \emphbar{For team of people working remotely(even different computers/machines) on a project, use of version control is inevitable!}
       
   157   \vspace{0.15in}
   157   \emphbar{For single person: managing projects and assignments becomes easy}
   158   \emphbar{For single person: managing projects and assignments becomes easy}
       
   159   \vspace{0.15in}
   158   \pause
   160   \pause
   159   \emphbar{Its a good habit!}
   161   \emphbar{\color{red}{Its a good habit!}}
   160 \end{frame}
   162 \end{frame}
   161 
   163 
   162 \begin{frame}
   164 \begin{frame}
   163   \frametitle{Whats on the menu!}
   165   \frametitle{Whats on the menu!}
   164   \begin{itemize}
   166   \begin{itemize}
   165   \item cvs(Concurrent Version System)
   167   \item cvs (Concurrent Version System)
   166   \item svn (Subversion)
   168   \item svn (Subversion)
   167   \item hg (Mercurial)
   169   \item hg (Mercurial)
   168   \item bzr (Bazaar)
   170   \item bzr (Bazaar)
   169   \item git
   171   \item git
   170   \end{itemize}
   172   \end{itemize}
       
   173   \inctime{10}
   171 \end{frame}
   174 \end{frame}
   172 
   175 
   173 % Introduction to jargons 
   176 % Introduction to jargons 
   174 \section{Learning the Lingo!}
   177 \section{Learning the Lingo!}
   175 
   178 
   211   \item Diff/Change:\\
   214   \item Diff/Change:\\
   212     Finding the differences in a file in two versions.
   215     Finding the differences in a file in two versions.
   213   \item Merge (or patch):\\
   216   \item Merge (or patch):\\
   214     Apply the changes to file, to make it up-to-date.
   217     Apply the changes to file, to make it up-to-date.
   215   \item Conflict:\\
   218   \item Conflict:\\
   216     When merging a file creates a contradict.
   219     When merging a file is not obvious.
   217   \item Resolve:\\
   220   \item Resolve:\\
   218     Fixing the conflict manually.
   221     Fixing the conflict manually.
   219   \end{itemize}
   222   \end{itemize}
   220 \end{frame}
   223 \end{frame}
   221 
   224 
   224 
   227 
   225 \begin{frame}
   228 \begin{frame}
   226   \frametitle{Types:}
   229   \frametitle{Types:}
   227   Based on way of managing the repo there are two types of VCS:
   230   Based on way of managing the repo there are two types of VCS:
   228   \begin{itemize}
   231   \begin{itemize}
   229   \item Centralized VCS
   232   \item Centralized VCS\\
   230   \item Distributed VCS
   233     cvs, svn falls under this category.
   231   \end{itemize}
   234   \item Distributed VCS\\
       
   235     hg, bzr, git follows this methodology.
       
   236   \end{itemize}
       
   237   \emphbar{We would be covering \typ{hg}}
   232 \end{frame}
   238 \end{frame}
   233 
   239 
   234 \begin{frame}
   240 \begin{frame}
   235   \frametitle{Why hg?}
   241   \frametitle{Why hg?}
       
   242     \includegraphics[height=.75in, interpolate=true]{mercurial}
   236   \begin{itemize}
   243   \begin{itemize}
   237   \item Easy to learn and use.
   244   \item Easy to learn and use.
   238   \item Lightweight.
   245   \item Lightweight.
   239   \item Scales excellently.
   246   \item Scales excellently.
   240   \item Based on Python.
   247   \item Based on Python.
   241   \end{itemize}
   248   \end{itemize}
       
   249   \inctime{10}
   242 \end{frame}
   250 \end{frame}
   243 
   251 
   244 % Initializing the repo, cloning, committing changes, pushing, pulling to repo.
   252 % Initializing the repo, cloning, committing changes, pushing, pulling to repo.
   245 \section{Getting Started}
   253 \section{Getting Started}
   246 
   254 
   256 
   264 
   257 \begin{frame}[fragile]
   265 \begin{frame}[fragile]
   258   \frametitle{Cloning a repo}
   266   \frametitle{Cloning a repo}
   259   Clone is used to make a copy of an existing repository. This repo can be both local or remote.
   267   Clone is used to make a copy of an existing repository. This repo can be both local or remote.
   260   \begin{lstlisting}
   268   \begin{lstlisting}
   261 $ hg clone http://hg.serpentine.com/tutorial/hello 
   269 $ hg clone \
   262      localCopyhello
   270   http://hg.serpentine.com/tutorial/hello \
       
   271   localCopyhello
   263   \end{lstlisting}
   272   \end{lstlisting}
   264   And we get a local copy of this repository. 
   273   And we get a local copy of this repository. 
   265   \begin{lstlisting}
   274   \begin{lstlisting}
   266 $ ls localCopyhello/
   275 $ ls localCopyhello/
   267 hello.c  Makefile
   276 hello.c  Makefile
   292 $ hg clone localCopyhello newCopy
   301 $ hg clone localCopyhello newCopy
   293 updating working directory
   302 updating working directory
   294 2 files updated, 0 files merged, 
   303 2 files updated, 0 files merged, 
   295 0 files removed, 0 files unresolved
   304 0 files removed, 0 files unresolved
   296   \end{lstlisting}
   305   \end{lstlisting}
   297 or
   306   or
   298   \begin{lstlisting}
   307   \begin{lstlisting}
   299 $ hg clone Fevicol Fevicol-pull
   308 $ hg clone Fevicol Fevicol-pull
   300 updating working directory
   309 updating working directory
   301 0 files updated, 0 files merged, 
   310 0 files updated, 0 files merged, 
   302 0 files removed, 0 files unresolved
   311 0 files removed, 0 files unresolved
   303   \end{lstlisting}
   312   \end{lstlisting}
       
   313   \inctime{15}
   304 \end{frame}
   314 \end{frame}
   305 
   315 
   306 \begin{frame}[fragile]
   316 \begin{frame}[fragile]
   307   \frametitle{History/Logs}
   317   \frametitle{History/Logs}
   308   To check out track record of a repo one has to use \typ{log} command.
   318   To check out track record of a repo one has to use \typ{log} command.
   319   \end{itemize}
   329   \end{itemize}
   320 \end{frame}
   330 \end{frame}
   321 
   331 
   322 \begin{frame}[fragile]
   332 \begin{frame}[fragile]
   323   \frametitle{History/Logs cont...}
   333   \frametitle{History/Logs cont...}
   324 By default it returns complete logs of all changes. To make it selective try:
   334 By default it returns complete logs of all changes. To make it selective use:
   325 \begin{lstlisting}
   335 \begin{lstlisting}
   326   $ hg log -r 3
   336   $ hg log -r 3
   327   $ hg log -r 2:4
   337   $ hg log -r 2:4
   328 \end{lstlisting}
   338 \end{lstlisting}
   329 To see tip/latest commit history use:\\
   339   To see tip/latest commit history use:\\
   330 \typ{$ hg tip} %$
   340 \typ{$ hg tip} \\ %$
       
   341   \inctime{5}
   331 \end{frame}
   342 \end{frame}
   332 
   343 
   333 \begin{frame}[fragile]
   344 \begin{frame}[fragile]
   334   \frametitle{Adding files}
   345   \frametitle{Adding files}
   335   We will revisit the Fevicol repo we created earlier.
   346   We will revisit the Fevicol repo we created earlier.
   336   \begin{lstlisting}
   347   \begin{lstlisting}
   337 $ cd Fevicol
   348 $ cd Fevicol
   338 $ hg log
   349 $ hg log
   339 $ hg status
   350 $ hg st
   340 ? feviStick.py
   351 ? feviStick.py
   341   \end{lstlisting} %$
   352   \end{lstlisting} %$
   342   "?" 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.
   353   "?" 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.
   343   \begin{lstlisting}
   354   \begin{lstlisting}
   344 $ hg add feviStick.py
   355 $ hg add feviStick.py
   347   \end{lstlisting}
   358   \end{lstlisting}
   348 \end{frame}
   359 \end{frame}
   349 
   360 
   350 \begin{frame}[fragile]
   361 \begin{frame}[fragile]
   351   \frametitle{Committing changes}
   362   \frametitle{Committing changes}
   352   \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:
   363   \typ{hg} uses \typ{ci} (alias \typ{commit}) command to make changes logged. So after adding a file, we have to commit it also by:
   353   \begin{lstlisting}
   364   \begin{lstlisting}
   354 $ hg ci -u "Shantanu <shantanu@fossee.in>" 
   365 $ hg ci -u "Shantanu <shantanu@fossee.in>" 
   355         -m "First commit."
   366         -m "First commit."
   356 $ hg log
   367 $ hg log
   357 changeset:   0:84f5e91f4de1
   368 changeset:   0:84f5e91f4de1
   363 \end{frame}
   374 \end{frame}
   364 
   375 
   365 \begin{frame}[fragile]
   376 \begin{frame}[fragile]
   366   \frametitle{More basic operations}
   377   \frametitle{More basic operations}
   367   \begin{lstlisting}
   378   \begin{lstlisting}
   368 $ hg rename feviStick.py feviCol.py
   379 $ hg cp feviStick.py pidiLite.py
       
   380 $ hg rename pidiLite.py feviCol.py
   369 $ hg st
   381 $ hg st
   370 A feviCol.py
   382 A feviCol.py
   371 $ hg ci -u "Shantanu <shantanu@fossee.in>" 
   383 $ hg ci -u "Shantanu <shantanu@fossee.in>" 
   372         -m "Renamed feviStick.py."
   384         -m "Added feviCol.py."
   373 $ hg tip
   385 $ hg tip
   374 changeset:   1:d948fb4137c5
   386 changeset:   1:d948fb4137c5
   375 tag:         tip
   387 tag:         tip
   376 user:        Shantanu <shantanu@fossee.in>
   388 user:        Shantanu <shantanu@fossee.in>
   377 date:        Sat Aug 22 00:11:25 2009 +0530
   389 date:        Sat Aug 22 00:11:25 2009 +0530
   378 summary:     Renamed feviStick.py.
   390 summary:     Renamed feviStick.py.
   379   \end{lstlisting}
   391   \end{lstlisting}
   380 %% Other commands which can be handy are \typ{cp}, \typ{remove}, \typ{revert} etc.
   392 %% Other commands which can be handy are \typ{cp}, \typ{remove}, \typ{revert} etc.
       
   393   \inctime{10}
   381 \end{frame}
   394 \end{frame}
   382 
   395 
   383 % Introduction to concepts of branches, merging patch?
   396 % Introduction to concepts of branches, merging patch?
   384 \section{Sharing and Collaborating}
   397 \section{Sharing and Collaborating}
   385 
   398 
   398   \end{lstlisting} %$
   411   \end{lstlisting} %$
   399 \end{frame}
   412 \end{frame}
   400 
   413 
   401 \begin{frame}[fragile]
   414 \begin{frame}[fragile]
   402   \frametitle{Pulling changesets cont...}
   415   \frametitle{Pulling changesets cont...}
   403   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:
   416   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:
   404   \begin{lstlisting}
   417   \begin{lstlisting}
   405 $ cd Fevicol-pull
   418 $ cd Fevicol-pull
   406 $ ls -a
   419 $ ls -a
   407 .  ..  .hg
   420 .  ..  .hg
   408 $ hg up
   421 $ hg up
   413   \end{lstlisting}
   426   \end{lstlisting}
   414 \end{frame}
   427 \end{frame}
   415 
   428 
   416 \begin{frame}[fragile]
   429 \begin{frame}[fragile]
   417   \frametitle{Making changes across the repos}
   430   \frametitle{Making changes across the repos}
   418   \typ{$ cd Fevicol-clone/}\\ %$
   431   \begin{lstlisting}
       
   432 $ Fevicol-clone/
       
   433   \end{lstlisting} %$
   419   Lets edit and correct the feviStick.py 
   434   Lets edit and correct the feviStick.py 
   420 \begin{lstlisting}
   435 \begin{lstlisting}
   421 $ echo "print 'Ab no more Chip Chip'" 
   436 $ echo "print 'Ab no more Chip Chip'" 
   422         > feviStick.py
   437         > feviStick.py
   423 $ hg st
   438 $ hg st
   426   'M' sign indicates that Mercurial has noticed change.\\
   441   'M' sign indicates that Mercurial has noticed change.\\
   427 \end{frame}
   442 \end{frame}
   428 
   443 
   429 \begin{frame}[fragile]
   444 \begin{frame}[fragile]
   430   \frametitle{Revisiting changes}
   445   \frametitle{Revisiting changes}
   431 To look back at the changes made there is \typ{diff} command:
   446 To revisit changes made earlier use \typ{diff} command:
   432 \begin{lstlisting}
   447 \begin{lstlisting}
   433 $ hg diff
   448 $ hg diff
   434 diff -r a7912d45f47c feviStick.py
   449 diff -r a7912d45f47c feviStick.py
   435 --- a/feviStick.py   Sun Aug 23 22:34:35 2009 +0530
   450 --- a/feviStick.py   Sun Aug 23 22:34:35 2009 +0530
   436 +++ b/feviStick.py   Sun Aug 23 22:47:49 2009 +0530
   451 +++ b/feviStick.py   Sun Aug 23 22:47:49 2009 +0530
   462 
   477 
   463 \begin{frame}[fragile]
   478 \begin{frame}[fragile]
   464   \frametitle{Syncing cont...}
   479   \frametitle{Syncing cont...}
   465   Same as pulling, pushing wont update the main repo by default. Try running following command:
   480   Same as pulling, pushing wont update the main repo by default. Try running following command:
   466   \begin{lstlisting}
   481   \begin{lstlisting}
       
   482 $ cd Fevicol
   467 $ hg tip    
   483 $ hg tip    
   468 $ cat feviStick.py
   484 $ cat feviStick.py
   469   \end{lstlisting}
   485   \end{lstlisting}
   470   \typ{tip} shows latest changeset, but content of file are not updated. We have to use \typ{up} on main branch
   486   \typ{tip} shows latest changeset, but content of file are not updated. We have to use \typ{up} on main branch
   471   \begin{lstlisting}
   487   \begin{lstlisting}
   472 $ hg up
   488 $ hg up
   473 1 files updated, 0 files merged, 0 files removed, 0 files unresolved    
   489 1 files updated, 0 files merged, 0 files removed, 0 files unresolved    
   474   \end{lstlisting} %$
   490   \end{lstlisting} %$
       
   491   \inctime{15}
   475 \end{frame}
   492 \end{frame}
   476 
   493 
   477 \begin{frame}[fragile]
   494 \begin{frame}[fragile]
   478   \frametitle{Merging: Scenario}
   495   \frametitle{Merging: Scenario}
   479   One very useful feature is merging work of different peers working on same project.\\
   496   One very useful feature is merging work of different peers working on same project.\\
   480   We consider scenario, two person on one project, both have local copies, and one among them is main branch.
   497   We consider scenario, two person on one project, both have local copies, and one among them is main branch.\\
       
   498   \begin{center}
       
   499     \includegraphics[height=1in, interpolate=true]{scenario}
       
   500   \end{center}  
   481 \end{frame}
   501 \end{frame}
   482 
   502 
   483 
   503 
   484 \begin{frame}[fragile]
   504 \begin{frame}[fragile]
   485   \frametitle{Making changes to one of repo}
   505   \frametitle{Making changes to one of repo}
   525 (run 'hg heads' to see heads, 'hg merge' to merge)    
   545 (run 'hg heads' to see heads, 'hg merge' to merge)    
   526   \end{lstlisting} %$
   546   \end{lstlisting} %$
   527   Output is already suggesting something!
   547   Output is already suggesting something!
   528 \end{frame}
   548 \end{frame}
   529 
   549 
   530 
   550 %% Here one can mention the point of having push and pull separate. Because of this policy, changes made are not lost.
   531 \begin{frame}[fragile]
   551 \begin{frame}[fragile]
   532   \frametitle{Analyzing events in detail}
   552   \frametitle{Analyzing events in detail}
   533   Since hg \typ{pull} don't update the files directly, our changes are still safe. Following command can help us deal this merging problem in better way:
   553   Since hg \typ{pull} don't update the files directly, our changes are still safe. Following command can help us deal this merging problem in better way:
   534   \begin{lstlisting}
   554   \begin{lstlisting}
   535 $ hg heads
   555 $ hg heads
   557 $ hg ci -u "Shantanu <shantanu@fossee.in>" 
   577 $ hg ci -u "Shantanu <shantanu@fossee.in>" 
   558         -m "Merged branches."
   578         -m "Merged branches."
   559 $ hg heads    
   579 $ hg heads    
   560 $ hg glog
   580 $ hg glog
   561   \end{lstlisting} %$
   581   \end{lstlisting} %$
       
   582   \inctime{15}
   562 \end{frame}
   583 \end{frame}
   563 
   584 
   564 % Steps to follow to make life easier. How to avoid/handle manual merges.
   585 % Steps to follow to make life easier. How to avoid/handle manual merges.
   565 \section{Work flow: DOS and DON'Ts}
   586 \section{Work flow: DOS and DON'Ts}
   566 
   587 
   567 \begin{frame}
   588 \begin{frame}
   568   \frametitle{Motto behind hg}
   589   \frametitle{Motto behind hg}
   569   \begin{center}
   590   \begin{center}
   570   \color{red}{``Commit Early Commit Often.''}\\  
   591   \color{red}{``Commit Early Commit Often.''}\\  
       
   592   \end{center}  
       
   593 \end{frame}
       
   594 
       
   595 \begin{frame}
       
   596   \frametitle{Cheat Sheet}
       
   597   \begin{center}
       
   598   \includegraphics[height=2.8in, interpolate=true]{dongwoo-Hg-120dpi}  
   571   \end{center}  
   599   \end{center}  
   572 \end{frame}
   600 \end{frame}
   573 
   601 
   574 \begin{frame}
   602 \begin{frame}
   575   \frametitle{Steps to be followed}
   603   \frametitle{Steps to be followed}
   578   \item Commit.
   606   \item Commit.
   579   \item Pull changesets.
   607   \item Pull changesets.
   580   \item Merge if required.
   608   \item Merge if required.
   581   \item Push.
   609   \item Push.
   582   \end{itemize}
   610   \end{itemize}
       
   611   \inctime{10}
   583 \end{frame}
   612 \end{frame}
   584 
   613 
   585 \begin{frame}
   614 \begin{frame}
   586   \frametitle{Suggested Readings:}
   615   \frametitle{Suggested Readings:}
   587   \begin{itemize}
   616   \begin{itemize}
   588   \item \url{http://hgbook.red-bean.com/}
   617   \item \url{http://mercurial.selenic.com/guide/}
       
   618   \item \url{http://hgbook.red-bean.com/}    
   589   \item \url{http://karlagius.com/2009/01/09/version-control-for-the-masses/}
   619   \item \url{http://karlagius.com/2009/01/09/version-control-for-the-masses/}
   590   \item Articles related to version control available on \url{http://betterexplained.com/}
   620   \item Articles related to version control available on \url{http://betterexplained.com/}
   591   \item \url{http://en.wikipedia.org/wiki/Revision_control}
   621   \item \url{http://en.wikipedia.org/wiki/Revision_control}
   592   \item \url{http://wiki.alliedmods.net/Mercurial_Tutorial}
   622   \item \url{http://wiki.alliedmods.net/Mercurial_Tutorial}
   593   \end{itemize}
   623   \end{itemize}
   594 \end{frame}
   624 \end{frame}
   595 \end{document}
   625 \end{document}
       
   626 
       
   627 Notes
       
   628 -----
       
   629 
       
   630 From http://mercurial.selenic.com/
       
   631 
       
   632 Quick Start
       
   633 
       
   634 Clone a project and push changes
       
   635 
       
   636 $ hg clone http://selenic.com/repo/hello
       
   637 $ cd hello
       
   638 $ (edit files)
       
   639 $ hg add (new files)
       
   640 $ hg commit -m 'My changes'
       
   641 $ hg push
       
   642 
       
   643 
       
   644 Create a project and commit
       
   645 
       
   646 $ hg init (project-directory)
       
   647 $ cd (project-directory)
       
   648 $ (add some files)
       
   649 $ hg add
       
   650 $ hg commit -m 'Initial commit'