versionControl/vcs.tex
changeset 81 3d20090b7cbd
parent 80 e5dcba8a6b13
child 83 c52c9a615356
equal deleted inserted replaced
80:e5dcba8a6b13 81:3d20090b7cbd
   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   \vspace{0.15in}
   158   \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}
   159   \vspace{0.15in}
   160   \pause
   160   \pause
   161   \emphbar{\color{red}{Its a good habit!}}
   161   \emphbar{\color{red}{It is a good habit!}}
   162 \end{frame}
   162 \end{frame}
   163 
   163 
   164 \begin{frame}
   164 \begin{frame}
   165   \frametitle{Whats on the menu!}
   165   \frametitle{Whats on the menu!}
   166   \begin{itemize}
   166   \begin{itemize}
   252 % Initializing the repo, cloning, committing changes, pushing, pulling to repo.
   252 % Initializing the repo, cloning, committing changes, pushing, pulling to repo.
   253 \section{Getting Started}
   253 \section{Getting Started}
   254 
   254 
   255 \begin{frame}[fragile]
   255 \begin{frame}[fragile]
   256   \frametitle{Getting comfortable:}
   256   \frametitle{Getting comfortable:}
   257   Try following commands:
   257   For checking \typ{hg} installation and its version try:
   258   \begin{lstlisting}
   258   \begin{lstlisting}
   259     $ hg version    
   259     $ hg version    
       
   260   \end{lstlisting}
       
   261   To get broad help on \typ{hg} and commands available:
       
   262   \begin{lstlisting}
       
   263     $ man hg
   260     $ hg help
   264     $ hg help
       
   265   \end{lstlisting}
       
   266   To get help on particular \typ{hg} related option try:
       
   267   \begin{lstlisting}
   261     $ hg help diff
   268     $ hg help diff
   262   \end{lstlisting} %$
   269   \end{lstlisting} %$
   263 \end{frame}
   270 \end{frame}
   264 
   271 
   265 \begin{frame}[fragile]
   272 \begin{frame}[fragile]
   266   \frametitle{Cloning a repo}
   273   \frametitle{Getting working/existing code base}
   267   Clone is used to make a copy of an existing repository. This repo can be both local or remote.
   274   \typ{clone} is used to make a copy of an existing repository. It can be both local or remote.
   268   \begin{lstlisting}
   275   \begin{lstlisting}
   269 $ hg clone \
   276 $ hg clone 
   270   http://hg.serpentine.com/tutorial/hello \
   277   http://hg.serpentine.com/tutorial/hello 
   271   localCopyhello
   278   localCopyhello
   272   \end{lstlisting}
   279   \end{lstlisting}
   273   And we get a local copy of this repository. 
   280   And we get a local copy of this repository. 
   274   \begin{lstlisting}
   281   \begin{lstlisting}
   275 $ ls localCopyhello/
   282 $ ls localCopyhello/
   276 hello.c  Makefile
   283 hello.c  Makefile
   277   \end{lstlisting}
   284   \end{lstlisting}
   278 \end{frame}
   285 \end{frame}
   279 
   286 
   280 \begin{frame}[fragile]
   287 \begin{frame}[fragile]
   281   \frametitle{Creating a repo}
   288   \frametitle{To start track-record on existing files}
   282   To start a new repository \typ{hg} provides \typ{init} command.
   289   I have some files which I want to bring under version control. \typ{hg} provides \typ{init} command for this: 
       
   290   \begin{lstlisting}
       
   291 $ ls -a circulate/
       
   292 .  ..  lena.png  pendulum.txt  points.txt  pos.txt  sslc1.py  sslc1.txt
       
   293 $ cd circulate/
       
   294 $ hg init
       
   295 $ ls -a
       
   296 .  ..  .hg  lena.png  pendulum.txt  points.txt  pos.txt  sslc1.py  sslc1.txt    
       
   297   \end{lstlisting}
       
   298   \emphbar{\typ{.hg} directory keeps log of changes made henceforth.}
       
   299 \end{frame}
       
   300 
       
   301 \begin{frame}[fragile]
       
   302   \frametitle{Starting fresh}
       
   303   We can use \typ{init} to start a new repository also
   283   \begin{lstlisting}
   304   \begin{lstlisting}
   284 $ mkdir Fevicol
   305 $ mkdir Fevicol
   285 $ cd Fevicol/
   306 $ cd Fevicol/
   286 $ echo "print 'Yeh Fevicol ka majboot 
   307 $ echo "print 'Yeh Fevicol ka majboot 
   287               jod hai'" > feviStick.py
   308               jod hai'" > feviStick.py
   289 .  ..  feviStick.py
   310 .  ..  feviStick.py
   290 $ hg init
   311 $ hg init
   291 $ ls -a
   312 $ ls -a
   292 .  ..  feviStick.py  .hg
   313 .  ..  feviStick.py  .hg
   293   \end{lstlisting}
   314   \end{lstlisting}
   294 \typ{.hg} folder will store the logs related to this repo.
   315 \end{frame}
   295 \end{frame}
   316 
   296 
   317 \begin{frame}[fragile]
   297 \begin{frame}[fragile]
   318   \frametitle{Making copies: Branching}
   298   \frametitle{Cloning a local repo: Branching}
   319   All \typ{hg} repositories are self-contained, and independent which can be copied(cloned):
   299   All \typ{hg} repositories are self-contained, and independent which can be cloned. Like:
       
   300   \begin{lstlisting}
   320   \begin{lstlisting}
   301 $ hg clone localCopyhello newCopy
   321 $ hg clone localCopyhello newCopy
   302 updating working directory
   322 updating working directory
   303 2 files updated, 0 files merged, 
   323 2 files updated, 0 files merged, 
   304 0 files removed, 0 files unresolved
   324 0 files removed, 0 files unresolved
   311 0 files removed, 0 files unresolved
   331 0 files removed, 0 files unresolved
   312   \end{lstlisting}
   332   \end{lstlisting}
   313   \inctime{15}
   333   \inctime{15}
   314 \end{frame}
   334 \end{frame}
   315 
   335 
   316 \begin{frame}[fragile]
   336 %% Should we here stress on how are distribute VCS have 
   317   \frametitle{History/Logs}
   337 %% different approach then centralized ones? Maybe a pic
   318   To check out track record of a repo one has to use \typ{log} command.
   338 %% 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]
       
   363   \frametitle{Revisiting saved points:history/logs}
       
   364   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.
   319   \begin{lstlisting}
   366   \begin{lstlisting}
   320 $ cd localCopyhello
   367 $ cd localCopyhello
   321 $ hg log    
   368 $ hg log    
   322   \end{lstlisting}
   369   \end{lstlisting}
   323   The output of previous command have following fields:
   370 \end{frame}
   324   \begin{itemize}
   371 
   325   \item changeset: identifiers for the changeset.
   372 \begin{frame}[fragile]
   326   \item user: person who creates the changeset.
   373   \frametitle{Understanding output}
   327   \item date: The date and time of creation of changeset.
   374   The output provides following information:
   328   \item summary: The one line description of changeset.
   375   \begin{itemize}
       
   376   \item changeset: Identifiers for the changeset.
       
   377   \item user: Person who created the changeset.
       
   378   \item date: Date and time of creation of changeset.
       
   379   \item summary: One line description.
   329   \end{itemize}
   380   \end{itemize}
   330 \end{frame}
   381 \end{frame}
   331 
   382 
   332 \begin{frame}[fragile]
   383 \begin{frame}[fragile]
   333   \frametitle{History/Logs cont...}
   384   \frametitle{History/Logs cont...}
   334 By default it returns complete logs of all changes. To make it selective use:
   385   By default \typ{log} returns complete list of all changes. \\
       
   386   For selective view try:
   335 \begin{lstlisting}
   387 \begin{lstlisting}
   336   $ hg log -r 3
   388 $ hg log -r 3
   337   $ hg log -r 2:4
   389 $ hg log -r 2:4
   338 \end{lstlisting}
   390 \end{lstlisting}
   339   To see tip/latest commit history use:\\
   391   tip/latest changes can be seen via:
   340 \typ{$ hg tip} \\ %$
   392   \begin{lstlisting}
   341   \inctime{5}
   393 $ hg tip    
   342 \end{frame}
   394   \end{lstlisting} %%$
   343 
   395   \inctime{10}
   344 \begin{frame}[fragile]
   396 \end{frame}
   345   \frametitle{Adding files}
   397 
   346   We will revisit the Fevicol repo we created earlier.
   398 \begin{frame}[fragile]
       
   399   \frametitle{Advancing through state: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.\\
       
   401   We will use the Fevicol repo we created earlier.
   347   \begin{lstlisting}
   402   \begin{lstlisting}
   348 $ cd Fevicol
   403 $ cd Fevicol
   349 $ hg log
   404 $ hg log
   350 $ hg st
   405 $ hg st
   351 ? feviStick.py
   406 ? feviStick.py
   352   \end{lstlisting} %$
   407   \end{lstlisting} %%$
   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.
   408   \typ{st} (aka status) is command to show changed files in the working directory.\\
       
   409 \end{frame}
       
   410 
       
   411 \begin{frame}[fragile]
       
   412   \frametitle{Adding files}
       
   413   "?" indicates that these file are aliens to track record.\\
       
   414   \typ{add} command is available to add new files to present structure.
   354   \begin{lstlisting}
   415   \begin{lstlisting}
   355 $ hg add feviStick.py
   416 $ hg add feviStick.py
   356 $ hg st
   417 $ hg st
   357 A feviStick.py
   418 A feviStick.py
   358   \end{lstlisting}
   419   \end{lstlisting}
   359 \end{frame}
   420 \end{frame}
   360 
   421 
   361 \begin{frame}[fragile]
   422 \begin{frame}[fragile]
   362   \frametitle{Committing changes}
   423   \frametitle{Saving present stage: committing}
   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:
   424   \emphbar{This is equivalent to completing tasks, before reaching a stage where you want to save.}
       
   425   \typ{hg} uses \typ{ci}(aka \typ{commit}) command to save changes. So after adding file, we have to commit it also:
   364   \begin{lstlisting}
   426   \begin{lstlisting}
   365 $ hg ci -u "Shantanu <shantanu@fossee.in>" 
   427 $ hg ci -u "Shantanu <shantanu@fossee.in>" 
   366         -m "First commit."
   428         -m "First commit."
   367 $ hg log
   429 $ hg log
   368 changeset:   0:84f5e91f4de1
   430 changeset:   0:84f5e91f4de1