versionControl/handOut.rst
author Madhusudan.C.S <madhusudancs@gmail.com>
Tue, 07 Sep 2010 16:49:56 +0530
changeset 129 6e237b9442cd
parent 96 bb52cf47e920
child 135 339230606dc0
permissions -rw-r--r--
Adding a huge question for lab exercise 4.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
60
8a36825e21c5 Arithmetic section, typo correction, eg script.
Shantanu <shantanu@fossee.in>
parents: 54
diff changeset
     1
===============
8a36825e21c5 Arithmetic section, typo correction, eg script.
Shantanu <shantanu@fossee.in>
parents: 54
diff changeset
     2
Version Control
8a36825e21c5 Arithmetic section, typo correction, eg script.
Shantanu <shantanu@fossee.in>
parents: 54
diff changeset
     3
===============
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     4
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     5
Introduction
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
     6
============
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     7
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
     8
The following statement from a blog[1](http://karlagius.com/2009/01/09/version-control-for-the-masses/") aptly points usefulness of version control systems:
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     9
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    10
"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
    11
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
    12
Version control (or source control) is nothing more complex than keeping copies of work as we make changes. 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 wrong."
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    13
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
    14
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
    15
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    16
Why Use Version Control
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
    17
=======================
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
    18
 
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
    19
One of idea behind Version Control Tools was to build onto very first step which can be creating a empty file, or writing a first buggy program for assignment, rather than simply loose it. So here are some more reasons why is automated version control needed:
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    20
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    21
    - 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
    22
    - 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.
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
    23
    - It can help to recover from mistakes. If a change made at some moment of time, turns out to be an 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.
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    24
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
    25
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.
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    26
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    27
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
    28
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    29
     - cvs (Concurrent Version System)
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    30
     - svn (Subversion)
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    31
     - hg (Mercurial)
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    32
     - bzr (Bazaar)
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    33
     - git 
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    34
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    35
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
    36
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    37
Learning the Lingo
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
    38
==================
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    39
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
    40
Here are some of terms which are going to used through out the rest of session:
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    41
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    42
Basic Setup
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
    43
-----------
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    44
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
    45
(should we include at all terms used by vcs's other than hg?)
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
    46
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    47
     Repository(repo):
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
    48
	The folder with all the files.
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    49
     Server:
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
    50
	The system with the main(mother) repo.
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    51
     Trunk/Main:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    52
	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
    53
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    54
Basic Actions
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
    55
-------------
7
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
     Add:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    58
	Put a file into the repo for the first time, i.e. begin tracking it with Version Control.
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
    59
     Head/Tip:
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
    60
	The latest version of the repo(Die Hard 4.1)
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    61
     Revision:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    62
	What version a file is on.
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
    63
     Clone:
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
    64
     	Creating initial copy of the repo onto a local machine.
17
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
    65
     Commit:
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
    66
     	Committing the changes done to the repo in terms of contents of the files or adding/removing of the files.
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
    67
     Logs/History:
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
    68
	Logs of all the past changes done to the repo.
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
    69
     Update:
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
    70
        Updating the local repo with the main one, includes both, adding changing done by us or importing changes done by others.
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    71
     Revert:
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
    72
        Going back to previous committed state of file.
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    73
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    74
Advanced Actions:
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
    75
-----------------
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    76
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    77
     Branch:
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
    78
	Create a separate copy of the repo for private use (bug fixing, testing, etc).
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    79
     Diff/Change:
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
    80
	Finding the differences between two versions of a file.
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    81
     Merge (or patch):
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
    82
     	Apply the changes from one branch to another, to bring it up-to-date.
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    83
     Conflict:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    84
	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
    85
     
8
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
    86
Types of Version Control:
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
    87
-------------------------
8
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
    88
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
    89
(should we have this part at all?)
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
    90
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
    91
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
    92
      - Centralized VCS: 
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
    93
      	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 others 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.
8
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
    94
   
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
    95
      - Distributed VCS:
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
    96
      	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
    97
15
d20e3fe4fd8c Started hg command section.
Shantanu <shantanu@fossee.in>
parents: 8
diff changeset
    98
Get Going with Hg:
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
    99
==================
8
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   100
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   101
Why hg?
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   102
-------
15
d20e3fe4fd8c Started hg command section.
Shantanu <shantanu@fossee.in>
parents: 8
diff changeset
   103
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   104
   - easy to learn and use.
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   105
   - lightweight.
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   106
   - scales excellently.
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   107
   - based on Python.
15
d20e3fe4fd8c Started hg command section.
Shantanu <shantanu@fossee.in>
parents: 8
diff changeset
   108
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   109
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
   110
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   111
Installation:
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   112
-------------
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   113
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   114
- For Linux based systems, hg is available in most of package management. So for say Ubuntu systems::
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   115
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   116
   $ sudo apt-get install mercurial
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   117
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   118
  will be all you need to install hg. Similarly Fedora users can use yum to install hg. 
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   119
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   120
- For Windows and Mac OS X systems the setup can be downloaded from http://mercurial.selenic.com/downloads/ and standard installation can be followed.
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   121
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   122
Getting Started:
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   123
----------------
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   124
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   125
After installation is complete lets get started with using. First things first, lets pay our homage to *man* pages as per rituals: ::
15
d20e3fe4fd8c Started hg command section.
Shantanu <shantanu@fossee.in>
parents: 8
diff changeset
   126
   
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   127
   $ man hg
15
d20e3fe4fd8c Started hg command section.
Shantanu <shantanu@fossee.in>
parents: 8
diff changeset
   128
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   129
This will give us manuscript of all the options available with *hg*. We can either look through all of it, or a better way will be to use built-in help system of *hg*. Say to get brief list of all commands, along with a description of what each does we can use ::
15
d20e3fe4fd8c Started hg command section.
Shantanu <shantanu@fossee.in>
parents: 8
diff changeset
   130
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   131
   $ hg help
15
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	-----------------------
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   137
   ------------------------------------
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   138
   heads        show current repository heads or show branch heads
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   139
   ------------------------------------
15
d20e3fe4fd8c Started hg command section.
Shantanu <shantanu@fossee.in>
parents: 8
diff changeset
   140
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   141
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
   142
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   143
    $ hg help diff
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   144
    hg diff [OPTION]... [-r REV1 [-r REV2]] [FILE]...
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   145
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   146
    diff repository (or selected files)
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   147
    Show differences between revisions for the specified files.
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   148
    Differences between files are shown using the unified diff format.
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   149
    NOTE:____________
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   150
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   151
Let there be Repository:
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   152
------------------------
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   153
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   154
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 which Mercurial treats as special.
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   155
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   156
There can be two ways to create a repo, either downloading a copy of existing repo available on Internet, or creating/starting a new repo. 
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   157
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   158
Say we have a directory which we want to bring under version control, so we start a new repository using *hg init*: ::
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   159
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   160
  $ ls -a circulate/
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   161
  .  ..  lena.png  pendulum.txt  points.txt  pos.txt  sslc1.py  sslc1.txt
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   162
  $ cd circulate/
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   163
  $ hg init
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   164
  $ ls -a
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   165
  .  ..  .hg  lena.png  pendulum.txt  points.txt  pos.txt  sslc1.py  sslc1.txt
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   166
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   167
*.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.
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   168
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   169
For getting already existing repo hg uses command *"clone"* ::
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   170
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   171
      $ hg clone http://hg.serpentine.com/tutorial/hello localCopyhello
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   172
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   173
      requesting all changes
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   174
      adding changesets
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   175
      adding manifests
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   176
      adding file changes
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   177
      added 5 changesets with 5 changes to 2 files
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   178
      updating working directory
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   179
      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
   180
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   181
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
   182
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   183
      $ ls localCopyhello/
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   184
      hello.c  Makefile
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   185
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   186
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
   187
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   188
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
   189
	
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   190
     $ hg clone localCopyhello newCopy
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   191
    updating working directory
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   192
    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
   193
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   194
newCopy is exact copy of already existing repo. 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.
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   195
	
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   196
History or Logs:
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   197
----------------
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   198
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   199
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 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
   200
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   201
    $ hg log
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   202
    changeset:   4:2278160e78d4
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   203
    tag:         tip
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   204
    user:        Bryan O'Sullivan <bos@serpentine.com>
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   205
    date:        Sat Aug 16 22:16:53 2008 +0200
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   206
    summary:     Trim comments.
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   207
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   208
    changeset:   3:0272e0d5a517
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   209
    user:        Bryan O'Sullivan <bos@serpentine.com>
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   210
    date:        Sat Aug 16 22:08:02 2008 +0200
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   211
    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
   212
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   213
    changeset:   2:fef857204a0c
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   214
    user:        Bryan O'Sullivan <bos@serpentine.com>
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   215
    date:        Sat Aug 16 22:05:04 2008 +0200
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   216
    summary:     Introduce a typo into hello.c.
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   217
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   218
    changeset:   1:82e55d328c8c
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   219
    user:        mpm@selenic.com
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   220
    date:        Fri Aug 26 01:21:28 2005 -0700
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   221
    summary:     Create a makefile
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   222
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   223
    changeset:   0:0a04b987be5a
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   224
    user:        mpm@selenic.com
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   225
    date:        Fri Aug 26 01:20:50 2005 -0700
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   226
    summary:     Create a standard "hello, world" program
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   227
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   228
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
   229
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   230
   - changeset: This field is a identifier for the changeset. The hex string is a unique identifier.
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   231
   - user: The identity of the person who created the changeset.
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   232
   - date: The date and time on which the changeset was created.
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   233
   - summary: The first line of the text message entered to describe the changeset.
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   234
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   235
To narrow the output of hg log down to a single revision, use the -r option. ::
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   236
   
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   237
   $ hg log -r 3
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   238
   changeset:   3:0272e0d5a517
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   239
   user:        Bryan O'Sullivan <bos@serpentine.com>
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   240
   date:        Sat Aug 16 22:08:02 2008 +0200
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   241
   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
   242
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   243
*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
   244
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   245
   $  hg log -r 2:4
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   246
   changeset:   2:fef857204a0c
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   247
   user:        Bryan O'Sullivan <bos@serpentine.com>
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   248
   date:        Sat Aug 16 22:05:04 2008 +0200
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   249
   summary:     Introduce a typo into hello.c.
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   250
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   251
   changeset:   3:0272e0d5a517
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   252
   user:        Bryan O'Sullivan <bos@serpentine.com>
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   253
   date:        Sat Aug 16 22:08:02 2008 +0200
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   254
   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
   255
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   256
   changeset:   4:2278160e78d4
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   257
   tag:         tip
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   258
   user:        Bryan O'Sullivan <bos@serpentine.com>
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   259
   date:        Sat Aug 16 22:16:53 2008 +0200
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   260
   summary:     Trim comments.
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   261
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   262
-v option with "log" gives some extra details related to a changeset.
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   263
17
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   264
Making Changes:
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   265
---------------
17
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   266
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   267
Lets follow a simple exercise of *managing letters* using hg. We create a new directory and start revision tracking on it.::
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   268
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   269
  $  mkdir letter
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   270
  $  cd letter
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   271
  $  touch letter.tex
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   272
  $  hg init
17
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   273
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   274
Now lets try to create a local clone of this repository::
17
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   275
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   276
  $  hg clone letter letter-clone
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   277
  updating working directory
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   278
  0 files updated, 0 files merged, 
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   279
  0 files removed, 0 files unresolved 
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   280
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   281
So here, message says 0 files updated but we have just created a *tex* file inside it. Lets try to see status of our main repository by using *status(st)* command::
17
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   282
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   283
  $ cd letter  
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   284
  $ hg st
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   285
  ? letter.tex
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   286
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   287
"?" sign in front of file indicates that this file is alien to hg, as in we have to *add* it to repo by::
17
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   288
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   289
  $ hg add letter.tex
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   290
  $ hg st
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   291
  A letter.tex
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   292
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   293
So file is now part of repository(A symbol). We *commit (alias ci)* it to repo and make changes effective ::
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   294
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   295
   $ hg ci -u "Shantanu <shantanu@fossee.in>" 
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   296
        -m "First commit."
17
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   297
   $ hg log
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   298
   changeset:   0:210664b4ed58
17
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   299
   tag:         tip
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   300
   user:        Shantanu <shantanu@fossee.in>
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   301
   date:        Tue Feb 23 19:41:45 2010 +0530
17
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   302
   summary:     First commit.
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   303
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   304
Some arguments passed to *ci* command are worth noticing:
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   305
 - *u* is to provide name and email contact information of person making changes!
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   306
 - *m* is to provide one-line summary of changeset. 
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   307
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   308
If we don't give these options, *ci* will take us to a default editor, there we have to specify a commit *message* in first line, then we can edit other information like username, once done just exit the editor and changes are committed to the repo. Now these changes will be visible in logs.
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   309
38
ce7634ee7986 Some more typo correction.
Shantanu <shantanu@fossee.in>
parents: 37
diff changeset
   310
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
   311
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   312
   $ hg cp letter.tex letter-prof.tex
17
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   313
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   314
*rename(alias mv)* rename files; equivalent of copy + remove. ::
17
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   315
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   316
   $ hg rename letter.tex letter-personal.tex
17
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   317
   $ hg st
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   318
   A letter-personal.tex
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   319
   A letter-pro.tex
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   320
   R letter.tex
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   321
   $ hg ci -u "Shantanu <shantanu@fossee.in>" -m "Renamed and added letters."
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   322
           
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   323
*tip* command shows newest revision in the repository. ::
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   324
17
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   325
   $ hg tip
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   326
   changeset:   1:4a2d973a92de
17
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   327
   user:        Shantanu <shantanu@fossee.in>
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   328
   date:        Tue Feb 23 19:50:39 2010 +0530
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   329
   summary:     Renamed and added letters.
17
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   330
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   331
Sharing Changes:
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   332
----------------
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   333
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   334
Pulling from repo:
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   335
~~~~~~~~~~~~~~~~~~
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   336
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   337
As mentioned earlier that repositories in Mercurial are self-contained. This means that the changeset just created exists only in *letter* repository and not in previously cloned . There are a few ways that can be used to propagate this change into other repositories. *pull* command will download all changeset from main repo. ::
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   338
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   339
   $ cd letter-clone
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   340
   $ hg pull 
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   341
   pulling from /home/baali/letter
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   342
   requesting all changes
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   343
   adding changesets
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   344
   adding manifests
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   345
   adding file changes
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   346
   added 2 changesets with 2 changes to 2 files
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   347
   (run 'hg update' to get a working copy)
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
*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
   350
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   351
   pull changes from the specified source
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   352
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   353
   Pull changes from a remote repository to a local one.
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   354
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   355
   This finds all changes from the repository at the specified path
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   356
   or URL and adds them to the local repository. By default, this
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   357
   does not update the copy of the project in the working directory.
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   358
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   359
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
   360
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   361
As output of *pull* command suggests it does not(by default) update the working directory. By update we mean, content of files and directory structure still remains the same as prior to *pull* command. *hg up (alias update)* command updates repo by adding latest imported changesets and bringing it upto date. ::
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   362
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   363
   $ ls -a
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   364
   .  ..  .hg
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   365
   $ hg up
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   366
   2 files updated, 0 files merged, 
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   367
   0 files removed, 0 files unresolved
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   368
   $ ls -a
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   369
   .  ..  .hg  letter-personal.tex  
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   370
   letter-pro.tex
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   371
    
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   372
To update to specific version, give a version number to the *hg update* command.
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   373
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   374
Making Changes:
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   375
~~~~~~~~~~~~~~~
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   376
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   377
Lets start with adding content to letters. For start personal letter can be a letter to ask a boy/girl out! Using LaTeX to write letter, it would be straight forward, open the file in any text editor and add the following content to it ::
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   378
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   379
  \documentclass{letter}
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   380
  \begin{document}
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   381
  \begin{letter}{}
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   382
  \opening{Hello xxxxxx,}
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   383
  I really enjoyed meeting you in CS 101, 
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   384
  but would love to know you better. 
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   385
  How about a coffee on Thursday after class?
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   386
  \closing{-xxxxx}
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   387
  \end{letter}
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   388
  \end{document}
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   389
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   390
Replace "xxxxx" with proper names to suite yourself. Mercurial's hg status command will tell us what Mercurial knows about the files in the repository. 'M' sign in front of feviStick.py indicates that Mercurial has noticed change(modified). ::
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   391
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   392
  $ hg st
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   393
  M letter-personal.tex
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   394
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   395
At times more information is needed on knowing exactly what changes were made to what files. To do this, use the *hg diff* command. ::
26
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
    $ hg diff
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   398
    diff -r 4a2d973a92de letter-personal.tex
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   399
    --- a/letter-personal.tex	Tue Feb 23 19:50:39 2010 +0530
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   400
    +++ b/letter-personal.tex	Tue Jun 08 16:12:19 2010 +0530
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   401
    @@ -0,0 +1,11 @@
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   402
    +\documentclass{letter}
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   403
    +\begin{document}
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   404
    + 
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   405
    +\begin{letter}{}
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   406
    +\opening{Hello Jas,}
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   407
    +  
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   408
    +I really enjoyed meeting you in CS 101, but would love to know you better. How about a coffee on Thursday after class?
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   409
    +
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   410
    +\closing{-Samarth}
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   411
    +\end{letter}
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   412
    +\end{document}
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   413
        
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   414
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.Then we use *hg commit* to create a new changeset
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   415
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   416
Mercurial records your name and email-address with each change that you commit, so that you and others will later be able to tell who made each change. It also 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:
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   417
	  
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   418
	  - Specify a -u option to the hg commit command on the command line, followed by a username, this is the procedure we used earlier.
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   419
	  - set HGUSER environment variable::
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   420
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   421
	    $ export HGUSER="xxxxx"	  
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   422
	  - 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
   423
	  
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   424
		[ui]
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   425
		username = Firstname Lastname <email.address@example.net>
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   426
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   427
	    For me the hgrc file for *letter* clone repo looks like this: ::
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   428
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   429
	        [paths]
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   430
		default = /home/baali/letter
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   431
		[ui]	
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   432
		username = Shantanu Choudhary <shantanu@fossee.in>
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   433
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   434
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
   435
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   436
    Added content to personal letter.
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   437
    HG: Enter commit message.  Lines beginning with 'HG:' are removed.
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   438
    HG: --
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   439
    HG: user: Shantanu Choudhary <shantanu@fossee.in>
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   440
    HG: branch 'default'
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   441
    HG: changed letter-personal.tex
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   442
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   443
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
   444
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   445
    $ hg tip
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   446
    changeset:   2:a5d8cb2fac01
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   447
    user:        Shantanu <shantanu@fossee.in>
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   448
    date:        Tue Feb 23 20:34:12 2010 +0530
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   449
    summary:     Added content to personal letter.
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   450
    
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   451
One can do above mentioned procedure using following one line command: ::
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   452
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   453
    $ hg ci -u "Shantanu <shantanu@fossee.in>" -m "Added content to personal letter."
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   454
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   455
Sharing Changes:
17
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   456
~~~~~~~~~~~~~~~~
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   457
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   458
So now we have this *letter-clone* repo where we created above changes and committed them. But the main repo(*trunk*) that is *letter* wont be hinted of these changes. It will be still in older stage, same way as we pulled changes to this cloned repo from main branch at starting. To share changes from a cloned repo to main branch hg provides with *push* command. It is same as *pull* but instead of pulling it pushes the changes to trunk. ::
26
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
    $ hg push ../Fevicol
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   461
    pushing to ../Fevicol
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   462
    searching for changes
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   463
    adding changesets
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   464
    adding manifests
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   465
    adding file changes
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   466
    added 1 changesets with 1 changes to 1 files
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   467
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   468
Same as with hg pull, the hg push command populates the changesets nothing more. ::
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   469
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   470
   $ cd ../letter
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   471
   $ hg tip
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   472
   changeset:   2:a5d8cb2fac01
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   473
   user:        Shantanu <shantanu@fossee.in>
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   474
   date:        Tue Feb 23 20:34:12 2010 +0530
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   475
   summary:     Added content to personal letter.
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   476
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   477
The branch where changes are being pushed still need *up* to be updated or for inclusion of all the imported changesets ::
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   478
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   479
   $ hg up
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   480
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   481
   $ cat letter-personal.tex
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   482
   \documentclass{letter}
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   483
   \begin{document} 
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   484
   \begin{letter}{}
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   485
   \opening{Hello xxxx,}  
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   486
   I really enjoyed meeting you in CS 101, but would love to know you better. How about a coffee on Thursday after class?
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   487
 
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   488
   \closing{-xxxx}
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   489
   \end{letter}
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   490
   \end{document}
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   491
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   492
Merging the Work:
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   493
~~~~~~~~~~~~~~~~~
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   494
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   495
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
   496
38
ce7634ee7986 Some more typo correction.
Shantanu <shantanu@fossee.in>
parents: 37
diff changeset
   497
Two persons, A and B are contributing on same project. Both starts from cloning the same online repo(lets say present state X), so that both have a working local repo. Now A edits one of file, commits the changes and pushes to the repo, hence changing the state of repo to Y, but B, have not updated his repo, makes a change in one of files and reaches to a different state Z. Now when A pulls repo from B, his repo will have multiple heads. This stage is clearly ambiguous, the repo of A is not consistent, it has multiple heads, and from here, whatever changes he makes can take whatsoever direction if it is not fixed, and hence A will have to merge changes so that everything becomes consistent again.
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   498
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   499
Lets see how this work with working repo, we will use letter and letter-clone repositories created earlier. For now, the status of both repo is: ::
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   500
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   501
   $ cd letter-clone
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   502
   $ hg tip
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   503
   changeset:   2:a5d8cb2fac01
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   504
   user:        Shantanu <shantanu@fossee.in>
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   505
   date:        Tue Feb 23 20:34:12 2010 +0530
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   506
   summary:     Added content to personal letter.
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   507
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   508
We share(clones) this repo with a friend, he goes through the letter and just makes small change of adding color to clogins part of letter. ::
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   509
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   510
   $ hg diff
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   511
   diff -r 4a2d973a92de letter-personal.tex
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   512
   --- a/letter-personal.tex	Tue Feb 23 19:50:39 2010 +0530
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   513
   +++ b/letter-personal.tex	Wed Feb 24 12:03:33 2010 +0530
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   514
   @@ -0,0 +1,12 @@
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   515
   \documentclass{letter}
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   516
   +\usepackage{color}
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   517
   \begin{document}
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   518
   .
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   519
   -\closing{-Samarth}
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   520
   +\closing{\textcolor{red}{-Samarth}}
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   521
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   522
Here the "-" sign shows which lines are removed, and "+" indicates what lines are added. He is satisfied and commits the changes. ::
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   523
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   524
    $ hg ci -u "Vattam <vattam@fossee.in>" -m "Added some suggestions."   
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   525
    changeset:   3:71fd776d856b
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   526
    parent:      2:a5d8cb2fac01
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   527
    user:        Vattam <vattam@fossee.in>
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   528
    date:        Wed Feb 24 12:54:31 2010 +0530
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   529
    summary:     Added some suggestions.
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   530
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   531
In the meanwhile, it seems, our "xxxx" is already dating someone else. So we also change the name to "yyyy" who is available, and we commit it ::
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   532
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   533
    $ cd letter
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   534
    $ hg ci -u "Shantanu <shantanu@fossee.in>" -m "Changed name."
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   535
    $ hg tip
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   536
    changeset:   3:02b49a53063f
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   537
    user:        Shantanu <shantanu@fossee.in>
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   538
    date:        Wed Feb 24 13:12:26 2010 +0530
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   539
    summary:     Changed name.
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   540
    
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   541
So now we have two repo, who have different commit history and tree. 
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   542
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   543
.. image:: glog-main.png 
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   544
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   545
.. image:: glog-suggestion.png
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   546
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   547
If we try to pull changes from one to another, this is how it goes(we are still in letter repo): ::
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   548
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   549
    $ hg pull ../letter-suggestion
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   550
    pulling from ../letter-suggestion
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   551
    searching for changes
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   552
    adding changesets
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   553
    adding manifests
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   554
    adding file changes
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   555
    added 1 changesets with 1 changes to 1 files (+1 heads)
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   556
    (run 'hg heads' to see heads, 'hg merge' to merge)    
37
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
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
   559
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   560
    $ hg heads 
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   561
    changeset:   4:71fd776d856b
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   562
    tag:         tip
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   563
    parent:      2:a5d8cb2fac01
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   564
    user:        Vattam <vattam@fossee.in>
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   565
    date:        Wed Feb 24 12:54:31 2010 +0530
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   566
    summary:     Added some suggestions.
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   567
    
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   568
    changeset:   3:02b49a53063f
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   569
    user:        Shantanu <Shantanu@fossee.in>
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   570
    date:        Wed Feb 24 13:12:26 2010 +0530
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   571
    summary:     Changed name.
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   572
    
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   573
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
   574
     
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   575
    $ hg glog
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   576
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   577
.. image:: heads.png
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
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
   580
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   581
    $ hg up
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   582
    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
   583
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   584
*hg merge* command merge working directory with another revision. ::
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 merge
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   587
    1 files updated, 0 files merged, 0 files removed, 0 files unresolved
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   588
    (branch merge, don't forget to commit)   
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   589
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   590
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
   591
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   592
    $ hg ci -u "Shantanu <shantanu@fossee.in>" -m "Merged branches."
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   593
    $ hg glog 
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   594
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   595
.. image:: glog-2.png
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   596
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   597
*And we are back on track.*
37
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
Workflow:
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   600
=========
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   601
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   602
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
   603
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   604
For example: ::
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   605
    
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   606
    $ hg pull
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   607
    $ hg update
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
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
   610
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   611
    $ hg pull -u
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   612
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   613
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
   614
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   615
    $ hg commit
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   616
54
bed3fe467e21 First version of 5-6 Session of ult.
Shantanu <shantanu@fossee.in>
parents: 38
diff changeset
   617
An editor will pop-up asking you to write a message describing your change. 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, ::
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   618
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   619
    $ hg push
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   620
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   621
Cheatsheet
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   622
==========
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   623
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   624
.. image:: mod.png
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   625
8
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   626
Suggested Reading:
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   627
==================
8
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   628
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   629
	* 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
   630
	* http://betterexplained.com/articles/a-visual-guide-to-version-control/
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   631
	* http://en.wikipedia.org/wiki/Revision_control
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   632
	* http://hgbook.red-bean.com/
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   633
	* http://betterexplained.com/articles/intro-to-distributed-version-control-illustrated/
38
ce7634ee7986 Some more typo correction.
Shantanu <shantanu@fossee.in>
parents: 37
diff changeset
   634
	* http://wiki.alliedmods.net/Mercurial_Tutorial