|
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 %% There are some %$ used just to minimise the effect of $ sign used in lstlisting. In emacs it looks unhealthy. |
|
122 |
|
123 % Introduction to course-need of version control, history, options available. |
|
124 \section{Introduction} |
|
125 |
|
126 \begin{frame} |
|
127 \frametitle{What is Version Control?} |
|
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.'' |
|
130 \end{block} |
|
131 \pause |
|
132 \begin{block}{} |
|
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} |
|
135 \end{frame} |
|
136 |
|
137 \begin{frame} |
|
138 \frametitle{Motivation behind such tools} |
|
139 \begin{itemize} |
|
140 \item Track the history and evolution of a program. |
|
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'' |
|
143 \end{itemize} |
|
144 \end{frame} |
|
145 |
|
146 %% Introduction to how logs are managed in VCS. |
|
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?} |
|
170 \begin{itemize} |
|
171 \item It keeps track of changes you make to a file. You can improvise, revisit, and amend. |
|
172 \item All procedure is logged/recorded, so you and others can follow the development cycle. |
|
173 \end{itemize} |
|
174 \end{frame} |
|
175 |
|
176 \begin{frame} |
|
177 \frametitle{Do we really need this?} |
|
178 \emphbar{For team of people working remotely(even different computers/machines) on a project, use of version control is inevitable!} |
|
179 \vspace{0.15in} |
|
180 \emphbar{For single person: managing projects and assignments becomes easy} |
|
181 \vspace{0.15in} |
|
182 \pause |
|
183 \emphbar{\color{red}{It is a good habit!}} |
|
184 \end{frame} |
|
185 |
|
186 \begin{frame} |
|
187 \frametitle{Whats on the menu!} |
|
188 \begin{itemize} |
|
189 \item cvs (Concurrent Version System) |
|
190 \item svn (Subversion) |
|
191 \item hg (Mercurial) |
|
192 \item bzr (Bazaar) |
|
193 \item git |
|
194 \end{itemize} |
|
195 \inctime{10} |
|
196 \end{frame} |
|
197 |
|
198 % Introduction to jargon |
|
199 \section{Learning the Lingo!} |
|
200 |
|
201 \begin{frame} |
|
202 \frametitle{Common jargon: Basic setup} |
|
203 \begin{itemize} |
|
204 \item Repository(repo):\\ |
|
205 The folder with all files. |
|
206 \item Server:\\ |
|
207 Machine with main inventory/repo. |
|
208 \item Client:\\ |
|
209 Local machines with copy of main repo. |
|
210 \end{itemize} |
|
211 \end{frame} |
|
212 |
|
213 \begin{frame} |
|
214 \frametitle{Actions} |
|
215 \begin{itemize} |
|
216 \item Add:\\ |
|
217 Adding file into the repo for the first time. |
|
218 \item Version:\\ |
|
219 Version number(Die Hard 4.0). |
|
220 \item Head/Tip:\\ |
|
221 Most recent revision/stage. |
|
222 \item Check out/Clone:\\ |
|
223 Initial download of working copy. |
|
224 \item Commit:\\ |
|
225 Saving(recording) a change. |
|
226 \item Change log/History:\\ |
|
227 List of all past changes. |
|
228 \end{itemize} |
|
229 \end{frame} |
|
230 |
|
231 \begin{frame} |
|
232 \frametitle{Actions cont...} |
|
233 \begin{itemize} |
|
234 \item Branch:\\ |
|
235 Separate local copy for bug fixing, testing. |
|
236 \item Diff/Change:\\ |
|
237 Changes made in a file in two different versions. |
|
238 \item Merge (or patch):\\ |
|
239 Appling the changes to file, to make it up-to-date. |
|
240 \item Conflict:\\ |
|
241 When merging a file is not obvious. |
|
242 \item Resolve:\\ |
|
243 Fixing the conflict manually. |
|
244 \end{itemize} |
|
245 \end{frame} |
|
246 |
|
247 % Types of Version Controls |
|
248 \section{Types of VCS} |
|
249 |
|
250 \begin{frame} |
|
251 \frametitle{Types:} |
|
252 Based on ways of managing the repo there are two types of VCS: |
|
253 \begin{itemize} |
|
254 \item Centralized VCS\\ |
|
255 cvs, svn fall under this category. |
|
256 \item Distributed VCS\\ |
|
257 hg, bzr, git follows this methodology. |
|
258 \end{itemize} |
|
259 \emphbar{We would be covering \typ{hg}} |
|
260 \end{frame} |
|
261 |
|
262 \begin{frame} |
|
263 \frametitle{Why hg?} |
|
264 \includegraphics[height=.75in, interpolate=true]{mercurial} |
|
265 \begin{itemize} |
|
266 \item Easy to learn and use. |
|
267 \item Lightweight. |
|
268 \item Scales excellently. |
|
269 \item Written in Python. |
|
270 \end{itemize} |
|
271 \inctime{10} |
|
272 \end{frame} |
|
273 |
|
274 % Initializing the repo, cloning, committing changes, pushing, pulling to repo. |
|
275 \section{Getting Started} |
|
276 |
|
277 \begin{frame}[fragile] |
|
278 \frametitle{Getting comfortable:} |
|
279 For checking \typ{hg} installation and its version try: |
|
280 \begin{lstlisting} |
|
281 $ hg version |
|
282 \end{lstlisting} |
|
283 To get broad help on \typ{hg} and commands available: |
|
284 \begin{lstlisting} |
|
285 $ man hg |
|
286 $ hg help |
|
287 \end{lstlisting} |
|
288 To get help on particular \typ{hg} related option try: |
|
289 \begin{lstlisting} |
|
290 $ hg help diff |
|
291 \end{lstlisting} %$ |
|
292 \end{frame} |
|
293 |
|
294 \begin{frame}[fragile] |
|
295 \frametitle{Getting working/existing code base} |
|
296 \typ{clone} is used to make a copy of an existing repository. It can be both local or remote. |
|
297 \begin{lstlisting} |
|
298 $ hg clone |
|
299 http://hg.serpentine.com/tutorial/hello |
|
300 localCopyhello |
|
301 \end{lstlisting} |
|
302 And we get a local copy of this repository. |
|
303 \begin{lstlisting} |
|
304 $ ls localCopyhello/ |
|
305 hello.c Makefile |
|
306 \end{lstlisting} |
|
307 \end{frame} |
|
308 |
|
309 \begin{frame}[fragile] |
|
310 \frametitle{To start track-record on existing files} |
|
311 I have some files which I want to bring under version control. \typ{hg} provides \typ{init} command for this: |
|
312 \begin{lstlisting} |
|
313 $ ls -a circulate/ |
|
314 . .. lena.png pendulum.txt points.txt pos.txt sslc1.py sslc1.txt |
|
315 $ cd circulate/ |
|
316 $ hg init |
|
317 $ ls -a |
|
318 . .. .hg lena.png pendulum.txt points.txt pos.txt sslc1.py sslc1.txt |
|
319 \end{lstlisting} |
|
320 \emphbar{\typ{.hg} directory keeps log of changes made henceforth.} |
|
321 \end{frame} |
|
322 |
|
323 \begin{frame}[fragile] |
|
324 \frametitle{Starting fresh} |
|
325 We can use \typ{init} to start a new repository also |
|
326 \begin{lstlisting} |
|
327 $ mkdir Fevicol |
|
328 $ cd Fevicol/ |
|
329 $ echo "print 'Yeh Fevicol ka majboot |
|
330 jod hai'" > feviStick.py |
|
331 $ ls -a |
|
332 . .. feviStick.py |
|
333 $ hg init |
|
334 $ ls -a |
|
335 . .. feviStick.py .hg |
|
336 \end{lstlisting} |
|
337 \end{frame} |
|
338 |
|
339 \begin{frame}[fragile] |
|
340 \frametitle{Making copies: Branching} |
|
341 All \typ{hg} repositories are self-contained, and independent which can be copied(cloned): |
|
342 \begin{lstlisting} |
|
343 $ hg clone localCopyhello newCopy |
|
344 updating working directory |
|
345 2 files updated, 0 files merged, |
|
346 0 files removed, 0 files unresolved |
|
347 \end{lstlisting} |
|
348 or |
|
349 \begin{lstlisting} |
|
350 $ hg clone Fevicol Fevicol-pull |
|
351 updating working directory |
|
352 0 files updated, 0 files merged, |
|
353 0 files removed, 0 files unresolved |
|
354 \end{lstlisting} |
|
355 \inctime{20} |
|
356 \end{frame} |
|
357 |
|
358 %% Should we here stress on how are distribute VCS have |
|
359 %% different approach then centralized ones? Maybe a pic |
|
360 %% or some other graphical representation. |
|
361 \begin{frame}[fragile] |
|
362 \frametitle{Revisiting saved points:history/logs} |
|
363 In \typ{hg}, the difference between consecutive stages is termed as changeset.\\ |
|
364 Once we have saved stages, we need a mechanism to review and access them, for that use \typ{log} command. |
|
365 \begin{lstlisting} |
|
366 $ cd localCopyhello |
|
367 $ hg log |
|
368 \end{lstlisting} |
|
369 \end{frame} |
|
370 |
|
371 \begin{frame}[fragile] |
|
372 \frametitle{Understanding output} |
|
373 The output provides following information: |
|
374 \begin{itemize} |
|
375 \item changeset: Identifiers for the changeset. |
|
376 \item user: Person who created the changeset. |
|
377 \item date: Date and time of creation of changeset. |
|
378 \item summary: One line description. |
|
379 \end{itemize} |
|
380 \end{frame} |
|
381 |
|
382 \begin{frame}[fragile] |
|
383 \frametitle{History/Logs cont...} |
|
384 By default \typ{log} returns complete list of all changes. \\ |
|
385 For selective view try: |
|
386 \begin{lstlisting} |
|
387 $ hg log -r 3 |
|
388 $ hg log -r 2:4 |
|
389 \end{lstlisting} |
|
390 tip/latest changes can be seen via: |
|
391 \begin{lstlisting} |
|
392 $ hg tip |
|
393 \end{lstlisting} %%$ |
|
394 \inctime{5} |
|
395 \end{frame} |
|
396 |
|
397 \begin{frame}[fragile] |
|
398 \frametitle{Advancing through a stage:status} |
|
399 We often need to add/delete some files from directory(repo). The structure keeps on evolving, and tools for handling them are needed.\\ |
|
400 We will use the Fevicol repo we created earlier. |
|
401 \begin{lstlisting} |
|
402 $ cd Fevicol |
|
403 $ hg log |
|
404 $ hg st |
|
405 ? feviStick.py |
|
406 \end{lstlisting} %%$ |
|
407 \typ{st} (aka status) is command to show changed files in the working directory.\\ |
|
408 \end{frame} |
|
409 |
|
410 %% track record is confusing for some. Duma have some doubts :( |
|
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. |
|
415 \begin{lstlisting} |
|
416 $ hg add feviStick.py |
|
417 $ hg st |
|
418 A feviStick.py |
|
419 \end{lstlisting} |
|
420 \end{frame} |
|
421 |
|
422 \begin{frame}[fragile] |
|
423 \frametitle{Saving present stage: committing} |
|
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: |
|
426 \begin{lstlisting} |
|
427 $ hg ci -u "Shantanu <shantanu@fossee.in>" |
|
428 -m "First commit." |
|
429 $ hg log |
|
430 changeset: 0:84f5e91f4de1 |
|
431 tag: tip |
|
432 user: Shantanu <shantanu@fossee.in> |
|
433 date: Fri Aug 21 23:37:13 2009 +0530 |
|
434 summary: First commit. |
|
435 \end{lstlisting} |
|
436 \end{frame} |
|
437 |
|
438 \begin{frame}[fragile] |
|
439 \frametitle{Other operations} |
|
440 \typ{hg} supports basic file-management functions like copy, remove, rename etc. |
|
441 \begin{lstlisting} |
|
442 $ hg cp feviStick.py pidiLite.py |
|
443 $ hg rename pidiLite.py feviCol.py |
|
444 $ hg st |
|
445 A feviCol.py |
|
446 $ hg ci -u "Shantanu <shantanu@fossee.in>" |
|
447 -m "Added feviCol.py." |
|
448 $ hg tip| grep summary |
|
449 summary: Added feviCol.py. |
|
450 \end{lstlisting} %$ |
|
451 %% Other commands which can be handy are \typ{remove}, \typ{revert} etc. |
|
452 \inctime{10} |
|
453 \end{frame} |
|
454 |
|
455 % Introduction to concepts of branches, merging patch? |
|
456 \section{Sharing and Collaborating} |
|
457 |
|
458 \begin{frame}[fragile] |
|
459 \frametitle{Distributing changes} |
|
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} |
|
467 \begin{lstlisting} |
|
468 $ hg pull |
|
469 pulling from /home/baali/Fevicol |
|
470 requesting all changes |
|
471 adding changesets |
|
472 adding manifests |
|
473 adding file changes |
|
474 added 2 changesets with 2 changes to 2 files |
|
475 (run 'hg update' to get a working copy) |
|
476 \end{lstlisting} %$ |
|
477 \end{frame} |
|
478 |
|
479 \begin{frame}[fragile] |
|
480 \frametitle{Pulling changesets cont...} |
|
481 \typ{pull} command doesn't update current directory, it just imports changesets. To add all these changes, use \typ{up}: |
|
482 \begin{lstlisting} |
|
483 $ cd Fevicol-pull |
|
484 $ ls -a |
|
485 . .. .hg |
|
486 $ hg up |
|
487 2 files updated, 0 files merged, |
|
488 0 files removed, 0 files unresolved |
|
489 $ ls -a |
|
490 . .. feviCol.py feviStick.py .hg |
|
491 \end{lstlisting} |
|
492 \pause |
|
493 \emphbar{Why \typ{pull} and \typ{up} are needed separately?} |
|
494 \end{frame} |
|
495 |
|
496 \begin{frame}[fragile] |
|
497 \frametitle{Making changes across branches} |
|
498 \begin{lstlisting} |
|
499 $ cd Fevicol-pull/ |
|
500 \end{lstlisting} %$ |
|
501 Lets edit and correct the feviStick.py |
|
502 \begin{lstlisting} |
|
503 $ echo "print 'Ab no more Chip Chip'" |
|
504 > feviStick.py |
|
505 $ hg st |
|
506 M feviStick.py |
|
507 \end{lstlisting} |
|
508 'M' sign indicates that \typ{hg} has noticed change.\\ |
|
509 \end{frame} |
|
510 |
|
511 \begin{frame}[fragile] |
|
512 \frametitle{Revisiting changes} |
|
513 To view changes made \typ{hg} provides \typ{diff}: |
|
514 \begin{lstlisting} |
|
515 $ hg diff |
|
516 diff -r a7912d45f47c feviStick.py |
|
517 --- a/feviStick.py Sun Aug 23 22:34:35 2009 +0530 |
|
518 +++ b/feviStick.py Sun Aug 23 22:47:49 2009 +0530 |
|
519 @@ -1,1 +1,1 @@ |
|
520 -print 'Yeh Fevicol ka Majboot jod hai' |
|
521 +print 'Ab no more Chip Chip' |
|
522 \end{lstlisting} %$ |
|
523 \end{frame} |
|
524 |
|
525 \begin{frame}[fragile] |
|
526 \frametitle{Saving the changes} |
|
527 We have to commit these changes. |
|
528 \begin{lstlisting} |
|
529 $ hg ci -u "Shantanu <shantanu@fossee.in>" |
|
530 -m "Changed tagline for feviStick.py." |
|
531 \end{lstlisting} %$ |
|
532 \end{frame} |
|
533 |
|
534 \begin{frame}[fragile] |
|
535 \frametitle{Syncing two repos} |
|
536 To bring both the repos at same stage we have to \typ{push} differences. |
|
537 \begin{lstlisting} |
|
538 $ hg push |
|
539 pushing to /home/baali/Fevicol |
|
540 searching for changes |
|
541 adding changesets |
|
542 adding manifests |
|
543 adding file changes |
|
544 added 1 changesets with 1 changes to 1 files |
|
545 \end{lstlisting} %$ |
|
546 \end{frame} |
|
547 |
|
548 \begin{frame}[fragile] |
|
549 \frametitle{Syncing cont...} |
|
550 Same as pulling, pushing wont update the main directory by default. |
|
551 \begin{lstlisting} |
|
552 $ cd Fevicol |
|
553 $ hg tip |
|
554 $ cat feviStick.py |
|
555 \end{lstlisting} |
|
556 \typ{tip} shows latest changeset, but content of file are not updated. We have to use \typ{up} on main branch |
|
557 \begin{lstlisting} |
|
558 $ hg up |
|
559 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
560 \end{lstlisting} %$ |
|
561 \inctime{15} |
|
562 \end{frame} |
|
563 |
|
564 \begin{frame}[fragile] |
|
565 \frametitle{Merging: Scenario} |
|
566 One very useful feature is merging work of different peers working on same project.\\ |
|
567 We consider scenario, two person on one project, both have local copies, and one among them is main branch.\\ |
|
568 \begin{center} |
|
569 \includegraphics[height=1in, interpolate=true]{scenario} |
|
570 \end{center} |
|
571 \end{frame} |
|
572 |
|
573 \begin{frame}[fragile] |
|
574 \frametitle{Making changes to one of repo} |
|
575 \begin{lstlisting} |
|
576 $ cd Fevicol-pull |
|
577 $ echo "print 'Yeh Fevicol ka Majboot jod |
|
578 hai, tootega nahin'" > feviCol.py |
|
579 $ hg st |
|
580 M feviStick.py |
|
581 $ hg ci -u "Shantanu <shantanu@fossee.in>" |
|
582 -m "Updated tag line for feviCol.py." |
|
583 $ hg tip| grep changeset |
|
584 changeset: 3:caf986b15e05 |
|
585 \end{lstlisting} %$ |
|
586 \end{frame} |
|
587 |
|
588 \begin{frame}[fragile] |
|
589 \frametitle{In the meanwhile, other repo is ...} |
|
590 \begin{lstlisting} |
|
591 $ cd Fevicol |
|
592 $ echo "print 'Jor laga ke hayyiya'" |
|
593 > firstAdd.py |
|
594 $ hg add |
|
595 $ hg st |
|
596 A firstAdd.py |
|
597 $ hg ci -u "Shantanu <shantanu@fossee.in>" |
|
598 -m "Added firsAdd.py." |
|
599 $ hg tip|grep changeset |
|
600 changeset: 3:fadbd6492cc4 |
|
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} |
|
618 \end{frame} |
|
619 |
|
620 \begin{frame}[fragile] |
|
621 \frametitle{Merging} |
|
622 \emphbar{Lets sync both these branches!} |
|
623 \begin{lstlisting} |
|
624 $ hg pull ../Fevicol-pull |
|
625 pulling from ../Fevicol-pull |
|
626 searching for changes |
|
627 adding changesets |
|
628 adding manifests |
|
629 adding file changes |
|
630 added 1 changesets with 1 changes to 1 files (+1 heads) |
|
631 (run 'hg heads' to see heads, 'hg merge' to merge) |
|
632 \end{lstlisting} %$ |
|
633 \begin{itemize} |
|
634 \item \typ{pull} can be done from a branch explicitly also. |
|
635 \item Output is already suggesting something! |
|
636 \end{itemize} |
|
637 \end{frame} |
|
638 |
|
639 %% Here one can mention the point of having push and pull separate. Because of this policy, changes made are not lost. |
|
640 \begin{frame}[fragile] |
|
641 \frametitle{Analyzing events in detail} |
|
642 Since hg \typ{pull} don't update the files directly, our changes are still safe. \typ{hg} provides some commands to help understand such problems. |
|
643 \begin{tiny} |
|
644 \begin{lstlisting} |
|
645 $ hg heads |
|
646 changeset: 4:c5f40fda69cf |
|
647 tag: tip |
|
648 parent: 2:0b8286c48e88 |
|
649 user: Shantanu <shantanuc@fosse.in> |
|
650 date: Fri Jan 22 19:43:46 2010 +0530 |
|
651 summary: Updated tagline for feviCol.py. |
|
652 |
|
653 changeset: 3:60edf0e499e7 |
|
654 user: Shantanu <shantanuc@fosse.in> |
|
655 date: Fri Jan 22 19:47:58 2010 +0530 |
|
656 summary: Added firstAdd.py. |
|
657 \end{lstlisting} %%$ |
|
658 \end{tiny} |
|
659 It shows current repository heads or show branch head |
|
660 \end{frame} |
|
661 |
|
662 \begin{frame}[fragile] |
|
663 \frametitle{What went wrong: Analysis} |
|
664 \begin{lstlisting} |
|
665 $ hg glog |
|
666 \end{lstlisting} %%$ |
|
667 \begin{center} |
|
668 \includegraphics[height=2in]{glog} |
|
669 \end{center} |
|
670 It shows history alongside an ASCII revision graph. |
|
671 \end{frame} |
|
672 |
|
673 \begin{frame}[fragile] |
|
674 \frametitle{What went wrong: Analysis cont...} |
|
675 Because of different 'pasts', \typ{up} command fails. |
|
676 \begin{lstlisting} |
|
677 $ hg up |
|
678 abort: crosses branches (use 'hg merge' or 'hg update -C') |
|
679 \end{lstlisting} %$ |
|
680 \end{frame} |
|
681 |
|
682 \begin{frame}[fragile] |
|
683 \frametitle{Merging} |
|
684 To deal such situations \typ{hg merge} command merge working directory with another revision. |
|
685 \begin{lstlisting} |
|
686 $ hg merge |
|
687 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
688 (branch merge, don't forget to commit) |
|
689 \end{lstlisting} %$ |
|
690 After merging two branches, we have to commit the results to create a common head. |
|
691 \begin{lstlisting} |
|
692 $ hg ci -u "Shantanu <shantanu@fossee.in>" |
|
693 -m "Merged branches." |
|
694 \end{lstlisting} %$ |
|
695 \inctime{15} |
|
696 \end{frame} |
|
697 |
|
698 \begin{frame}[fragile] |
|
699 \frametitle{\typ{glog}} |
|
700 \begin{center} |
|
701 \includegraphics[height=2.8in]{glog-2} |
|
702 \end{center} |
|
703 \end{frame} |
|
704 |
|
705 \begin{frame}[fragile] |
|
706 \frametitle{More information} |
|
707 \begin{itemize} |
|
708 \item \typ{merge} fails if there are conflicting changes. |
|
709 \begin{itemize} |
|
710 \item Like two persons editing same file, same line and pushing it upstream. |
|
711 \end{itemize} |
|
712 \item In conflicts, one have to perform \typ{merge} manually. |
|
713 \item \typ{hg} provides \typ{incoming} command, which checks the would-be imported changes |
|
714 \begin{itemize} |
|
715 \item To avoid conflicting changes before importing. |
|
716 \end{itemize} |
|
717 \end{itemize} |
|
718 \end{frame} |
|
719 |
|
720 % Steps to follow to make life easier. How to avoid/handle manual merges. |
|
721 \section{Work flow: DOS and DON'Ts} |
|
722 |
|
723 \begin{frame} |
|
724 \frametitle{Motto behind hg} |
|
725 \begin{center} |
|
726 \color{red}{``Commit Early Commit Often.''} |
|
727 \end{center} |
|
728 \end{frame} |
|
729 |
|
730 \begin{frame} |
|
731 \frametitle{Cheat Sheet} |
|
732 \begin{center} |
|
733 \includegraphics[height=2.8in]{mod} |
|
734 \end{center} |
|
735 \end{frame} |
|
736 |
|
737 \begin{frame} |
|
738 \frametitle{Steps to be followed} |
|
739 \begin{itemize} |
|
740 \item Make changes. |
|
741 \item Commit. |
|
742 \item Pull changesets. |
|
743 \item Merge(if required). |
|
744 \item Push. |
|
745 \end{itemize} |
|
746 \inctime{20} |
|
747 \end{frame} |
|
748 |
|
749 \begin{frame} |
|
750 \frametitle{Suggested Readings:} |
|
751 \begin{itemize} |
|
752 \item \url{http://mercurial.selenic.com/guide/} |
|
753 \item \url{http://hgbook.red-bean.com/} |
|
754 \item \url{http://karlagius.com/2009/01/09/version-control-for-the-masses/} |
|
755 \item Articles related to version control available on \url{http://betterexplained.com/} |
|
756 \item \url{http://en.wikipedia.org/wiki/Revision_control} |
|
757 \item \url{http://wiki.alliedmods.net/Mercurial_Tutorial} |
|
758 \item Mario game images are taken from wikipedia. |
|
759 \end{itemize} |
|
760 \end{frame} |
|
761 \end{document} |
|
762 |
|
763 Notes |
|
764 ----- |
|
765 |
|
766 From http://mercurial.selenic.com/ |
|
767 |
|
768 Quick Start |
|
769 |
|
770 Clone a project and push changes |
|
771 |
|
772 $ hg clone http://selenic.com/repo/hello |
|
773 $ cd hello |
|
774 $ (edit files) |
|
775 $ hg add (new files) |
|
776 $ hg commit -m 'My changes' |
|
777 $ hg push |
|
778 |
|
779 |
|
780 Create a project and commit |
|
781 |
|
782 $ hg init (project-directory) |
|
783 $ cd (project-directory) |
|
784 $ (add some files) |
|
785 $ hg add |
|
786 $ hg commit -m 'Initial commit' |