versionControl/handOut.rst
author Shantanu <shantanu@fossee.in>
Tue, 25 Aug 2009 17:18:22 +0530
changeset 37 4cddf3a13843
parent 26 977009f5a22a
child 38 ce7634ee7986
permissions -rw-r--r--
Added merging section, and typo correction.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     1
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
     2
=================
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
     3
 Version Control
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
     4
=================
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     5
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     6
Introduction
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
     7
============
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     8
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     9
The following words are from a blogpost "http://karlagius.com/2009/01/09/version-control-for-the-masses/"
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    10
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    11
"Version control is one of those weird, geeky things that never really gained much ground in non-geek fields, despite the fact that it’s blindingly useful.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    12
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
    13
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."
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    14
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
    15
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.
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    16
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    17
Why Use Version Control
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
    18
=======================
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
    19
 
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
    20
One of idea behind Version Control Tools was to build onto very first step which can be creating a empty file, or writting a first buggy program for assignment, rather then simply loose it. So here are some reasons why is automated version control needed:
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    21
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    22
    - 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.
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
    23
    - 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.
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    24
    - It can help to recover from mistakes. If a change made at some moment of time, turns out to be in error in future, one can revert to an earlier version of one or more files. In fact, a really good revision control tool will even help in efficiently figure out exactly when a problem was introduced.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    25
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
    26
Most of these reasons are equally valid for the project having one man show, or hundred people. Besides projects, even it can be used to maintain assignments related to one particular subject/course, it will help manage things in way much better way. These tools can be used for better *resources management*. All codes, documents, presentation, assignments related to one course maintained in such a inventory can help avoiding accidental lose of data(deletion) and Internet hosting for version control will make the work immune to local hard-disk crash, unless hosting crashes itself.
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    27
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    28
Some of Version Control Tools available and used widely are:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    29
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    30
     - cvs (Concurrent Version System)
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    31
     - svn (Subversion)
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    32
     - hg (Mercurial)
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    33
     - bzr (Bazaar)
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    34
     - git 
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    35
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    36
Each of above mentioned tools have sets of feature which it offers in unique way. For this session we are going to concentrate on hg (mercurial). After covering the basics of hg, one can easily try other tools, and use what-ever he/she is most comfortable with.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    37
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    38
Learning the Lingo
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
    39
==================
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    40
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    41
Each Version Control uses its own nomenclature for more or less the same features. Here are some of terms which are going to used through out the rest of session:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    42
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    43
Basic Setup
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
    44
-----------
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    45
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    46
     Repository(repo):
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    47
	The database/folder storing the files.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    48
     Server:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    49
	The computer storing the repo.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    50
     Client:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    51
	The computer connecting to the repo.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    52
     Working Set/Working Copy:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    53
     	Your local directory of files, where you make changes. This is what is present on client side.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    54
     Trunk/Main:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    55
	The “primary” location for code in the repo. Think of code as a family tree — the “trunk” is the main line. This is generally what is present on server.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    56
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    57
Basic Actions
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
    58
-------------
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    59
     
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    60
     Add:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    61
	Put a file into the repo for the first time, i.e. begin tracking it with Version Control.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    62
     Revision:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    63
	What version a file is on.
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
    64
     Head/Tip:
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    65
	The latest revision of the repo.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    66
     Check out:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    67
     	Initial download of repo onto machine.
17
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
    68
     Commit:
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    69
     	Upload a file to repository(if it has changed). The file gets a new revision number, and people can “check out” the latest one.
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
    70
     Checking Message:
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    71
     	A short message describing what was changed.
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
    72
     Change log/History:
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    73
	A list of changes made to a file since it was created.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    74
     Update/Sync:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    75
	Synchronize local files with the latest from the repository on server. This get the latest revisions of all files.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    76
     Revert:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    77
	Throw away the local changes and reload the latest version from the repository.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    78
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    79
Advanced Actions:
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
    80
-----------------
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    81
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    82
     Branch:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    83
	Create a separate copy of a file/folder for private use (bug fixing, testing, etc).
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    84
     Diff/Change:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    85
	Finding the differences between two files. Useful for seeing what changed between revisions.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    86
     Merge (or patch):
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    87
     	Apply the changes from one file to another, to bring it up-to-date.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    88
     Conflict:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    89
	When pending changes to a file contradict each other (both changes cannot be applied).
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    90
     Resolve:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    91
	Fixing the changes that contradict each other and checking in the correct version.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    92
     
8
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
    93
Types of Version Control:
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
    94
-------------------------
8
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
    95
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
    96
Based on how source/code management is carried out in a tool there are two categories of Version Control Systems(VCS):
8
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
    97
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
    98
      - Centralized VCS: 
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
    99
      	In this kind of system all the revision control functions are performed on a shared server. If two developers try to change the same file at the same time, without some method of managing access the developers may end up overwriting each other's work. Centralized revision control systems solve this problem in one of two different "source management models": file locking and version merging. Both svn and cvs follows this kind of management.
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   100
   
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   101
      - Distributed VCS:
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   102
      	In a distributed model, every developer has their own repo. Diffs, commits, and reverts are all done locally, one needs Internet only to share the changes with others. It makes work faster, handles branching and merging in better way, with less management. hg, bzr and git uses this work flow.
8
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   103
15
d20e3fe4fd8c Started hg command section.
Shantanu <shantanu@fossee.in>
parents: 8
diff changeset
   104
Get Going with Hg:
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   105
==================
8
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   106
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   107
Why hg?
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   108
-------
15
d20e3fe4fd8c Started hg command section.
Shantanu <shantanu@fossee.in>
parents: 8
diff changeset
   109
d20e3fe4fd8c Started hg command section.
Shantanu <shantanu@fossee.in>
parents: 8
diff changeset
   110
	- It is easy to learn and use.
d20e3fe4fd8c Started hg command section.
Shantanu <shantanu@fossee.in>
parents: 8
diff changeset
   111
	- It is lightweight.
d20e3fe4fd8c Started hg command section.
Shantanu <shantanu@fossee.in>
parents: 8
diff changeset
   112
	- It scales excellently.
d20e3fe4fd8c Started hg command section.
Shantanu <shantanu@fossee.in>
parents: 8
diff changeset
   113
	- It is based on Python.
d20e3fe4fd8c Started hg command section.
Shantanu <shantanu@fossee.in>
parents: 8
diff changeset
   114
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   115
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.
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   116
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   117
Getting Started:
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   118
----------------
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   119
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   120
Following command tells the version of hg installed on machine: ::
15
d20e3fe4fd8c Started hg command section.
Shantanu <shantanu@fossee.in>
parents: 8
diff changeset
   121
   
d20e3fe4fd8c Started hg command section.
Shantanu <shantanu@fossee.in>
parents: 8
diff changeset
   122
   $hg version
d20e3fe4fd8c Started hg command section.
Shantanu <shantanu@fossee.in>
parents: 8
diff changeset
   123
d20e3fe4fd8c Started hg command section.
Shantanu <shantanu@fossee.in>
parents: 8
diff changeset
   124
   Mercurial Distributed SCM (version 1.1.2)
d20e3fe4fd8c Started hg command section.
Shantanu <shantanu@fossee.in>
parents: 8
diff changeset
   125
   Copyright (C) 2005-2008 Matt Mackall <mpm@selenic.com> and others
d20e3fe4fd8c Started hg command section.
Shantanu <shantanu@fossee.in>
parents: 8
diff changeset
   126
   This is free software; see the source for copying conditions. There is NO
d20e3fe4fd8c Started hg command section.
Shantanu <shantanu@fossee.in>
parents: 8
diff changeset
   127
   warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
d20e3fe4fd8c Started hg command section.
Shantanu <shantanu@fossee.in>
parents: 8
diff changeset
   128
d20e3fe4fd8c Started hg command section.
Shantanu <shantanu@fossee.in>
parents: 8
diff changeset
   129
Built-in help, Mercurial provides a built-in help system. Following command will print a brief list of commands, along with a description of what each does. ::
d20e3fe4fd8c Started hg command section.
Shantanu <shantanu@fossee.in>
parents: 8
diff changeset
   130
d20e3fe4fd8c Started hg command section.
Shantanu <shantanu@fossee.in>
parents: 8
diff changeset
   131
   $hg help
d20e3fe4fd8c Started hg command section.
Shantanu <shantanu@fossee.in>
parents: 8
diff changeset
   132
d20e3fe4fd8c Started hg command section.
Shantanu <shantanu@fossee.in>
parents: 8
diff changeset
   133
   Mercurial Distributed SCM
d20e3fe4fd8c Started hg command section.
Shantanu <shantanu@fossee.in>
parents: 8
diff changeset
   134
   list of commands:
d20e3fe4fd8c Started hg command section.
Shantanu <shantanu@fossee.in>
parents: 8
diff changeset
   135
   add          add the specified files on the next commit
d20e3fe4fd8c Started hg command section.
Shantanu <shantanu@fossee.in>
parents: 8
diff changeset
   136
   addremove	-----------------------
d20e3fe4fd8c Started hg command section.
Shantanu <shantanu@fossee.in>
parents: 8
diff changeset
   137
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   138
For specific command, just follow the command name after the help. ::
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   139
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   140
    $hg help diff
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   141
    hg diff [OPTION]... [-r REV1 [-r REV2]] [FILE]...
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   142
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   143
    diff repository (or selected files)
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   144
    Show differences between revisions for the specified files.
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   145
    Differences between files are shown using the unified diff format.
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   146
    NOTE:____________
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   147
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   148
Let there be Repository:
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   149
------------------------
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   150
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   151
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.
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   152
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   153
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"* ::
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   154
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   155
      $hg clone http://hg.serpentine.com/tutorial/hello localCopyhello
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   156
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   157
      requesting all changes
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   158
      adding changesets
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   159
      adding manifests
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   160
      adding file changes
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   161
      added 5 changesets with 5 changes to 2 files
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   162
      updating working directory
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   163
      2 files updated, 0 files merged, 0 files removed, 0 files unresolved
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   164
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   165
If clone succeeded, there would be a local directory called localCopyhello, with some files: ::
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   166
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   167
      $ls localCopyhello/
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   168
      hello.c  Makefile
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   169
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   170
Every Mercurial repository is complete, self-contained, and independent. It contains its own private copy of a project's files and history.
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   171
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   172
To start a new repository use *hg init*: ::
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   173
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   174
   $ mkdir Fevicol
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   175
   $ cd Fevicol/
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   176
   $ echo "print 'Yeh Fevicol ka Majboot jod hai'" > feviStick.py
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   177
   $ ls -a
17
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   178
   .  ..  feviStick.py
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   179
   $ hg init
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   180
   $ ls -a
17
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   181
   .  ..  feviStick.py  .hg
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   182
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   183
*.hg* directory indicates that this new dir is now a repo.This is where Mercurial keeps all of its metadata for the repository.The contents of the .hg directory and its subdirectories are private to Mercurial. Rest all files are for the user to use them as they pleases.
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   184
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   185
Creating a branch of existing local repo is very easy via hg using clone command: ::
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   186
	
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   187
    $ hg clone localCopyhello newCopy
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   188
    updating working directory
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   189
    2 files updated, 0 files merged, 0 files removed, 0 files unresolved
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   190
17
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   191
newCopy is exact copy of already existing repo. And this command can be used to create branch of locally created repo also: ::
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   192
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   193
    $ hg clone Fevicol Fevicol-pull
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   194
    updating working directory
17
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   195
    0 files updated, 0 files merged, 0 files removed, 0 files unresolved
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   196
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   197
These local branches can prove really handy at times. It allows keep multiple copies of local branch for different purposes, say for debugging, testing, working version.
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   198
	
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   199
History or Logs:
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   200
----------------
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   201
17
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   202
For the new repo created, first thing which can be tried is to check the logs/history. What changes were made and when and why, answers to all those questions are stored in logs safely. So for the the cloned repo the history can be viewed using command *"log"* (following commands are wrt localCopyhello repo). ::
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   203
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   204
    $hg log
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   205
    changeset:   4:2278160e78d4
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   206
    tag:         tip
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   207
    user:        Bryan O'Sullivan <bos@serpentine.com>
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   208
    date:        Sat Aug 16 22:16:53 2008 +0200
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   209
    summary:     Trim comments.
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   210
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   211
    changeset:   3:0272e0d5a517
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   212
    user:        Bryan O'Sullivan <bos@serpentine.com>
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   213
    date:        Sat Aug 16 22:08:02 2008 +0200
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   214
    summary:     Get make to generate the final binary from a .o file.
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   215
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   216
    changeset:   2:fef857204a0c
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   217
    user:        Bryan O'Sullivan <bos@serpentine.com>
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   218
    date:        Sat Aug 16 22:05:04 2008 +0200
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   219
    summary:     Introduce a typo into hello.c.
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   220
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   221
    changeset:   1:82e55d328c8c
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   222
    user:        mpm@selenic.com
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   223
    date:        Fri Aug 26 01:21:28 2005 -0700
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   224
    summary:     Create a makefile
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   225
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   226
    changeset:   0:0a04b987be5a
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   227
    user:        mpm@selenic.com
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   228
    date:        Fri Aug 26 01:20:50 2005 -0700
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   229
    summary:     Create a standard "hello, world" program
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   230
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   231
By default, this command prints a brief paragraph of output for each change to the project that was recorded.The fields in a record of output from hg log are as follows:
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   232
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   233
   - changeset: This field has the format of a number, followed by a colon, followed by a hexadecimal (or hex) string. These are identifiers for the changeset. The hex string is a unique identifier: the same hex string will always refer to the same changeset in every copy of this repository. 
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   234
   - user: The identity of the person who created the changeset.
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   235
   - date: The date and time on which the changeset was created, and the timezone in which it was created.
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   236
   - summary: The first line of the text message that the creator of the changeset entered to describe the changeset.
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   237
   - tag: A tag is another way to identify a changeset, by giving it an easy-to-remember name.
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   238
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   239
To narrow the output of hg log down to a single revision, use the -r (or --rev) option. ::
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   240
   
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   241
   $hg log -r 3
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   242
   changeset:   3:0272e0d5a517
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   243
   user:        Bryan O'Sullivan <bos@serpentine.com>
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   244
   date:        Sat Aug 16 22:08:02 2008 +0200
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   245
   summary:     Get make to generate the final binary from a .o file.
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   246
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   247
*range notation* can be used to get history of several revisions without having to list each one. ::
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   248
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   249
   $ hg log -r 2:4
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   250
   changeset:   2:fef857204a0c
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   251
   user:        Bryan O'Sullivan <bos@serpentine.com>
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   252
   date:        Sat Aug 16 22:05:04 2008 +0200
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   253
   summary:     Introduce a typo into hello.c.
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   254
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   255
   changeset:   3:0272e0d5a517
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   256
   user:        Bryan O'Sullivan <bos@serpentine.com>
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   257
   date:        Sat Aug 16 22:08:02 2008 +0200
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   258
   summary:     Get make to generate the final binary from a .o file.
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   259
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   260
   changeset:   4:2278160e78d4
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   261
   tag:         tip
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   262
   user:        Bryan O'Sullivan <bos@serpentine.com>
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   263
   date:        Sat Aug 16 22:16:53 2008 +0200
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   264
   summary:     Trim comments.
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   265
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   266
The hg log  command's -v (or --verbose) option gives you this extra detail. ::
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   267
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   268
    $ hg log -v -r 3
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   269
    changeset:   3:0272e0d5a517
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   270
    user:        Bryan O'Sullivan <bos@serpentine.com>
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   271
    date:        Sat Aug 16 22:08:02 2008 +0200
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   272
    files:       Makefile
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   273
    description:
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   274
    Get make to generate the final binary from a .o file.
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   275
17
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   276
Making Changes:
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   277
---------------
17
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   278
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   279
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::
17
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   280
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   281
    $ cd Fevicol
17
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   282
    $ hg log
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   283
    $ hg status
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   284
    ? feviStick.py
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   285
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   286
"?" 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. ::
17
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   287
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   288
    $ hg add feviStick.py
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   289
    $ hg st
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   290
    A feviStick.py
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   291
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   292
So file is now part of repository(A symbol). Use *commit (alias ci)* command to make changes effective(this command would be explained in more details in later parts). ::
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   293
   
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   294
   $ hg ci -u "Shantanu <shantanu@fossee.in>" -m "First commit."
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   295
   $ hg log
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   296
   changeset:   0:84f5e91f4de1
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   297
   tag:         tip
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   298
   user:        Shantanu <shantanu@fossee.in>
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   299
   date:        Fri Aug 21 23:37:13 2009 +0530
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   300
   summary:     First commit.
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   301
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   302
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.::
17
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   303
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   304
   $ hg cp feviStick.py pidiLite.py
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   305
   $ hg st
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   306
   A pidiLite.py
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   307
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   308
*rename(alias mv)* rename files; equivalent of copy + remove. *tip* command shows newest revision in the repository. ::
17
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   309
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   310
   $ hg rename pidiLite.py feviCol.py
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   311
   $ hg st
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   312
   A feviCol.py
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   313
   $ hg ci -u "Shantanu <shantanu@fossee.in>" -m "Renamed pidiLite.py."
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   314
   $ hg tip
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   315
   changeset:   1:d948fb4137c5
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   316
   tag:         tip
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   317
   user:        Shantanu <shantanu@fossee.in>
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   318
   date:        Sat Aug 22 00:11:25 2009 +0530
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   319
   summary:     Renamed pidiLite.py.
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   320
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   321
*remove* command is used to remove files from a repo. ::
17
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   322
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   323
   $ hg remove feviCol.py
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   324
   $ hg st
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   325
   R feviCol.py
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   326
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   327
R status of files denotes, file is marked as to be removed by the previous command *remove*. To add the file again to repo, one can use *revert* command, which restore individual files or dirs to an earlier state. ::
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   328
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   329
  $ ls
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   330
  feviStick.py
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   331
  $ hg revert feviCol.py
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   332
  $ ls
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   333
  feviCol.py  feviStick.py
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   334
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   335
Sharing Changes:
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   336
----------------
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   337
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   338
Pulling from repo:
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   339
~~~~~~~~~~~~~~~~~~
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   340
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   341
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. ::
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   342
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   343
   $ hg clone Fevicol Fevicol-clone
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   344
   updating working directory
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   345
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   346
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   347
Or traverse into the any dir which is a working hg repo(using hg init) and pull command will download all changeset from main repo. ::
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   348
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   349
   $ mkdir Fevicol-pull
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   350
   $ cd Fevicol-pull
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   351
   $ hg init
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   352
   $ hg pull ../Fevicol
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   353
   pulling from ../Fevicol
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   354
   requesting all changes
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   355
   adding changesets
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   356
   adding manifests
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   357
   adding file changes
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   358
   added 2 changesets with 2 changes to 2 files
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   359
   (run 'hg update' to get a working copy)
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   360
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   361
*changeset* means a list of changes made to a file. In words of *hg help*, pull command is: ::
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   362
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   363
   pull changes from the specified source
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   364
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   365
    Pull changes from a remote repository to a local one.
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   366
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   367
    This finds all changes from the repository at the specified path
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   368
    or URL and adds them to the local repository. By default, this
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   369
    does not update the copy of the project in the working directory.
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   370
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   371
Some times, even before pulling changesets, one may need to see what changes would be pulled, Mercurial provides *hg incoming* to tell what changes *hg pull* would pull into repo, without actually pulling the changes. This command is really handy in case of avoiding unwanted changesets into the repo.
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   372
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   373
With Mercurial, *hg pull* does not(by default) touch the working directory. Instead there is *hg up (alias update, co, checkout)* command to do this. ::
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   374
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   375
    $ cd Fevicol-pull
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   376
    $ ls -a
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   377
    .  ..  .hg
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   378
    $ hg up
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   379
    2 files updated, 0 files merged, 0 files removed, 0 files unresolved
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   380
    $ ls -a
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   381
    .  ..  feviCol.py  feviStick.py  .hg
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   382
    
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   383
To update to specific version, give a version number to the *hg update* command. ::
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   384
   
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   385
    $ hg update 0
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   386
    0 files updated, 0 files merged, 1 files removed, 0 files unresolved
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   387
    $ hg parent
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   388
    changeset:   0:84f5e91f4de1
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   389
    user:        Shantanu <shantanu@fossee.in>
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   390
    date:        Fri Aug 21 23:37:13 2009 +0530
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   391
    summary:     First commit.
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   392
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   393
If no version number is specified *hg up* will update to the tip version. Version number of hg starts from 0. Compare *hg parent* output to the one before doing update to see the difference.
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   394
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   395
Making Changes:
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   396
~~~~~~~~~~~~~~~
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   397
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   398
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. ::
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   399
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   400
    $ cd Fevicol-clone/
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   401
    $ cat feviStick.py 
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   402
    print 'Yeh Fevicol ka Majboot jod hai'
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   403
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   404
This tagline is correct for feviCol.py but for feviStick.py it should be different. ::
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   405
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   406
    $ echo "print 'Ab no more Chip Chip'" > feviStick.py
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   407
    $ cat feviStick.py
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   408
    print 'Ab no more Chip Chip'
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   409
    $ hg st
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   410
    M feviStick.py
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   411
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   412
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.
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   413
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   414
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. ::
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   415
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   416
    $ hg diff
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   417
    diff -r a7912d45f47c feviStick.py
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   418
    --- a/feviStick.py	 Sun Aug 23 22:34:35 2009 +0530
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   419
    +++ b/feviStick.py	 Sun Aug 23 22:47:49 2009 +0530
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   420
    @@ -1,1 +1,1 @@
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   421
    -print 'Yeh Fevicol ka Majboot jod hai'
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   422
    +print 'Ab no more Chip Chip'
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   423
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   424
We can modify files, build and test our changes, and use hg status and hg diff to review our changes, until we're satisfied with what we've done and arrive at a natural stopping point where we want to record our work in a new changeset. All the diffs prior to committing the changes would be done wrt earlier marked record.The hg commit command lets us create a new changeset.
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   425
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   426
Mercurial records your name and address with each change that you commit, so that you and others will later be able to tell who made each change. Mercurial tries to automatically figure out a sensible username to commit the change with. When we try to use *hg commit* there are various ways by which one can specify User name, some of those are:
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   427
	  
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   428
	  - Specify a -u option to the hg commit command on the command line, followed by a username.
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   429
	  - set HGUSER environment variable.
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   430
	  - 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. ::
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   431
	  
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   432
		[ui]
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   433
		username = Firstname Lastname <email.address@example.net>
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   434
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   435
For me the hgrc file looks like this: ::
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   436
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   437
    [paths]
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   438
    default = /home/baali/Fevicol
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   439
    [ui]
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   440
    username = Shantanu Choudhary <shantanu@fossee.in>
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   441
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   442
Once this parameter is set, *hg commit* command drops us into a text editor, to enter a message that will describe the modifications we've made in this changeset. This is called the commit message. It will be a record for readers of what we did and why, and it will be printed by hg log after we've finished committing. ::
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   443
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   444
    Changed tagline for feviStick.py.
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   445
    HG: Enter commit message.  Lines beginning with 'HG:' are removed.
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   446
    HG: --
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   447
    HG: user: Shantanu Choudhary <shantanu@fossee.in>
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   448
    HG: branch 'default'
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   449
    HG: changed feviStick.py 
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   450
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   451
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. ::
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   452
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   453
    $ hg tip
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   454
    changeset:   3:e1ab2aff4ddd
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   455
    tag:         tip
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   456
    user:        Shantanu Choudhary <shantanu@fossee.in>
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   457
    date:        Sun Aug 23 23:32:01 2009 +0530
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   458
    summary:     Changed tagline for feviStick.py. 
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   459
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   460
One can do above mentioned procedure using following one line command: ::
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   461
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   462
    $ hg ci -u "Shantanu <shantanu@fossee.in>" -m "Changed tagline for feviStick.py."
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   463
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   464
Sharing Changes:
17
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   465
~~~~~~~~~~~~~~~~
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   466
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   467
The *hg outgoing* command tells us what changes would be pushed into another repository. ::
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   468
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   469
    $ hg outgoing ../Fevicol
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   470
    comparing with ../Fevicol
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   471
    searching for changes
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   472
    changeset:   3:e1ab2aff4ddd
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   473
    tag:         tip
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   474
    user:        Shantanu Choudhary <shantanu@fossee.in>
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   475
    date:        Sun Aug 23 23:32:01 2009 +0530
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   476
    summary:     Changed tagline for feviStick.py.
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   477
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   478
And the *hg push* command does the actual push. ::
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   479
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   480
    $ hg push ../Fevicol
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   481
    pushing to ../Fevicol
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   482
    searching for changes
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   483
    adding changesets
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   484
    adding manifests
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   485
    adding file changes
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   486
    added 1 changesets with 1 changes to 1 files
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   487
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   488
As with hg pull, the hg push command does not update the working directory in the repository that it's pushing changes into. One has to use hg update to populate the changes in desired repo. ::
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   489
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   490
   $ cd ../Fevicol
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   491
   $ hg tip
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   492
   changeset:   3:e1ab2aff4ddd
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   493
   tag:         tip
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   494
   user:        Shantanu Choudhary <shantanu@fossee.in>
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   495
   date:        Sun Aug 23 23:32:01 2009 +0530
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   496
   summary:     Changed tagline for feviStick.py.
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   497
   $ cat feviStick.py
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   498
   print 'Yeh Fevicol ka Majboot jod hai'
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   499
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   500
changesets are imported, but update is yet to be done. ::
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   501
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   502
   $ hg up tip
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   503
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   504
   $ $ cat feviStick.py 
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   505
   print 'Ab no more Chip Chip'
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   506
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   507
Merging the Work:
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   508
~~~~~~~~~~~~~~~~~
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   509
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   510
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: 
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   511
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   512
Two persons, changu and mangu are contributing on same project. Both starts from cloning the same online repo(lets say present state A), so that both have a working local repo. Now changu edits one of file, commits the changes and pushes to the repo, hence changing the state of repo to B, but mangu, have not updated his repo, makes a change in one of files and reaches to a different state C. Now when changu pulls repo from mangu, his repo will have multiple heads. This stage is clearly ambiguous the repo of changu 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 changu will have to merge changes so that everything becomes consistent again.
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   513
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   514
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: ::
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   515
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   516
    $ cd Fevicol-clone
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   517
    $ hg tip
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   518
    changeset:   3:e1ab2aff4ddd
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   519
    tag:         tip
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   520
    user:        Shantanu Choudhary <shantanu@fossee.in>
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   521
    date:        Sun Aug 23 23:32:01 2009 +0530
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   522
    summary:     Changed tagline for feviStick.py.
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   523
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   524
The tagline for feviCol.py is not complete, so we make changes in that file in this repo. ::
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   525
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   526
    $ echo "print 'Yeh Fevicol ka Majboot jod hai, tootega nahin'" > feviStick.py
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   527
    $ hg st
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   528
    M feviStick.py
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   529
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   530
And commit the changes made ::
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   531
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   532
    $ hg ci -u "Shantanu <shantanu@fossee.in>" -m "Updated tag line for feviCol.py."
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   533
    $ hg st
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   534
    $ hg tip
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   535
    changeset:   4:caf986b15e05
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   536
    tag:         tip
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   537
    user:        Shantanu <shantanu@fossee.in>
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   538
    date:        Tue Aug 25 16:28:24 2009 +0530
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   539
    summary:     Updated tag line for feviCol.py.
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   540
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   541
Now we will make some changes on Fevicol repo. We will add new file here ::
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   542
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   543
    $ cd Fevicol
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   544
    $ echo "print 'Jor laga ke hayyiya'" > firstAdd.py
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   545
    $ hg st
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   546
    ? firstAdd.py
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   547
    $ hg add firstAdd.py
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   548
    $ hg st
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   549
    A firstAdd.py
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   550
    $ hg ci -u "Shantanu <shantanu@fossee.in>" -m "Added firsAdd.py."
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   551
    $ hg tip
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   552
    changeset:   4:fadbd6492cc4
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   553
    tag:         tip
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   554
    user:        Shantanu <shantanu@fossee.in>
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   555
    date:        Tue Aug 25 16:46:24 2009 +0530
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   556
    summary:     Added firsAdd.py.
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   557
    
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   558
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): ::
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   559
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   560
    $ hg pull ../Fevicol-clone 
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   561
    pulling from ../Fevicol-clone
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   562
    searching for changes
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   563
    adding changesets
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   564
    adding manifests
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   565
    adding file changes
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   566
    added 1 changesets with 1 changes to 1 files (+1 heads)
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   567
    (run 'hg heads' to see heads, 'hg merge' to merge)
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   568
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   569
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. ::
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   570
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   571
    $ hg heads
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   572
    changeset:   5:caf986b15e05
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   573
    tag:         tip
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   574
    parent:      3:e1ab2aff4ddd
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   575
    user:        Shantanu <shantanu@fossee.in>
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   576
    date:        Tue Aug 25 16:28:24 2009 +0530
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   577
    summary:     Updated tag line for feviCol.py.
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   578
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   579
    changeset:   4:fadbd6492cc4
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   580
    user:        Shantanu <shantanu@fossee.in>
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   581
    date:        Tue Aug 25 16:46:24 2009 +0530
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   582
    summary:     Added firsAdd.py.
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   583
    
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   584
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. ::
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   585
     
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   586
    $ hg glog
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   587
    o  changeset:   5:caf986b15e05
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   588
    |  tag:         tip
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   589
    |  parent:      3:e1ab2aff4ddd
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   590
    |  user:        Shantanu <shantanu@fossee.in>
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   591
    |  date:        Tue Aug 25 16:28:24 2009 +0530
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   592
    |  summary:     Updated tag line for feviCol.py.
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   593
    |
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   594
    | @  changeset:   4:fadbd6492cc4
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   595
    |/   user:        Shantanu <shantanu@fossee.in>
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   596
    |    date:        Tue Aug 25 16:46:24 2009 +0530
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   597
    |    summary:     Added firsAdd.py.
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   598
    |
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   599
    o  changeset:   3:e1ab2aff4ddd
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   600
    |  user:        Shantanu Choudhary <shantanu@fossee.in>
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   601
    |  date:        Sun Aug 23 23:32:01 2009 +0530
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   602
    |  summary:     Changed tagline for feviStick.py.
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   603
    |
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   604
    o  changeset:   2:a7912d45f47c
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   605
    |  user:        Shantanu <shantanu@fossee.in>
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   606
    |  date:        Sun Aug 23 22:34:35 2009 +0530
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   607
    |  summary:     Updated Content.
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   608
    |
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   609
    o  changeset:   1:d948fb4137c5
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   610
    |  user:        Shantanu <shantanu@fossee.in>
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   611
    |  date:        Sat Aug 22 00:11:25 2009 +0530
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   612
    |  summary:     Renamed pidiLite.py.
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   613
    |
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   614
    o  changeset:   0:84f5e91f4de1
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   615
       user:        Shantanu <shantanu@fossee.in>
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   616
       date:        Fri Aug 21 23:37:13 2009 +0530
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   617
       summary:     First commit.
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   618
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   619
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. ::
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   620
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   621
    $ hg up
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   622
    abort: crosses branches (use 'hg merge' or 'hg update -C')
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   623
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   624
*hg merge* command merge working directory with another revision. ::
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   625
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   626
    $ hg merge
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   627
    1 files updated, 0 files merged, 0 files removed, 0 files unresolved
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   628
    (branch merge, don't forget to commit) 
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   629
    $ hg tip 
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   630
    changeset:   5:caf986b15e05
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   631
    tag:         tip
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   632
    parent:      3:e1ab2aff4ddd
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   633
    user:        Shantanu <shantanu@fossee.in>
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   634
    date:        Tue Aug 25 16:28:24 2009 +0530
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   635
    summary:     Updated tag line for feviCol.py.
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   636
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   637
After merging two branches, until we commit the results of merge it will keep on showing two heads. ::
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   638
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   639
    $ hg ci -u "Shantanu <shantanu@fossee.in>" -m "Merged branches of add and tag line."
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   640
    $ hg heads 
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   641
    changeset:   6:edbe97209954
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   642
    tag:         tip
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   643
    parent:      4:fadbd6492cc4
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   644
    parent:      5:caf986b15e05
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   645
    user:        Shantanu <shantanu@fossee.in>
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   646
    date:        Tue Aug 25 17:06:03 2009 +0530
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   647
    summary:     Merged branches of add and tag line.
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   648
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   649
Here is brief and meaningful output of glog ::
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   650
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   651
    $ hg glog 
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   652
    @    changeset:   6:edbe97209954
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   653
    |\   tag:         tip
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   654
    | |  parent:      4:fadbd6492cc4
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   655
    | |  parent:      5:caf986b15e05
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   656
    | |  user:        Shantanu <shantanu@fossee.in>
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   657
    | |  date:        Tue Aug 25 17:06:03 2009 +0530
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   658
    | |  summary:     Merged branches of add and tag line.
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   659
    | |
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   660
    | o  changeset:   5:caf986b15e05
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   661
    | |  parent:      3:e1ab2aff4ddd
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   662
    | |  user:        Shantanu <shantanu@fossee.in>
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   663
    | |  date:        Tue Aug 25 16:28:24 2009 +0530
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   664
    | |  summary:     Updated tag line for feviCol.py.
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   665
    | |
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   666
    o |  changeset:   4:fadbd6492cc4
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   667
    |/   user:        Shantanu <shantanu@fossee.in>
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   668
    |    date:        Tue Aug 25 16:46:24 2009 +0530
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   669
    |    summary:     Added firsAdd.py.
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   670
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   671
And we are back on track.
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   672
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   673
Workflow:
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   674
=========
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   675
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   676
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. 
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   677
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   678
For example: ::
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   679
    
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   680
    $ hg pull
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   681
    $ hg update
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   682
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   683
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: ::
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   684
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   685
    $ hg pull -u
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   686
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   687
Now let's say you make some changes. You edit a file and you want to commit your change. You can do this with: ::
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   688
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   689
    $ hg commit
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   690
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   691
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, ::
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   692
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   693
    $ hg push
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   694
8
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   695
Suggested Reading:
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   696
==================
8
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   697
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   698
	* http://karlagius.com/2009/01/09/version-control-for-the-masses/
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   699
	* http://betterexplained.com/articles/a-visual-guide-to-version-control/
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   700
	* http://en.wikipedia.org/wiki/Revision_control
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   701
	* http://hgbook.red-bean.com/
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   702
	* http://betterexplained.com/articles/intro-to-distributed-version-control-illustrated/