Merged mainline branch and Madhu branch.
authorMadhusudan.C.S <madhusudancs@gmail.com>
Wed, 09 Sep 2009 14:39:47 +0530
changeset 48 7a9acbaa9faa
parent 47 e724f1ee6e51 (current diff)
parent 45 9200c7887c57 (diff)
child 52 9748190df418
Merged mainline branch and Madhu branch.
--- a/basic_python/intro.rst	Wed Sep 09 00:38:40 2009 +0530
+++ b/basic_python/intro.rst	Wed Sep 09 14:39:47 2009 +0530
@@ -1,6 +1,6 @@
-=====================
-Basic Python Workshop
-=====================
+============
+Basic Python
+============
 
 This document is intended to be handed out at the end of the workshop. It has
 been designed for Engineering students who are Python beginners and have basic
@@ -8,11 +8,11 @@
 
 The system requirements:
   * Python - version 2.5.x or newer.
-  * IPython 
+  * IPython
   * Text editor - scite, vim, emacs or whatever you are comfortable with.
 
-1. Introduction
-===============
+Introduction
+============
 
 The Python programming language was created by a dutch named Guido van Rossum.
 The idea of Python was conceived in December 1989. The name Python has nothing
@@ -78,11 +78,11 @@
 up for this setback.
 
 
-1.1 The Python Interpreter
---------------------------
+The Python Interpreter
+======================
 
-1.1.1 The Interactive Interpreter
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+The Interactive Interpreter
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 Typing *python* at the shell prompt on any standard Unix/Gnu-Linux system and
 hitting the enter key fires up the Python 'Interactive Interpreter'. The Python
@@ -196,8 +196,8 @@
   This example is to show that unlike in C or C++ there is no limit on the
   value of an integer.
 
-1.1.2 *ipython* - An enhanced interactive Python interpreter
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+*ipython* - An enhanced interactive Python interpreter
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 The power and the importance of the interactive interpreter was the highlight
 of the previous section. This section provides insight into the enhanced
@@ -222,32 +222,24 @@
 change based on the Python version installed. The following are some of the
 various features provided by **ipython**:
   
-  * Suggestions - ipython provides suggestions of the possible methods and
+    Suggestions - ipython provides suggestions of the possible methods and
     operations available for the given python object.
 
-Eg:
+Eg 5:
   
 ::
   
   In [4]: a = 6
   
   In [5]: a.
-  a.__abs__           a.__divmod__        a.__index__         a.__neg__       
-    a.__rand__          a.__rmod__          a.__rxor__
-  a.__add__           a.__doc__           a.__init__          a.__new__       
-    a.__rdiv__          a.__rmul__          a.__setattr__
-  a.__and__           a.__float__         a.__int__           a.__nonzero__   
-    a.__rdivmod__       a.__ror__           a.__str__
-  a.__class__         a.__floordiv__      a.__invert__        a.__oct__       
-    a.__reduce__        a.__rpow__          a.__sub__
-  a.__cmp__           a.__getattribute__  a.__long__          a.__or__        
-    a.__reduce_ex__     a.__rrshift__       a.__truediv__
-  a.__coerce__        a.__getnewargs__    a.__lshift__        a.__pos__      
-    a.__repr__          a.__rshift__        a.__xor__
-  a.__delattr__       a.__hash__          a.__mod__           a.__pow__      
-    a.__rfloordiv__     a.__rsub__          
-  a.__div__           a.__hex__           a.__mul__           a.__radd__     
-    a.__rlshift__       a.__rtruediv__      
+  a.__abs__           a.__divmod__        a.__index__         a.__neg__          a.__rand__          a.__rmod__          a.__rxor__
+  a.__add__           a.__doc__           a.__init__          a.__new__          a.__rdiv__          a.__rmul__          a.__setattr__
+  a.__and__           a.__float__         a.__int__           a.__nonzero__      a.__rdivmod__       a.__ror__           a.__str__
+  a.__class__         a.__floordiv__      a.__invert__        a.__oct__          a.__reduce__        a.__rpow__          a.__sub__
+  a.__cmp__           a.__getattribute__  a.__long__          a.__or__           a.__reduce_ex__     a.__rrshift__       a.__truediv__
+  a.__coerce__        a.__getnewargs__    a.__lshift__        a.__pos__          a.__repr__          a.__rshift__        a.__xor__
+  a.__delattr__       a.__hash__          a.__mod__           a.__pow__          a.__rfloordiv__     a.__rsub__          
+  a.__div__           a.__hex__           a.__mul__           a.__radd__         a.__rlshift__       a.__rtruediv__      
 
 In this example, we initialized 'a' (a variable - a concept that will be
 discussed in the subsequent sections.) to 6. In the next line when the *tab* key
@@ -256,7 +248,164 @@
 provides many such datatype specific features which will be presented in the
 further sections as and when the datatypes are introduced.
 
-1.2 Editing and running a python file
--------------------------------------
+Editing and running a python file
+=================================
+
+The previous sections focused on the use of the interpreter to run python code.
+While the interpeter is an excellent tool to test simple solutions and
+experiment with small code snippets, its main disadvantage is that everything
+written in the interpreter is lost once its quit. Most of the times a program is 
+used by people other than the author. So the programs have to be available in 
+some form suitable for distribution, and hence they are written in files. This 
+section will focus on editing and running python files. Start by opening a text 
+editor ( it is recommended you choose one from the list at the top of this page ).
+In the editor type down python code and save the file with an extension **.py** 
+(python files have an extension of .py). Once done with the editing, save the 
+file and exit the editor. 
+
+Let us look at a simple example of calculating the gcd of 2 numbers using Python:
+
+**Creating the first python script(file)**
+::
+
+  $ emacs gcd.py
+    def gcd(x,y):
+      if x % y == 0:
+        return y
+      return gcd(y, x%y)
+  
+    print gcd(72, 92)
+
+To run the script, open the shell prompt, navigate to the directory that 
+contains the python file and run `python <filename.py>` at the prompt ( in this 
+case filename is gcd.py )
+
+**Running the python script**
+::
+  
+  $ python gcd.py
+  4
+  $ 
+
+Another method to run a python script would be to include the line
+
+`#! /usr/bin/python`
+
+at the beginning of the python file and then make the file executable by 
+
+$ chmod a+x *filename.py*
+
+Once this is done, the script can be run as a standalone program as follows:
+
+$ ./*filename.py*
+
+Basic Datatypes and operators in Python
+=======================================
+
+Python provides the following set of basic datatypes.
+
+  * Numbers: int, float, long, complex
+  * Strings
+  * Boolean
+
+Numbers
+~~~~~~~
+
+Numbers were introduced in the examples presented in the interactive interpreter
+section. Numbers include types as mentioned earlier viz., int (integers), float 
+(floating point numbers), long (large integers), complex (complex numbers with 
+real and imaginary parts). Python is not a strongly typed language, which means 
+the type of a variable need not mentioned during its initialization. Let us look
+at a few examples.
+
+Eg 6:
+::
+  
+  >>> a = 1 #here a is an integer variable
+
+Eg 7:
+::
 
-The 
\ No newline at end of file
+  >>> lng = 122333444455555666666777777788888888999999999 #here lng is a variable of type long
+  >>> lng
+  122333444455555666666777777788888888999999999L #notice the trailing 'L'
+  >>> print lng
+  122333444455555666666777777788888888999999999 #notice the absence of the trailing 'L'
+  >>> lng+1
+  122333444455555666666777777788888889000000000L
+
+
+Long numbers are the same as integers in almost all aspects. They can be used in
+operations just like integers and along with integers without any distinction.
+The only distinction comes during type checking (which is not a healthy practice).
+Long numbers are tucked with a trailing 'L' just to signify that they are long.
+Notice that in the example just lng at the prompt displays the value of the variable
+with the 'L' whereas `print lng` displays without the 'L'. This is because print 
+formats the output before printing. Also in the example, notice that adding an 
+integer to a long does not give any errors and the result is as expected. So for
+all practical purposes longs can be treated as ints.
+
+Eg 8:
+::
+
+  >>> fl = 3.14159 #fl is a float variable
+  >>> e = 1.234e-4 #e is also a float variable, specified in the exponential form
+  >>> a = 1
+  >>> b = 2
+  >>> a/b #integer division
+  0
+  >>> a/fl #floating point division
+  0.31831015504887655
+  >>> e/fl
+  3.9279473133031364e-05
+
+
+Floating point numbers, simply called floats are real numbers with a decimal point.
+The example above shows the initialization of a float variable. Shown also in this
+example is the difference between integer division and floating point division.
+'a' and 'b' here are integer variables and hence the division gives 0 as the quotient.
+When either of the operands is a float, the operation is a floating point division,
+and the result is also a float as illustrated.
+
+Eg 9:
+::
+
+  >>> cplx = 3 + 4j #cplx is a complex variable
+  >>> cplx
+  (3+4j)
+  >>> print cplx.real #prints the real part of the complex number
+  3.0
+  >>> print cplx.imag #prints the imaginary part of the complex number
+  4.0
+  >>> print cplx*fl  #multiplies the real and imag parts of the complex number with the multiplier
+  (9.42477+12.56636j)
+  >>> abs(cplx) #returns the absolute value of the complex number
+  5.0
+
+Python provides a datatype for complex numbers. Complex numbers are initialized 
+as shown in the example above. The *real* and *imag* operators return the real and
+imaginary parts of the complex number as shown. The *abs()* returns the absolute
+value of the complex number.
+
+Variables
+~~~~~~~~~
+
+Variables are just names that represent a value. Variables have already been 
+introduced in the various examples from the previous sections. Certain rules about
+using variables:
+
+  * Variables have to be initialized or assigned a value before being used.
+  * Variable names can consist of letters, digits and underscores(_).
+  * Variable names cannot begin with digits, but can contain digits in them.
+
+In reference to the previous section examples, 'a', 'b', 'lng', 'fl', 'e' and 'cplx'
+are all variables of various datatypes.
+
+::
+  
+  Note: Python is not a strongly typed language and hence an integer variable can at a
+  later stage be used as a float variable as well.
+
+Strings
+~~~~~~~
+
--- a/ult/Using_Linux_Tools.rst	Wed Sep 09 00:38:40 2009 +0530
+++ b/ult/Using_Linux_Tools.rst	Wed Sep 09 14:39:47 2009 +0530
@@ -1,5 +1,5 @@
-1. Introduction to the Course
-=============================
+Introduction to the Course
+==========================
 
 Engineering students use computers for a large number of curricular
 tasks – mostly computation centred. However, they do not see this as coding or programming tasks and usually are not even aware of the tools and
@@ -33,14 +33,16 @@
 
 - write unit tests and improve the quality of code.
 
-2. Introducing Linux
-=====================
+Introducing Linux
+=================
+
+(Attribution : A significant chunk of the content under this section is based on data from Wikipedia and the Linux Documentation Project)
 
-Linux (commonly pronounced ˈlɪnəks') is a generic term referring to Unix-like computer operating systems based on the Linux kernel. Their development is one of the most prominent examples of free and open source software collaboration; typically all the underlying source code can be used, freely modified, and redistributed by anyone under the terms of the GNU Global Public License (GPL) and other free software licences.
+Linux (usually pronounced ˈlɪnəks') is a generic term referring to Unix-like computer operating systems based on the Linux kernel. The development of the Linux OS is considered the basis for Free and Open Source Software (FOSS) collaboration since typically the underlying source code can be used, modified freely, and redistributed by anyone under the terms of the GNU Global Public License (GPL) and other free software licences.
 
-Linux is predominantly known for its use in servers, although it is installed on a wide variety of computer hardware, ranging from embedded devices and mobile phones to supercomputers. 
+Linux is installed on a variety of computer hardware, that include mobile phones, embedded devices and supercomputers, but is infamous for its use in servers.
 
-The name "Linux"  comes from the Linux kernel, originally written in 1991 by Linus Torvalds. The rest of the system usually comprises components such as the Apache HTTP Server, the X Window System, the GNOME and KDE desktop environments, and utilities and libraries from the GNU Project (announced in 1983 by Richard Stallman). Commonly-used applications with desktop Linux systems include the Mozilla Firefox web-browser and the OpenOffice.org office application suite. The GNU contribution is the basis for the Free Software Foundation's preferred name GNU/Linux
+The name "Linux"  comes from the Linux kernel, originally written in 1991 by Linus Torvalds. The rest of the system usually comprises components such as the Apache HTTP Server, the X Window System, the GNOME and KDE desktop environments, and utilities and libraries from the GNU Project (announced in 1983 by Richard Stallman). Commonly-used applications with desktop Linux systems include the Mozilla Firefox web-browser and the OpenOffice.org office application suite. The GNU contribution is the basis for the Free Software Foundation's preferred name GNU/Linux. The kernel's mascot is a penguin named "Tux".
 
 Historical Background
 ----------------------
@@ -63,7 +65,6 @@
 
 Torvalds continues to direct the development of the kernel. Stallman heads the Free Software Foundation, which in turn supports the GNU components. Finally, individuals and corporations develop third-party non-GNU components. These third-party components comprise a vast body of work and may include both kernel modules and user applications and libraries. Linux vendors and communities combine and distribute the kernel, GNU components, and non-GNU components, with additional package management software in the form of Linux distributions.
 
-For the 2.6.29 release only, the kernel's mascot, a penguin named Tux, was temporarily replaced by Tuz in order to highlight efforts to save the Tasmanian Devil from extinction.
 
 Design and Implications
 ------------------------
@@ -143,8 +144,9 @@
 
 Because Linux has been developed and tested by thousands of people, both errors and people to fix them are found very quickly. It often happens that there are only a couple of hours between discovery and fixing of a bug.
 
-3. Getting Started
-===================
+Getting Started
+================
+
 Logging in, activating the user interface and logging out
 ----------------------------------------------------------
 In order to work on a Linux system directly, you will need to provide a user name and password. You always need to authenticate to the system. Most PC−based Linux systems have two basic modes for a system to run in: either quick and sober in text console mode, which looks like DOS with mouse, multitasking and multi−user features, or in graphical console mode, which
@@ -192,5 +194,109 @@
 
 Logging out is done by entering the logout command, followed by Enter. You are successfully disconnected from the system when you see the login screen again.Don't power−off the computer after logging out. It is not meant to be shut off without application of the proper procedures for halting the system. Powering it off without going through the halting process might cause severe damage!
 
+Basic Commands
+===============
+
+ls
+---
+
+When invoked without any arguments, *ls* lists the files in the current working directory. A directory that is not the current working directory can be specified and ls will list the files there. The user also may specify any list of files and directories. In this case, all files and all contents of specified directories will be listed. The name *ls* is derived from *list segments* which was used in earlier systems.
+
+Files whose names start with "." are not listed, unless the *-a* flag is specified or the files are specified explicitly.
+
+Without options, *ls* displays files in a bare format. This bare format however makes it difficult to establish the type, permissions, and size of the files. The most common options to reveal this information or change the list of files are:
+
+    * *-l* long format, displaying Unix file types, permissions, number of hard links, owner, group, size, date, and filename
+    * *-F* appends a character revealing the nature of a file, for example, * for an executable, or / for a directory. Regular files have no suffix.
+    * *-a* lists all files in the given directory, including those whose names start with "." (which are hidden files in Unix). By default, these files are excluded from the list.
+    * *-R* recursively lists subdirectories. The command ls -R / would therefore list all files.
+    * *-d* shows information about a symbolic link or directory, rather than about the link's target or listing the contents of a directory.
+    * *-t* sort the list of files by modification time.
+    * *-h* print sizes in human readable format. (e.g., 1K, 234M, 2G, etc.)
+
+In some environments, providing the option *--color* (for GNU ls) or *-G* (FreeBSD ls) causes ls to highlight different types of files with different colors, instead of with characters as *-F* would. To determine what color to use for a file, GNU *ls* checks the Unix file type, the file permissions, and the file extension, while FreeBSD *ls* checks only the Unix file type and file permissions.::
+
+	$ ls
+	jeeves.rst psmith.html blandings.html
+	$ ls -l
+	drwxr--r--   1 plum  editors   4096  jeeves
+	-rw-r--r--   1 plum  editors  30405  psmith
+	-r-xr-xr-x   1 plum  plum      8460  blandings
 
 
+date
+------
+
+The Unix date command displays the time and date. The super-user can use it to set the system clock.
+
+With no options, the date command displays the current date and time, including the abbreviated day name, abbreviated month name, day of the month, the time separated by colons, the timezone name, and the year. For example::
+
+	$date
+	Tue Sep  8 12:01:45 IST 2009
+
+Options
+~~~~~~~~
+
+*-d, -de* : string display time described by string, not now.
+
+*-e* : datefile like de once for each line of datefile
+
+*-s, --set* : string set time described by string
+
+*-n* : don't synchronize the clocks on groups of machines using the utility timed(8). By default, if timed is running, date will set the time on all of the machines in the local group. *-n* inhibites that.
+
+*-u* : Display or set the date in UTC (universal) time.
+
+*date [-u|--utc|--universal] [mmddHHMM[[cc]yy].SS* : The only valid option for the this form specifies Coordinated Universal Time.
+
+*-u GMT* : example - Sat Feb 5 14:49:42 GMT 2005
+
+*--utc, --universal* : Coordinated Universal Time, example - Tue Sep  8 07:05:54 UTC 2009
+
+*-ITIMESPEC, --iso-8601* [=TIMESPEC] : output date/time in ISO 8601 format. TIMESPEC=date for date only, hours, minutes, or seconds for date and time to the indicated precision.
+
+*--iso-8601* without TIMESPEC defaults to 'date'.
+
+*-R*, *--rfc-822* outputs RFC-822 compliant date string,
+example - Sat Feb 5 09:50:23 EST 2005
+
+*--help*
+
+The Single Unix Specification (SUS) mandates only one option: *-u*, where the date and time is printed as if the timezone was UTC+0. Other Unix and Unix-like systems provide extra options.
+
+The XSI extension to the SUS specifies that the date command can also be used to set the date. The new date is specified as an option to date in the format MMddhhmm[[cc]yy], where MM specifies the two-digit numeric month, dd specifies the two-digit numeric day, hh specifies the two-digit numeric hour, mm specifies the two-digit numeric minutes. Optionally cc specifies the first two digits of the year, and yy specifies the last two digits of the year.
+
+Other Unix and Unix-like systems may set different options or date formats for date, for example, on some systems to set the current date and time to September 8, 2004 01:22 you type::
+
+	$date --set="20040908 01:22"
+
+cd
+----
+
+Change directory. Use “ cd ..” to go up one directory.
+
+One dot '.' represents the current directory while two dots '..' represent the parent directory.
+
+“ cd -” will return you to the previous directory (a bit like an “undo”).
+
+You can also use cd absolute path or cd relative path (see below):
+
+Absolute paths
+
+    An “ absolute path” is easily recognised from the leading forward slash, /. The / means that you start at the top level directory and continue down.
+
+For example to get to /boot/grub you would type::
+
+	$cd /boot/grub
+
+This is an absolute path because you start at the top of the hierarchy and go downwards from there (it doesn't matter where in the filesystem you were when you typed the command).
+
+Relative paths
+
+    A “ relative path” doesn't have a preceding slash. Use a relative path when you start from a directory below the top level directory structure. This is dependent on where you are in the filesystem.
+
+    For example if you are in root's home directory and want to get to /root/music, you type::
+
+	$ cd music
+
+Please note that there is no / using the above cd command. Using a / would cause this to be an absolute path, working from the top of the hierarchy downward.
--- a/versionControl/handOut.rst	Wed Sep 09 00:38:40 2009 +0530
+++ b/versionControl/handOut.rst	Wed Sep 09 14:39:47 2009 +0530
@@ -12,13 +12,12 @@
 
 Version control (or source control) is nothing more arcane than keeping copies of ones work as one make changes to it. On the surface, it’s all straight-forward; make a copy of every file before making any changes to it. That way, if something seriously messes up, one can always fall back to something that worked before, or at least compare the broken copy with one that used to work so one can figure out where it went off kilter. Accidentally deleted half of thesis and closed the word processor? No problem – out comes the backup."
 
-Now, in the real world, it’s not so easy. One probably cooks up their own version control system without realizing it had such a geeky name. For instances files with names oldxxxxxx.odt and latestxxxxxx.odt. Every time to make some change in a file, one save it with different name then the original one. Luckily there are like, loads of version control systems out there to do this heavy lifting.
+Now, in the real world, it’s not so easy. One probably cooks up their own version control system without realizing it had such a geeky name. For instances files with names oldxxxxxx.py and latestxxxxxx.py. Every time to make some change in a file, one save it with different name then the original one. Luckily there are like, loads of version control systems out there to do this heavy lifting.
 
 Why Use Version Control
 =======================
-
-"Its the start which most people fail to attempt". 
-One of idea behind Version Control Tools was to save that "one" step, to build onto it, rather then simply loose it. So here are some reasons why is automated version control needed:
+ 
+One of idea behind Version Control Tools was to build onto very first step which can be creating a empty file, or writing a first buggy program for assignment, rather then simply loose it. So here are some reasons why is automated version control needed:
 
     - It will track the history and evolution of a project, so one don't have to do it manually. It allows to track what changes where made, when were they made, by whom and why.
     - For a team of people working on same project, revision control software makes it easier to collaborate. For example, when people more or less simultaneously make potentially incompatible changes, the software will help them to identify and resolve those conflicts.
@@ -113,6 +112,8 @@
 	- It scales excellently.
 	- It is based on Python.
 
+A small point to notice here, hg cant track binary files for changes, one can add them to repo, but wont be able to track changes made to it. And hg considers, odt, pdf files as binary.
+
 Getting Started:
 ----------------
 
@@ -147,7 +148,7 @@
 Let there be Repository:
 ------------------------
 
-In Mercurial, everything happens inside a repository. The repository for a project contains all of the files that “belong to” that project, along with a historical record of the project's files. A repository is simply a directory tree in filesystem that Mercurial treats as special.
+In Mercurial, everything happens inside a repository. The repository for a project contains all of the files that “belong to” that project, along with a historical record of the project's files. A repository is simply a directory tree in file-system that Mercurial treats as special.
 
 There can be two ways to create a repo, either getting local copy for existing repo available on Internet or machine, or creating a new repo. For getting already existing repo hg uses command *"clone"* ::
 
@@ -275,14 +276,14 @@
 Making Changes:
 ---------------
 
-There is feviStick.py file in repo created above with name feviCol. ::
+There is feviStick.py file in repo created above with name Fevicol. *status(alias st)* command prints the revision history of the specified files or the entire project::
 
     $ cd Fevicol
     $ hg log
     $ hg status
     ? feviStick.py
 
-*status(st)* command prints the revision history of the specified files or the entire project. "?" sign in front of file indicates that this file is not yet part of track record. *add* command is used to add new files to repo. ::
+"?" sign in front of file indicates that this file is not yet part of track record. *add* command is used to add new files to repo. ::
 
     $ hg add feviStick.py
     $ hg st
@@ -298,13 +299,13 @@
    date:        Fri Aug 21 23:37:13 2009 +0530
    summary:     First commit.
 
-Similar to add there are other commands available for file management in repo. ::
+Similar to add there are other commands available for file management in repo. *copy (alias cp)* command is used to mark files as copied for the next commit. ::
 
    $ hg cp feviStick.py pidiLite.py
    $ hg st
    A pidiLite.py
 
-*copy (alias cp)* command is used to mark files as copied for the next commit. ::
+*rename(alias mv)* rename files; equivalent of copy + remove. *tip* command shows newest revision in the repository. ::
 
    $ hg rename pidiLite.py feviCol.py
    $ hg st
@@ -317,7 +318,7 @@
    date:        Sat Aug 22 00:11:25 2009 +0530
    summary:     Renamed pidiLite.py.
 
-*rename(alias mv)* rename files; equivalent of copy + remove. *tip* command shows newest revision in the repository.. ::
+*remove* command is used to remove files from a repo. ::
 
    $ hg remove feviCol.py
    $ hg st
@@ -337,7 +338,7 @@
 Pulling from repo:
 ~~~~~~~~~~~~~~~~~~
 
-As mentioned earlier that repositories in Mercurial are self-contained. This means that the changeset just created exists only in Fevicol repository and not in previously cloned fevicol-pull. There are a few ways that can be used to propagate this change into other repositories. ::
+As mentioned earlier that repositories in Mercurial are self-contained. This means that the changeset just created exists only in Fevicol repository and not in previously cloned Fevicol-pull. There are a few ways that can be used to propagate this change into other repositories. ::
 
    $ hg clone Fevicol Fevicol-clone
    updating working directory
@@ -397,18 +398,18 @@
 After getting the desired version of local repo, one can make changes as he/she needs and then make them available(share) for others. For these operations we will be working in Fevicol-clone repo which we created earlier. It's often good practice to keep a “pristine” copy of a remote repository around, which you can then make temporary clones of to create sandboxes for each task you want to work on. ::
 
     $ cd Fevicol-clone/
-    $ cat cat feviStick.py 
+    $ cat feviStick.py 
     print 'Yeh Fevicol ka Majboot jod hai'
 
 This tagline is correct for feviCol.py but for feviStick.py it should be different. ::
 
     $ echo "print 'Ab no more Chip Chip'" > feviStick.py
-    $ cat cat feviStick.py
+    $ cat feviStick.py
     print 'Ab no more Chip Chip'
     $ hg st
     M feviStick.py
 
-Mercurial's hg status command will tell us what Mercurial knows about the files in the repository. 'M' sign infront of feviStick.py indicates that Mercurial has noticed change.
+Mercurial's hg status command will tell us what Mercurial knows about the files in the repository. 'M' sign in front of feviStick.py indicates that Mercurial has noticed change.
 
 It's somewhat helpful to know that feviStick.py was modified, but one might prefer to know exactly what changes were made to it. To do this, use the *hg diff* command. ::
 
@@ -426,7 +427,7 @@
 	  
 	  - Specify a -u option to the hg commit command on the command line, followed by a username.
 	  - set HGUSER environment variable.
-	  - Edit hgrc file present in .hg folder to set this property, add following lines to that file and Mercurial will read those parameters from that location.
+	  - Edit hgrc file present in .hg folder to set this property, add following lines to that file and Mercurial will read those parameters from that location. ::
 	  
 		[ui]
 		username = Firstname Lastname <email.address@example.net>
@@ -447,7 +448,7 @@
     HG: branch 'default'
     HG: changed feviStick.py 
 
-This would be vi sort of editor, where you can enter the log message in first line, once you are done with log message quit the editor using *[ESC] key ":wq"*.Once we've finished the commit, we can use the hg tip command to display the changeset we just created. ::
+This would be your default system editor(for me it is vim, one can set it also), where you can enter the log message in first line, once you are done with log message quit the editor using *[ESC] key ":wq"*.Once we've finished the commit, we can use the hg tip command to display the changeset we just created. ::
 
     $ hg tip
     changeset:   3:e1ab2aff4ddd
@@ -474,7 +475,7 @@
     date:        Sun Aug 23 23:32:01 2009 +0530
     summary:     Changed tagline for feviStick.py.
 
-And the hg push command does the actual push. ::
+And the *hg push* command does the actual push. ::
 
     $ hg push ../Fevicol
     pushing to ../Fevicol
@@ -503,10 +504,193 @@
    $ $ cat feviStick.py 
    print 'Ab no more Chip Chip'
 
-Dos and Don'ts with Mercurial:
-==============================
+Merging the Work:
+~~~~~~~~~~~~~~~~~
+
+This is next aspect of any version control, how to merge work done by various participants of project in a way that no one looses changes being made, and still remains updated. Here is simple case study which can help understanding why merging is required: 
+
+Two persons, A and B are contributing on same project. Both starts from cloning the same online repo(lets say present state X), so that both have a working local repo. Now A edits one of file, commits the changes and pushes to the repo, hence changing the state of repo to Y, but B, have not updated his repo, makes a change in one of files and reaches to a different state Z. Now when A pulls repo from B, his repo will have multiple heads. This stage is clearly ambiguous, the repo of A is not consistent, it has multiple heads, and from here, whatever changes he makes can take whatsoever direction if it is not fixed, and hence A will have to merge changes so that everything becomes consistent again.
+
+Lets see how this work with working repo, we will use Fevicol and Fevicol-clone repositories created earlier. For now, the status of both repo is: ::
+
+    $ cd Fevicol-clone
+    $ hg tip
+    changeset:   3:e1ab2aff4ddd
+    tag:         tip
+    user:        Shantanu Choudhary <shantanu@fossee.in>
+    date:        Sun Aug 23 23:32:01 2009 +0530
+    summary:     Changed tagline for feviStick.py.
+
+The tagline for feviCol.py is not complete, so we make changes in that file in this repo. ::
+
+    $ echo "print 'Yeh Fevicol ka Majboot jod hai, tootega nahin'" > feviStick.py
+    $ hg st
+    M feviStick.py
+
+And commit the changes made ::
+
+    $ hg ci -u "Shantanu <shantanu@fossee.in>" -m "Updated tag line for feviCol.py."
+    $ hg st
+    $ hg tip
+    changeset:   4:caf986b15e05
+    tag:         tip
+    user:        Shantanu <shantanu@fossee.in>
+    date:        Tue Aug 25 16:28:24 2009 +0530
+    summary:     Updated tag line for feviCol.py.
+
+Now we will make some changes on Fevicol repo. We will add new file here ::
+
+    $ cd Fevicol
+    $ echo "print 'Jor laga ke hayyiya'" > firstAdd.py
+    $ hg st
+    ? firstAdd.py
+    $ hg add firstAdd.py
+    $ hg st
+    A firstAdd.py
+    $ hg ci -u "Shantanu <shantanu@fossee.in>" -m "Added firsAdd.py."
+    $ hg tip
+    changeset:   4:fadbd6492cc4
+    tag:         tip
+    user:        Shantanu <shantanu@fossee.in>
+    date:        Tue Aug 25 16:46:24 2009 +0530
+    summary:     Added firsAdd.py.
+    
+So now we have two repo, who have different commit history and tree, now if we try to pull changes from one to another, this is how it goes(we are still in Fevicol repo): ::
+
+    $ hg pull ../Fevicol-clone 
+    pulling from ../Fevicol-clone
+    searching for changes
+    adding changesets
+    adding manifests
+    adding file changes
+    added 1 changesets with 1 changes to 1 files (+1 heads)
+    (run 'hg heads' to see heads, 'hg merge' to merge)
+
+There we go, since both repo were on different track, hg pull command in last line gives some heading from here. *hg heads* command show current repository heads or show branch heads. ::
+
+    $ hg heads
+    changeset:   5:caf986b15e05
+    tag:         tip
+    parent:      3:e1ab2aff4ddd
+    user:        Shantanu <shantanu@fossee.in>
+    date:        Tue Aug 25 16:28:24 2009 +0530
+    summary:     Updated tag line for feviCol.py.
 
+    changeset:   4:fadbd6492cc4
+    user:        Shantanu <shantanu@fossee.in>
+    date:        Tue Aug 25 16:46:24 2009 +0530
+    summary:     Added firsAdd.py.
+    
+To get better understanding of what is going on hg have a tool known as *glog* which shows revision history alongside an ASCII revision graph. ::
+     
+    $ hg glog
+    o  changeset:   5:caf986b15e05
+    |  tag:         tip
+    |  parent:      3:e1ab2aff4ddd
+    |  user:        Shantanu <shantanu@fossee.in>
+    |  date:        Tue Aug 25 16:28:24 2009 +0530
+    |  summary:     Updated tag line for feviCol.py.
+    |
+    | @  changeset:   4:fadbd6492cc4
+    |/   user:        Shantanu <shantanu@fossee.in>
+    |    date:        Tue Aug 25 16:46:24 2009 +0530
+    |    summary:     Added firsAdd.py.
+    |
+    o  changeset:   3:e1ab2aff4ddd
+    |  user:        Shantanu Choudhary <shantanu@fossee.in>
+    |  date:        Sun Aug 23 23:32:01 2009 +0530
+    |  summary:     Changed tagline for feviStick.py.
+    |
+    o  changeset:   2:a7912d45f47c
+    |  user:        Shantanu <shantanu@fossee.in>
+    |  date:        Sun Aug 23 22:34:35 2009 +0530
+    |  summary:     Updated Content.
+    |
+    o  changeset:   1:d948fb4137c5
+    |  user:        Shantanu <shantanu@fossee.in>
+    |  date:        Sat Aug 22 00:11:25 2009 +0530
+    |  summary:     Renamed pidiLite.py.
+    |
+    o  changeset:   0:84f5e91f4de1
+       user:        Shantanu <shantanu@fossee.in>
+       date:        Fri Aug 21 23:37:13 2009 +0530
+       summary:     First commit.
 
+To bring repo on single track/branch once again we will have to merge these two branches. Without merging them even hg update wont work for obvious reason of confusing track record. ::
+
+    $ hg up
+    abort: crosses branches (use 'hg merge' or 'hg update -C')
+
+*hg merge* command merge working directory with another revision. ::
+
+    $ hg merge
+    1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+    (branch merge, don't forget to commit) 
+    $ hg tip 
+    changeset:   5:caf986b15e05
+    tag:         tip
+    parent:      3:e1ab2aff4ddd
+    user:        Shantanu <shantanu@fossee.in>
+    date:        Tue Aug 25 16:28:24 2009 +0530
+    summary:     Updated tag line for feviCol.py.
+
+After merging two branches, until we commit the results of merge it will keep on showing two heads. ::
+
+    $ hg ci -u "Shantanu <shantanu@fossee.in>" -m "Merged branches of add and tag line."
+    $ hg heads 
+    changeset:   6:edbe97209954
+    tag:         tip
+    parent:      4:fadbd6492cc4
+    parent:      5:caf986b15e05
+    user:        Shantanu <shantanu@fossee.in>
+    date:        Tue Aug 25 17:06:03 2009 +0530
+    summary:     Merged branches of add and tag line.
+
+Here is brief and meaningful output of glog ::
+
+    $ hg glog 
+    @    changeset:   6:edbe97209954
+    |\   tag:         tip
+    | |  parent:      4:fadbd6492cc4
+    | |  parent:      5:caf986b15e05
+    | |  user:        Shantanu <shantanu@fossee.in>
+    | |  date:        Tue Aug 25 17:06:03 2009 +0530
+    | |  summary:     Merged branches of add and tag line.
+    | |
+    | o  changeset:   5:caf986b15e05
+    | |  parent:      3:e1ab2aff4ddd
+    | |  user:        Shantanu <shantanu@fossee.in>
+    | |  date:        Tue Aug 25 16:28:24 2009 +0530
+    | |  summary:     Updated tag line for feviCol.py.
+    | |
+    o |  changeset:   4:fadbd6492cc4
+    |/   user:        Shantanu <shantanu@fossee.in>
+    |    date:        Tue Aug 25 16:46:24 2009 +0530
+    |    summary:     Added firsAdd.py.
+
+And we are back on track.
+
+Workflow:
+=========
+
+This is chain of steps which can be followed for working against a project that has a centralized copy, you may want to make sure you're up to date first. This means pulling its changes and then updating. 
+
+For example: ::
+    
+    $ hg pull
+    $ hg update
+
+This will grab the remote changes from the location you first cloned from. Then it will apply the changes. You can do this in one go with: ::
+
+    $ hg pull -u
+
+Now let's say you make some changes. You edit a file and you want to commit your change. You can do this with: ::
+
+    $ hg commit
+
+An editor will pop-up asking you to write a message describing your change. This is required. When you're done for the day, and you have required changesets sitting in your repository. Before pushing to upstream make sure to pull and update and merge branches if required, once everything looks okay and you have single track, push the changes, ::
+
+    $ hg push
 
 Suggested Reading:
 ==================
@@ -516,3 +700,4 @@
 	* http://en.wikipedia.org/wiki/Revision_control
 	* http://hgbook.red-bean.com/
 	* http://betterexplained.com/articles/intro-to-distributed-version-control-illustrated/
+	* http://wiki.alliedmods.net/Mercurial_Tutorial