versionControl/handOut.rst
author Puneeth Chaganti <punchagan@fossee.in>
Mon, 31 Jan 2011 12:48:45 +0530
changeset 150 8526f94072f6
parent 149 4499aebbee83
child 151 44838801f255
permissions -rw-r--r--
vcs: Add include directive for exercises in handOut.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
148
79315a169b96 vcs: Add highlight directive to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 147
diff changeset
     1
.. highlight:: bash
79315a169b96 vcs: Add highlight directive to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 147
diff changeset
     2
60
8a36825e21c5 Arithmetic section, typo correction, eg script.
Shantanu <shantanu@fossee.in>
parents: 54
diff changeset
     3
===============
8a36825e21c5 Arithmetic section, typo correction, eg script.
Shantanu <shantanu@fossee.in>
parents: 54
diff changeset
     4
Version Control
8a36825e21c5 Arithmetic section, typo correction, eg script.
Shantanu <shantanu@fossee.in>
parents: 54
diff changeset
     5
===============
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     6
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     7
Introduction
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
     8
============
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     9
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    10
Version control is just a way to track your files over time and share them.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    11
This allows you to go back to older versions when something goes wrong, see
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    12
what changed when and why, collaborate on a single piece of work with a bunch
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    13
of people. 
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    14
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    15
Like this
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    16
`blog <http://karlagius.com/2009/01/09/version-control-for-the-masses/>`_
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    17
aptly points out, "Version control is one of those weird, geeky things that
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    18
never really gained much ground in non-geek fields, despite the fact that
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    19
it’s blindingly useful." In this course, we are going to see a handful of
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    20
such things, which are widely used in the programmer world, but not so much
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    21
in the scientific computing world, even when if they would be very useful.
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    22
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    23
Version control is just a way of backing up your files, before making changes
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    24
to it. Most people would have cooked up their own version control system,
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    25
without realizing, there are tools built by others, which make this task much
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    26
more organized and systematic. You surely would've saved your files, some
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    27
time or the other as ``oldproject.py``, ``latestproject.py`` and so on, or
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    28
date-tagging them as ``project-21-01-10.py``, ``project-20-02-10.py`` and so
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    29
on. 
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    30
136
68508b5175db vcs: Minor changes to handout
Puneeth Chaganti <punchagan@fossee.in>
parents: 135
diff changeset
    31
It is, in some ways, similar to playing a video game. We generally play games
68508b5175db vcs: Minor changes to handout
Puneeth Chaganti <punchagan@fossee.in>
parents: 135
diff changeset
    32
in stages, saving the game, each time we finish a stage or complete a task.
68508b5175db vcs: Minor changes to handout
Puneeth Chaganti <punchagan@fossee.in>
parents: 135
diff changeset
    33
We continue playing, but we could, if necessary, choose to go back to one of
68508b5175db vcs: Minor changes to handout
Puneeth Chaganti <punchagan@fossee.in>
parents: 135
diff changeset
    34
the saved states and start over. In this manner we could change the state of
68508b5175db vcs: Minor changes to handout
Puneeth Chaganti <punchagan@fossee.in>
parents: 135
diff changeset
    35
the game. 
68508b5175db vcs: Minor changes to handout
Puneeth Chaganti <punchagan@fossee.in>
parents: 135
diff changeset
    36
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    37
Why Use Version Control
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
    38
=======================
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
    39
 
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    40
We have seen that one of the main motivation to use a version system control
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    41
system is the ability to go back to a working version of the file, when
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    42
something stops working. Below are a few more advantages of using an
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    43
automated version control system.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    44
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    45
    - It tracks the history and evolution of a project. It allows you to
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    46
      track what changes were made at what point of time, when and by whom. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    47
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    48
    - If you are collaborating, as a team on a project, a version control
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    49
      system will make it much easier for you to collaborate. It allows you
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    50
      to work simultaneously on the same file, without worrying about merging
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    51
      your changes. 
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    52
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    53
    - A good version control system will help you efficiently track down bugs
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    54
      and pin-point the changes that introduced the bug, reducing your
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    55
      debugging time. 
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    56
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    57
Version control is as useful for a one man show, as it is for a big group of
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    58
people working on a project. As a student, you can use it to maintain your
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    59
course work, too. You could maintain a version controlled repository with all
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    60
your code, assignments, and other documents. Keeping your stuff version
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    61
controlled will help avoid accidental deletion of individual files etc.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    62
Hosting it on a remote server will protect you from a local hard disk crash. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    63
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    64
Mercurial
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    65
=========
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    66
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    67
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
    68
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    69
  - ``cvs`` (Concurrent Versions System)
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    70
  - ``svn`` (Subversion)
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    71
  - ``hg`` (Mercurial)
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    72
  - ``git`` 
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    73
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    74
Each of these tools have some unique functionality and their own merits and
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    75
de-merits. In this course, we shall learn to use Mercurial or ``hg``.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    76
Once you know how to use ``hg``, you could easily try other tools and switch
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    77
to one that you feel most comfortable with.
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    78
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    79
Why ``hg`` ?
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    80
------------
15
d20e3fe4fd8c Started hg command section.
Shantanu <shantanu@fossee.in>
parents: 8
diff changeset
    81
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
    82
   - easy to learn and use.
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
    83
   - lightweight.
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
    84
   - scales excellently.
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
    85
   - based on Python.
15
d20e3fe4fd8c Started hg command section.
Shantanu <shantanu@fossee.in>
parents: 8
diff changeset
    86
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    87
Installation
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    88
------------
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
    89
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    90
- For Linux based systems, hg is available in most of package management. So
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    91
  for say Ubuntu systems::
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
    92
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
    93
   $ sudo apt-get install mercurial
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
    94
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    95
  will be all you need to install hg. Similarly Fedora users can use yum to
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    96
  install hg.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    97
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    98
- For Windows and Mac OS X systems the setup can be downloaded from
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
    99
  http://mercurial.selenic.com/downloads/ and standard installation can be
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   100
  followed.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   101
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   102
Just say ``hg`` in your shell, to see some of the commands that ``hg``
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   103
provides and say ``hg version`` to see the version of ``hg`` that has
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   104
been installed on your system. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   105
136
68508b5175db vcs: Minor changes to handout
Puneeth Chaganti <punchagan@fossee.in>
parents: 135
diff changeset
   106
Let there be a Repository
68508b5175db vcs: Minor changes to handout
Puneeth Chaganti <punchagan@fossee.in>
parents: 135
diff changeset
   107
=========================
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   108
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   109
To start using Mercurial (or ``hg``) and get the benefits of using a version
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   110
control system, we should first have a **repository**. A repository is a
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   111
folder with all your files and a store of all the changes that were made to
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   112
it. To save disk space, ``hg`` doesn't save all the files, but only saves
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   113
only a series of changes made to the files.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   114
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   115
We have talked of an example of how we cook up our own version control
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   116
systems. Mercurial does almost the same thing with one major difference. It
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   117
doesn't keep track of individual files. It keeps snapshots of the whole
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   118
directory (or repository), instead of individual files.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   119
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   120
A repository can either be started using an ``init`` command or an existing
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   121
repository could be **cloned**.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   122
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   123
Let us look at creating our own repository, now. We can look at obtaining
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   124
already existing repositories, at a later stage.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   125
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   126
Let's say we have a folder called ``book``, which has all the chapters of a
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   127
book as text files. Let us convert that folder, into a ``hg`` repository.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   128
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   129
::
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   130
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   131
    $ cd book/
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   132
    $ ls -a
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   133
    . .. chapter1.txt chapter2.txt chapter3.txt 
149
4499aebbee83 vcs: Fix pygments highlighting of code blocks with $ and '
Puneeth Chaganti <punchagan@fossee.in>
parents: 148
diff changeset
   134
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   135
    
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   136
We have three chapters in the folder. We convert this folder into a mercurial
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   137
repository using the ``hg init`` command
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   138
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   139
::
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   140
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   141
    $ hg init
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   142
    $ ls -a
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   143
    . .. .hg chapter1.txt chapter2.txt chapter3.txt 
149
4499aebbee83 vcs: Fix pygments highlighting of code blocks with $ and '
Puneeth Chaganti <punchagan@fossee.in>
parents: 148
diff changeset
   144
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   145
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   146
The ``.hg`` directory indicates that our book directory is now a ``hg``
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   147
repository. Mercurial keeps all the history of the changes made, and a few
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   148
other config files, etc. in this directory. The directory, ``book`` is called
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   149
our **working directory**. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   150
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   151
Adding Files
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   152
------------
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   153
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   154
We now have a fresh repository, but all our files are not being tracked or
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   155
watched by ``mercurial``, yet. We need to explicitly ask it to watch the
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   156
files, that we want it to.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   157
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   158
To see this use the ``hg status`` command. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   159
::
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   160
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   161
    $ hg status
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   162
    ? chapter1.txt
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   163
    ? chapter2.txt
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   164
    ? chapter3.txt
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   165
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   166
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   167
We see the three files for the chapters, but they are preceded by a ``?``
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   168
mark. What does it mean?
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   169
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   170
We use the ``help`` command to see what this means. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   171
::
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   172
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   173
    $ hg help status 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   174
    ...
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   175
    The codes used to show the status of files are:
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   176
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   177
      M = modified
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   178
      A = added
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   179
      R = removed
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   180
      C = clean
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   181
      ! = missing (deleted by non-hg command, but still tracked)
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   182
      ? = not tracked
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   183
      I = ignored
136
68508b5175db vcs: Minor changes to handout
Puneeth Chaganti <punchagan@fossee.in>
parents: 135
diff changeset
   184
        = origin of the previous file listed as A (added)        
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   185
    ...
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   186
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   187
By looking at the codes, it is clear that our files are not *yet* being
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   188
tracked by ``hg``. We now use the add command to ask ``hg`` to track these
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   189
files.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   190
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   191
The ``status`` command gives the *status* of our working-directory at this
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   192
point in time. Using this command after every ``hg`` command you use, is a
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   193
good idea, at least until you are reasonably comfortable with the use of
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   194
``hg``.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   195
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   196
::
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   197
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   198
    $ hg add
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   199
    adding chapter1.txt
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   200
    adding chapter2.txt
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   201
    adding chapter3.txt
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   202
    $ hg status
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   203
    A chapter1.txt
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   204
    A chapter2.txt
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   205
    A chapter3.txt
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   206
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   207
This simply adds all the files in the (working) directory, to the repository.
136
68508b5175db vcs: Minor changes to handout
Puneeth Chaganti <punchagan@fossee.in>
parents: 135
diff changeset
   208
As expected, the ``status`` command shows an ``A`` before he file names. We
68508b5175db vcs: Minor changes to handout
Puneeth Chaganti <punchagan@fossee.in>
parents: 135
diff changeset
   209
could also specify files individually, for example
68508b5175db vcs: Minor changes to handout
Puneeth Chaganti <punchagan@fossee.in>
parents: 135
diff changeset
   210
68508b5175db vcs: Minor changes to handout
Puneeth Chaganti <punchagan@fossee.in>
parents: 135
diff changeset
   211
::
147
6b8bf1951cf4 vcs: Fix problem with typesetting a code block.
Puneeth Chaganti <punchagan@fossee.in>
parents: 143
diff changeset
   212
136
68508b5175db vcs: Minor changes to handout
Puneeth Chaganti <punchagan@fossee.in>
parents: 135
diff changeset
   213
    $ hg add chapter1.txt
68508b5175db vcs: Minor changes to handout
Puneeth Chaganti <punchagan@fossee.in>
parents: 135
diff changeset
   214
    adding chapter1.txt
68508b5175db vcs: Minor changes to handout
Puneeth Chaganti <punchagan@fossee.in>
parents: 135
diff changeset
   215
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   216
143
fde473906aac vcs: Mention hg remove command.
Puneeth Chaganti <punchagan@fossee.in>
parents: 139
diff changeset
   217
*Note*: If you have deleted files, ``hg status`` will show you the status
fde473906aac vcs: Mention hg remove command.
Puneeth Chaganti <punchagan@fossee.in>
parents: 139
diff changeset
   218
 code ``!``. You can then, tell ``hg`` to stop tracking these files, using
fde473906aac vcs: Mention hg remove command.
Puneeth Chaganti <punchagan@fossee.in>
parents: 139
diff changeset
   219
 the ``hg remove`` command. Look at ``hg help remove`` for more details. 
fde473906aac vcs: Mention hg remove command.
Puneeth Chaganti <punchagan@fossee.in>
parents: 139
diff changeset
   220
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   221
Taking Snapshots
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   222
----------------
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   223
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   224
We have added a set of new files to the repository, but we haven't told
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   225
mercurial to remember these changes, i.e., to take a snapshot at this point
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   226
in time. We do this by using the ``commit`` command.
15
d20e3fe4fd8c Started hg command section.
Shantanu <shantanu@fossee.in>
parents: 8
diff changeset
   227
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   228
::
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   229
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   230
    $ hg commit 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   231
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   232
We are now prompted with a new editor window. We type out our message here
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   233
describing the changes that we have made.
15
d20e3fe4fd8c Started hg command section.
Shantanu <shantanu@fossee.in>
parents: 8
diff changeset
   234
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   235
::
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   236
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   237
    Initial Commit
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   238
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   239
    HG: Enter commit message.  Lines beginning with 'HG:' are removed.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   240
    HG: Leave message empty to abort commit.
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   241
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   242
Mercurial has now taken a snapshot of our repository and has attached our
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   243
description along with it. To see the status of the files in the repository,
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   244
use the ``hg status`` command. 
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   245
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   246
::
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   247
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   248
    $ hg st
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   249
    
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   250
The command does not return anything, when there are no uncommitted changes.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   251
Also, notice that I have started getting lazy and used only a short name
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   252
``st`` for the status command. Mercurial accepts short names, as long as they
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   253
can be disambiguated (just like tab completion).
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   254
136
68508b5175db vcs: Minor changes to handout
Puneeth Chaganti <punchagan@fossee.in>
parents: 135
diff changeset
   255
Snapshot's Thumbnail views
68508b5175db vcs: Minor changes to handout
Puneeth Chaganti <punchagan@fossee.in>
parents: 135
diff changeset
   256
--------------------------
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   257
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   258
To see the history of the changes to our repository, we use ``hg log``. We
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   259
can view the change that we just made to our repository.
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   260
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   261
::
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   262
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   263
    $ hg log
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   264
    changeset:   0:cbf6e2a375b4
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   265
    tag:         tip
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   266
    user:        punchagan@shrike.aero.iitb.ac.in
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   267
    date:        Fri Jan 28 14:04:07 2011 +0530
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   268
    summary:     Initial Commit
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   269
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   270
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   271
As we already discussed, mercurial keeps track of the changes that are made
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   272
to the files in the repository. Notice, that our ``log`` is showing a
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   273
**changeset**. A change set is nothing but a set of changes made to the
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   274
repository between two consecutive commits (the action of taking snapshots).
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   275
Notice that ``hg`` also shows the date at which the commit was made and the
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   276
description of the changeset.
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   277
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   278
User information
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   279
----------------
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   280
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   281
But there is a slight problem with the user details that mercurial is saving.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   282
It saves my username with my machine name. It is a general good practice to
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   283
use your full name with your email id. We set our username in the ``.hgrc``
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   284
file in our Home folder. (``$HOME/.hgrc`` on Unix like systems and
136
68508b5175db vcs: Minor changes to handout
Puneeth Chaganti <punchagan@fossee.in>
parents: 135
diff changeset
   285
``%HOME%\.hgrc`` on Windows systems) This is a global setting for all the
68508b5175db vcs: Minor changes to handout
Puneeth Chaganti <punchagan@fossee.in>
parents: 135
diff changeset
   286
projects that we are working on. We could also set the details, at a
68508b5175db vcs: Minor changes to handout
Puneeth Chaganti <punchagan@fossee.in>
parents: 135
diff changeset
   287
repository level. We shall look at this in due course. 
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   288
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   289
We open the file in our favorite editor and add the username details. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   290
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   291
::
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   292
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   293
    $ emacs ~/.hgrc  
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   294
    [ui]
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   295
    username = Puneeth Chaganti <punchagan@fossee.in>
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   296
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   297
We have now set the username details for mercurial to use, in all our future
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   298
commits. (Note: You can also set user preferences at the repository level.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   299
Exercise-N asks you to do that)
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   300
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   301
Let us now make another commit to see if this has taken effect. Let us
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   302
add author information to all the chapters that we have. 
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   303
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   304
::
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   305
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   306
    Author: Puneeth Chaganti <punchagan@fossee.in>
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   307
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   308
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   309
Once we have added this to all the files, let us commit this change. We again
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   310
used the ``hg commit`` command to commit the changes that we have made.
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   311
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   312
::
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   313
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   314
    $ hg commit
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   315
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   316
We are again prompted with the editor window to enter our commit message and
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   317
we type out our commit message. There are some good practices when typing out
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   318
a commit message too. It is a general practice to have a summary line in the
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   319
commit message which is no longer than 60 to 65 characters giving a summary
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   320
of the change we have made. This is followed up with an explanation of why
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   321
this was changed, what is the effect of this change, known bugs/issues
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   322
remaining, if any, etc.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   323
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   324
::
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   325
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   326
    Add author info to all the chapters
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   327
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   328
    All the chapters must have an author info. Added Puneeth Chaganti
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   329
    as the author. New authors can be added in newlines.              
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   330
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   331
    HG: Enter commit message.  Lines beginning with 'HG:' are removed.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   332
    HG: Leave message empty to abort commit.
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   333
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   334
``hg log`` should now show us both the changes that we have made. Notice that
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   335
the username settings are being used and also, the summary of the changeset
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   336
shows only the first line in the description that we have added. Also, notice
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   337
that ``hg`` shows the commits in the reverse chronological order, which is
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   338
useful.
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   339
136
68508b5175db vcs: Minor changes to handout
Puneeth Chaganti <punchagan@fossee.in>
parents: 135
diff changeset
   340
But why commit?
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   341
===============
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   342
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   343
You must already be wondering, why we need all the overhead of
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   344
``commit`` and ``log``, etc. What is all this fuss about? "Isn't it
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   345
just a waste of time?"
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   346
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   347
Reverting Changes
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   348
-----------------
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   349
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   350
While you were wondering, let's say your friend walks in and together you
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   351
make a lot of changes.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   352
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   353
1. You replace all the occurrences of ``&`` in ``chapter1.txt`` with
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   354
``and``. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   355
2. You delete the ``chapter3.txt`` file. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   356
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   357
::
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   358
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   359
    $ rm chapter3.txt
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   360
    $ hg st
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   361
    M chapter1.txt
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   362
    ! chapter3.txt
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   363
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   364
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   365
But after a while, you realize that these changes are unwarranted. You
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   366
want to go back to the previous state, undoing all the changes that
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   367
you made, after your friend arrived. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   368
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   369
The undo in your editor may allow undoing the first change (if you
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   370
haven't closed it after making the changes) but there's no way you
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   371
could get back your ``chapter3.txt`` file, using your editor. But
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   372
don't worry. Mercurial to the rescue!
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   373
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   374
We shall use the ``revert`` command of ``hg`` to undo all the changes
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   375
after the last commit. As we want to undo all the changes, we use the
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   376
``revert`` command with the ``--all`` argument. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   377
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   378
::
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   379
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   380
    $ hg revert --all
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   381
    reverting chapter1.txt
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   382
    reverting chapter3.txt
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   383
    $ hg st
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   384
    ? chapter1.txt.orig
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   385
    $ ls
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   386
    chapter1.txt  chapter1.txt.orig  chapter2.txt  chapter3.txt
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   387
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   388
As you can see the ``chapter3.txt`` file has been restored. But ``hg``
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   389
gives you a new file ``chapter1.txt.orig``. Mercurial actually doesn't
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   390
like to delete any of the changes that you have made. So, it makes a
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   391
back-up of the file ``chapter1.txt`` in the present state and gives
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   392
you back the old file. 
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   393
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   394
If we now decide, that we want to ``redo`` the changes that we had
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   395
done to the ``chapter1``, we can just overwrite the ``chapter1.txt``
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   396
file with the backed up file. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   397
::
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   398
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   399
    $ mv chapter1.txt.orig chapter1.txt
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   400
    $ hg st
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   401
    M chapter1.txt
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
   402
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   403
Viewing Changes
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   404
---------------
17
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   405
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   406
Let's say we now want to ``commit`` these changes, but we are not sure
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   407
of all the changes that we have made to the file, since it's been a
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   408
while after we made the changes. We could use the ``diff`` command to
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   409
see all the changes that have been made in the file. 
17
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   410
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   411
::
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   412
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   413
    $ hg diff
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   414
    diff -r 3163b8db10bb chapter1.txt
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   415
    --- a/chapter1.txt	Fri Jan 28 16:21:29 2011 +0530
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   416
    +++ b/chapter1.txt	Fri Jan 28 16:22:41 2011 +0530
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   417
    @@ -8,9 +8,9 @@
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   418
       1 Session
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   419
     Table of Contents
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   420
     =================
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   421
    -1 Introduction & Motivation 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   422
    -2 Creating & Getting repositories 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   423
    +1 Introduction and Motivation 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   424
    +2 Creating and Getting repositories 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   425
     3 Revision history 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   426
    -4 Making & sharing changes 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   427
    -5 Merges & Conflicts 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   428
    +4 Making and sharing changes 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   429
    +5 Merges and Conflicts 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   430
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   431
You see some cryptic output, but it's essentially giving you the list
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   432
of changes made to the file. All the lines that were deleted are
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   433
preceded by a ``-`` and all the new-lines are preceded by a ``+``. You
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   434
can see that the ``&`` occurrences have been replaces with ``and``. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   435
139
d309b09761b9 vcs: Add note about binary files in handout
Puneeth Chaganti <punchagan@fossee.in>
parents: 136
diff changeset
   436
We should note here that, the ``diff`` wouldn't make much sense, if we had
d309b09761b9 vcs: Add note about binary files in handout
Puneeth Chaganti <punchagan@fossee.in>
parents: 136
diff changeset
   437
some binary files like ``.jpg`` or ``.pdf`` files. We would see some
d309b09761b9 vcs: Add note about binary files in handout
Puneeth Chaganti <punchagan@fossee.in>
parents: 136
diff changeset
   438
gibberish in the output. 
d309b09761b9 vcs: Add note about binary files in handout
Puneeth Chaganti <punchagan@fossee.in>
parents: 136
diff changeset
   439
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   440
Let us now commit this change. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   441
::
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   442
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   443
    $ hg commit
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   444
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   445
    Replace all occurrences of & with and
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   446
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   447
    On the suggestion of Madhusudan C S. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   448
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   449
    HG: Enter commit message.  Lines beginning with 'HG:' are removed.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   450
    HG: Leave message empty to abort commit.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   451
    
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   452
::
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   453
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   454
    $ hg log    
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   455
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   456
We can see the history of all the commits that we have made in our
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   457
project. As you can see, the logs have started getting longer (and
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   458
hence have been dropped from the output) and may even be getting out
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   459
of our screens. Also, we are not very interested in all the commits in
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   460
the project. We usually want to see the last few commits. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   461
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   462
Revision Numbering
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   463
------------------
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   464
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   465
Let us now see how to get logs of specific commits and a range of
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   466
commits. Have a look at the logs that the previous ``log`` command has
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   467
printed and look at the ``changeset`` line. It shows a number followed
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   468
by a semi-colon and some long hexa-decimal string. The number is
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   469
called the **revision number**. It is an identifier for the commit,
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   470
and can be along with various commands to specify the revision number,
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   471
if required. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   472
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   473
Let us now check the logs of the very first commit of the project.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   474
::
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   475
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   476
    $ hg log -r0
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   477
    changeset:   0:cbf6e2a375b4
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   478
    tag:         tip
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   479
    user:        punchagan@shrike.aero.iitb.ac.in
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   480
    date:        Fri Jan 28 14:04:07 2011 +0530
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   481
    summary:     Initial Commit
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   482
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   483
Now, if we wish to get the logs of the latest commit only, how do we
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   484
do it? We could specify the exact revision number of the commit (2) or
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   485
just use -1 to start counting in the reverse chronological order. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   486
::
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   487
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   488
    $ hg log -r-1
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   489
    changeset:   2:98f7f4a1bb4d
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   490
    tag:         tip
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   491
    user:        Puneeth Chaganti <punchagan@fossee.in>
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   492
    date:        Fri Jan 28 16:24:42 2011 +0530
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   493
    summary:     Replace all occurrences of & with and
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   494
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   495
You could also specify a range of commits whose logs you would like to
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   496
see. Say, we would like to see the last two commits, 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   497
::
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   498
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   499
    $ hg log -r-1:-2
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   500
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   501
This is equivalent to using the following     
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   502
::
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   503
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   504
        $ hg log -r2:1
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   505
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   506
You could also see the changes made to a particular file, in the
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   507
specified range of the commits. Say, we wish to see the changes made
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   508
to the ``chapter2.txt`` file in the last two commits. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   509
::
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   510
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   511
    $ hg log -r-1:-2 chapter2.txt
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   512
    changeset:   1:3163b8db10bb
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   513
    user:        Puneeth Chaganti <punchagan@fossee.in>
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   514
    date:        Fri Jan 28 16:21:29 2011 +0530
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   515
    summary:     Add author info to all the chapters
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   516
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   517
Notice that it shows only the logs of revision 1, since no changes
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   518
were made to the specified file in the second commit. 
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   519
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   520
You can do all of this with the ``diff`` command to see the exact
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   521
changes made to the files, instead of seeing the ``log`` message. This
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   522
will be a part of your exercises. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   523
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   524
Collaborating with Mercurial
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   525
============================
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   526
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   527
When motivating the use of version control systems, we spoke a lot about
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   528
collaboration and sharing our changes with our peers. Let us now see how we
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   529
can share our project with our peers and collaborate with them. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   530
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   531
Cloning Repositories
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   532
--------------------
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   533
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   534
For this purpose let us create a central repository, a copy of our
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   535
repository, which is different from the one in which we are working. The
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   536
``clone`` command is used to **clone** or replicate an existing repository.
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   537
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   538
::
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   539
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   540
    $ hg clone book book-repo
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   541
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   542
This creates a copy of our repository, ``book``, with the name ``book-repo``.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   543
The syntax of the ``clone`` command is -- ``hg clone SOURCE [DEST]``, where
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   544
the optional argument DEST is being represented in brackets. Here we are
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   545
giving book-repo as the destination. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   546
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   547
The clone command can be used to replicate already existing repositories,
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   548
either on your own machine or on some remote machine somewhere on the
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   549
network. Since, ``hg`` maintains a copy of the full repository with every
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   550
copy of the repository, the two copies that we have are exactly equivalent.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   551
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   552
``book-repo`` is the repository we shall be using as a central repository
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   553
and share it with our peers. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   554
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   555
Sharing Repositories
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   556
--------------------
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   557
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   558
A mercurial repository can be shared in multiple ways. We shall use the
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   559
``http`` protocol to share the repository. Mercurial comes inbuilt with a
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   560
tiny server that can be used to share your repository over the network. To
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   561
start sharing the repository, we say 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   562
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   563
::
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   564
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   565
    $ cd ../book-repo
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   566
    $ hg serve 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   567
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   568
This will start serving the repository on the network on the port 8000.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   569
Anybody in your network can access the repository in their browsers. Let us
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   570
see how it looks, in our own browser. We open the url `http://localhost:8000`
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   571
in our browser.     
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   572
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   573
Let's say, our friend Madhu, now wants  to clone this repository. He will use
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   574
our ip-address and the port on which  we are serving the repository, to clone
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   575
the repository. Instead of using two machines, for the purposes of
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   576
demonstration, we shall clone into our own machine, with a different name. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   577
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   578
::
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   579
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   580
    $ hg clone http://192.168.1.101:8000 book-madhu
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   581
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   582
This will clone the repository to the folder, ``book-madhu``. The log of the
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   583
repository will, obviously, be the same as our original repository. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   584
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   585
::
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   586
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   587
    $ hg log
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   588
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   589
Sharing Changes
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   590
---------------
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   591
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   592
Let's say, Madhu now makes some changes to the repository. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   593
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   594
1. He adds his name to the Authors list. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   595
2. He moves down the Getting repositories part into a different section.  
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   596
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   597
::
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   598
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   599
    $ hg diff
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   600
    diff -r 98f7f4a1bb4d chapter1.txt
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   601
    --- a/chapter1.txt	Fri Jan 28 16:24:42 2011 +0530
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   602
    +++ b/chapter1.txt	Fri Jan 28 23:03:37 2011 +0530
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   603
    @@ -2,6 +2,7 @@
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   604
                            =======================
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   605
     
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   606
     Author: Puneeth Chaganti <punchagan@fossee.in>
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   607
    +        Madhusudan CS <madhusudancs@fossee.in>
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   608
     Date: 2011-01-28 13:58:47 IST
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   609
     
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   610
     
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   611
    @@ -9,8 +10,9 @@
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   612
     Table of Contents
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   613
     =================
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   614
     1 Introduction and Motivation 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   615
    -2 Creating and Getting repositories 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   616
    +2 Creating 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   617
     3 Revision history 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   618
     4 Making and sharing changes 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   619
    -5 Merges and Conflicts 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   620
    +5 Getting repositories 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   621
    +6 Merges and Conflicts  
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   622
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   623
He then commits these changes and **pushes** them to the central repository
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   624
that we have created. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   625
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   626
::
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   627
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   628
    $ hg commit
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   629
    $ hg push
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   630
    pushing to http://192.168.1.101:8000 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   631
    searching for changes
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   632
    ssl required
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   633
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   634
The push failed, obviously, since we have not taken care of access rights
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   635
etc. It doesn't make much sense to allow anybody to make changes to a public
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   636
repository, by default. We will need to make changes to the settings of the
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   637
repository to allow this. **Note**: This is obviously not a safe way to share
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   638
your repository, but for our purposes, this is sufficient.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   639
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   640
We add the following lines to the ``.hg/hgrc`` of the ``book-repo``
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   641
repository. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   642
::
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   643
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   644
    [web]
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   645
    push_ssl=False
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   646
    allow_push=*
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   647
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   648
This will allow anybody to push to the repository, now. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   649
136
68508b5175db vcs: Minor changes to handout
Puneeth Chaganti <punchagan@fossee.in>
parents: 135
diff changeset
   650
By the way, this ``hgrc`` is a repository level configuration file. We could
68508b5175db vcs: Minor changes to handout
Puneeth Chaganti <punchagan@fossee.in>
parents: 135
diff changeset
   651
also set the details of the user information in this file. 
68508b5175db vcs: Minor changes to handout
Puneeth Chaganti <punchagan@fossee.in>
parents: 135
diff changeset
   652
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   653
Madhusudan can now push and his changes will appear in the central
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   654
repository. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   655
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   656
::
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   657
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   658
    $ hg push
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   659
    
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   660
Let's confirm it in the web interface that we started with the ``hg serve``
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   661
command. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   662
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   663
Pulling Changes
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   664
---------------
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   665
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   666
Let us now **pull** these changes into our original repository ``book`` that
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   667
we have been working with. Before pulling the changes, we can use the command
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   668
``hg incoming`` to see the changes that have been made to the repository
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   669
after our last **pull** and the changesets that will be coming into our
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   670
repository after we do a **pull**. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   671
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   672
::
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   673
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   674
    $ hg incoming
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   675
    abort: repository default not found!
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   676
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   677
What is going on here? This is because, we didn't clone our repository
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   678
``book`` from the central repository ``book-repo``. We can now add the
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   679
location of the central repository to the ``hgrc`` file, of this project. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   680
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   681
::
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   682
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   683
    [paths]
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   684
    default = /home/punchagan/book-repo
17
e6240ecd7ae6 Basic file management in Repo.
Shantanu <shantanu@fossee.in>
parents: 16
diff changeset
   685
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   686
Now, we can check the incoming changes. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   687
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   688
::
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   689
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   690
    $ hg incoming
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   691
    searching for changes
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   692
    changeset:   3:3cd54926dbea
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   693
    tag:         tip
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   694
    user:        Madhusudan CS <madhusudancs@fossee.in>
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   695
    date:        Fri Jan 28 23:08:25 2011 +0530
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   696
    summary:     Add my name to authors and move getting repositories section
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   697
    to 5
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   698
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   699
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   700
To now **pull** these changes, we use the ``pull`` command. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   701
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   702
::
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   703
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   704
    $ hg pull 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   705
    pulling from /home/punchagan/book-repo
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   706
    searching for changes
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   707
    adding changesets
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   708
    adding manifests
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   709
    adding file changes
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   710
    added 1 changesets with 1 changes to 1 files
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   711
    (run 'hg update' to get a working copy)
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   712
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   713
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   714
*Note* that ``hg`` is giving us a message, asking us to run a ``hg update``
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   715
 to get a working copy. Let us try to understand what this is. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   716
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   717
As already explained, ``.hg`` folder has all the information about the
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   718
changesets of the repository. When we do a ``pull`` the changesets from the
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   719
remote repository are pulled to our repository, but our working directory is
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   720
not affected by these changes. To see this, we could use the ``hg parent``
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   721
command. 
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   722
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   723
::
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   724
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   725
    $ hg parent
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   726
    changeset:   2:98f7f4a1bb4d
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   727
    user:        Puneeth Chaganti <punchagan@fossee.in>
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   728
    date:        Fri Jan 28 16:24:42 2011 +0530
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   729
    summary:     Replace all occurrences of & with and
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   730
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   731
As we can see, the parent is still our last commit, and the changes made by
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   732
Madhusudan are still not in our working directory. To get these changes we do
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   733
the update as suggested by ``hg``. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   734
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   735
::
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   736
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   737
    $ hg up
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   738
    1 files updated, 0 files merged, 0 files removed, 0 files unresolved
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   739
    $ hg parent
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   740
    changeset:   3:3cd54926dbea
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   741
    tag:         tip
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   742
    user:        Madhusudan CS <madhusudancs@fossee.in>
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   743
    date:        Fri Jan 28 23:08:25 2011 +0530
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   744
    summary:     Add my name to authors and move getting repositories section
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   745
    to 5 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   746
    
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   747
As expected the **update** command updates the parent to the latest changes
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   748
that we just pulled from the remote repository. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   749
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   750
The update command can also be used to go back into an older revision, by
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   751
specifying the revision to which we want to go to. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   752
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   753
::
26
977009f5a22a Completed rough HandOut.
Shantanu <shantanu@fossee.in>
parents: 17
diff changeset
   754
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   755
    $ hg up -r1
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   756
    1 files updated, 0 files merged, 0 files removed, 0 files unresolved
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   757
    $ hg parent
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   758
    changeset:   1:3163b8db10bb
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   759
    user:        Puneeth Chaganti <punchagan@fossee.in>
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   760
    date:        Fri Jan 28 16:21:29 2011 +0530
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   761
    summary:     Add author info to all the chapters
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   762
    $ hg cat chapter1.txt
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   763
    # Displays the contents of the chapter1.txt file as in revision 1. 
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   764
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   765
To return to the latest revision we just use the ``up`` or ``update`` command
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   766
without specifying any revision number. 
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   767
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   768
::
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   769
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   770
    $ hg up
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   771
    1 files updated, 0 files merged, 0 files removed, 0 files unresolved
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   772
    $ hg parent
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   773
    changeset:   3:3cd54926dbea
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   774
    tag:         tip
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   775
    user:        Madhusudan CS <madhusudancs@fossee.in>
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   776
    date:        Fri Jan 28 23:08:25 2011 +0530
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   777
    summary:     Add my name to authors and move getting repositories section
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   778
    to 5 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   779
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   780
Simultaneous Changes
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   781
--------------------
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   782
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   783
Ok, we have been talking about collaboration, but this is a nice situation,
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   784
where I was not changing anything while Madhusudan was changing the file,
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   785
incidentally.  
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   786
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   787
Now, let's say, both of us are editing the file at the same time, but
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   788
different parts of it.  Say, I change the title of the section 2. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   789
::
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   790
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   791
    $ hg diff
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   792
    diff -r 3cd54926dbea chapter1.txt
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   793
    --- a/chapter1.txt	Fri Jan 28 23:08:25 2011 +0530
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   794
    +++ b/chapter1.txt	Fri Jan 28 23:45:19 2011 +0530
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   795
    @@ -10,7 +10,7 @@
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   796
     Table of Contents
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   797
     =================
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   798
     1 Introduction and Motivation 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   799
    -2 Creating 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   800
    +2 Creating repositories
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   801
     3 Revision history 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   802
     4 Making and sharing changes 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   803
     5 Getting repositories 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   804
    $ hg commit 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   805
    $ hg push
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   806
    pushing to /home/punchagan/book-repo
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   807
    searching for changes
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   808
    adding changesets
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   809
    adding manifests
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   810
    adding file changes
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   811
    added 1 changesets with 1 changes to 1 files
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   812
    
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   813
Also, let us assume Madhusudan adds an additional section called References. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   814
::
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   815
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   816
    $ hg diff
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   817
    diff -r 3cd54926dbea chapter1.txt
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   818
    --- a/chapter1.txt	Fri Jan 28 23:08:25 2011 +0530
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   819
    +++ b/chapter1.txt	Fri Jan 28 23:47:05 2011 +0530
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   820
    @@ -15,4 +15,4 @@
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   821
     4 Making and sharing changes 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   822
     5 Getting repositories 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   823
     6 Merges and Conflicts 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   824
    -
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   825
    +7 References
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   826
    $ hg commit
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   827
    $ hg log
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   828
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   829
Let us now compare the logs of the two repositories. You can see that both
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   830
the repositories have their topmost revision numbered as 4, but they are both
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   831
different. The identification number given to each revision is a local
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   832
identification. The hexadecimal string following that number is the actual
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   833
unique identification of that changeset, which will be unique across
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   834
repositories.
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   835
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   836
What happens now, when Madhusudan tries to push his changes to the central
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   837
repository? 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   838
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   839
::
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   840
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   841
    $ hg push
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   842
    pushing to http://192.168.1.101:8000 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   843
    searching for changes
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   844
    abort: push creates new remote heads!
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   845
    (did you forget to merge? use push -f to force)
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   846
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   847
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   848
The push failed! This is because, both of us have made changes, and they need
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   849
to be merged somehow. **Don't**, just for this one instance, take the advice
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   850
given by ``mercurial``. Using the ``-f`` would be disastrous. We will leave
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   851
out a discussion of that, for this course. 
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   852
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   853
Madhusudan now needs to pull the new changes that have been pushed to the
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   854
repository after his last pull and **merge** them with his changes. 
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   855
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   856
::
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   857
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   858
    $ hg pull 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   859
    pulling from http://192.168.1.101:8000 
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   860
    searching for changes
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   861
    adding changesets
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   862
    adding manifests
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   863
    adding file changes
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   864
    added 1 changesets with 1 changes to 1 files (+1 heads)
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   865
    (run 'hg heads' to see heads, 'hg merge' to merge)
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   866
    $ hg merge
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   867
    merging chapter1.txt
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   868
    0 files updated, 1 files merged, 0 files removed, 0 files unresolved
149
4499aebbee83 vcs: Fix pygments highlighting of code blocks with $ and '
Puneeth Chaganti <punchagan@fossee.in>
parents: 148
diff changeset
   869
    (branch merge, dont forget to commit)
4499aebbee83 vcs: Fix pygments highlighting of code blocks with $ and '
Puneeth Chaganti <punchagan@fossee.in>
parents: 148
diff changeset
   870
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   871
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   872
We have now pull the changes from the central repository and merged them with
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   873
the changes in our repository. But, ``hg`` is warning us not to forget to
149
4499aebbee83 vcs: Fix pygments highlighting of code blocks with $ and '
Puneeth Chaganti <punchagan@fossee.in>
parents: 148
diff changeset
   874
commit. Let's see what is the status of the repository at this point in time.
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
   875
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   876
::
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   877
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   878
    $ hg st
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   879
    M chapter1.txt
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   880
    $ hg diff
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   881
    diff -r bd57162c31f6 chapter1.txt
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   882
    --- a/chapter1.txt	Fri Jan 28 23:51:52 2011 +0530
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   883
    +++ b/chapter1.txt	Sat Jan 29 00:00:39 2011 +0530
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   884
    @@ -10,7 +10,7 @@
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   885
     Table of Contents
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   886
     =================
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   887
     1 Introduction and Motivation 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   888
    -2 Creating 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   889
    +2 Creating repositories
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   890
     3 Revision history 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   891
     4 Making and sharing changes 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   892
     5 Getting repositories 
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   893
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   894
As you can see, the changes pushed by us, changing the name of the section 2,
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   895
have now been made in the repository of Madhusudan. We will now need to
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   896
commit these changes. 
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   897
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   898
::
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   899
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   900
    $ hg commit
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   901
    
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   902
We shall be using a commit message that makes it clear that we are merging.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   903
We can now push this changes to the central repository. We could also check
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   904
the changes that will be pushed, before pushing them, using the ``hg
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   905
outgoing`` command. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   906
::
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   907
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   908
    $ hg outgoing
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   909
    tag:         tip
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   910
    parent:      5:bd57162c31f6
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   911
    parent:      4:5c88c36f60de
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   912
    user:        Madhusudan CS <madhusudancs@fossee.in>
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   913
    date:        Sat Jan 29 00:02:53 2011 +0530
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   914
    summary:     Merge heads.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   915
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   916
    changeset:   5:bd57162c31f6
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   917
    parent:      3:3cd54926dbea
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   918
    user:        Madhusudan CS <madhusudancs@fossee.in>
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   919
    date:        Fri Jan 28 23:51:52 2011 +0530
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   920
    summary:     Add additional References section
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   921
    $ hg push
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   922
    pushing to http://192.168.1.101:8000 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   923
    searching for changes
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   924
    adding changesets
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   925
    adding manifests
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   926
    adding file changes
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   927
    added 2 changesets with 2 changes to 1 files
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   928
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   929
The changes have now been successfully pushed! Let us look at the web
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   930
interface of the repo, to see that the changes have actually taken place. Let
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   931
us also have a look at the graph to, try and understand what has happened. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   932
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   933
As we can see, a branch was created, when both of us started editing the file
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   934
simultaneously, and was then merged by Madhusudan CS. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   935
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   936
Simultaneous Conflicting Changes
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   937
--------------------------------
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   938
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   939
We were lucky this time, in that we were editing separate parts of the file.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   940
What will happen if we edited the same portion of the file, at the same time?
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   941
How would merges work? This will be the last thing that we are going to see
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   942
in this part of the course. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   943
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   944
Let's say both of us edit the title of the section 6. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   945
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   946
Let's say, I make the following changes, commit them and push them. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   947
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   948
::
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
   949
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   950
    $ hg diff
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   951
    diff -r ce3469a9446f chapter1.txt
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   952
    --- a/chapter1.txt	Sat Jan 29 00:02:53 2011 +0530
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   953
    +++ b/chapter1.txt	Sat Jan 29 10:30:21 2011 +0530
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   954
    @@ -14,5 +14,5 @@
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   955
     3 Revision history 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   956
     4 Making and sharing changes 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   957
     5 Getting repositories 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   958
    -6 Merges and Conflicts 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   959
    +6 Merging and resolving conflicts 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   960
     7 References
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   961
    $ hg commit
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   962
    $ hg push
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   963
    ...
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   964
    added 1 changesets with 1 changes to 1 files
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   965
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   966
Meanwhile, let's say Madhusudan was changing the same section title, as
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   967
follows.      
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   968
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   969
::
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   970
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   971
    $ hg diff
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   972
    diff -r ce3469a9446f chapter1.txt
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   973
    --- a/chapter1.txt	Sat Jan 29 00:02:53 2011 +0530
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   974
    +++ b/chapter1.txt	Sat Jan 29 10:35:29 2011 +0530
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   975
    @@ -14,5 +14,5 @@
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   976
     3 Revision history 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   977
     4 Making and sharing changes 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   978
     5 Getting repositories 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   979
    -6 Merges and Conflicts 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   980
    +6 Simple Merges and Merges with Conflicts 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   981
     7 References
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   982
    $ hg commit
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   983
    $ hg push
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   984
    pushing to http://192.168.1.101:8000 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   985
    searching for changes
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   986
    abort: push creates new remote heads!
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   987
    (did you forget to merge? use push -f to force)
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   988
    $ hg pull 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   989
    ...
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   990
    added 1 changesets with 1 changes to 1 files (+1 heads)
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   991
    (run 'hg heads' to see heads, 'hg merge' to merge)
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   992
    $ hg merge
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   993
    0 files updated, 1 files merged, 0 files removed, 0 files unresolved
149
4499aebbee83 vcs: Fix pygments highlighting of code blocks with $ and '
Puneeth Chaganti <punchagan@fossee.in>
parents: 148
diff changeset
   994
    (branch merge, dont forget to commit)
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   995
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   996
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   997
What happens now actually depends on how Mercurial is configured and the
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   998
programs available in your machine. You will either get a diff view with 3
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
   999
panes or ``merge`` will insert markers in your file at the points where the
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1000
conflicts occur.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1001
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1002
If you get a 3 pane view, the first pane is the actual file, where you make
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1003
changes, to resolve the conflicts. The second pane shows the changes that you
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1004
made, to the file. The last pane shows the changes that you pulled from the
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1005
original repo. Once you are satisfied with the changes, save and quit. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1006
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1007
If you have a very minimal system, you might end up getting a file with
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1008
change markers, the original file being backed up. Open the file and resolve
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1009
the conflicts, deleting the markers. Once you are done, you need to tell
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1010
mercurial that you have resolved the conflicts manually. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1011
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1012
::
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1013
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1014
    $ hg resolve -m chapter1.txt
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1015
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1016
Whatever be the process you have used for the merge, you will now need to
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1017
commit your changes, just like the simple merge that we performed. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1018
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1019
::
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1020
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1021
    $ hg commit -m "Merge heads."
37
4cddf3a13843 Added merging section, and typo correction.
Shantanu <shantanu@fossee.in>
parents: 26
diff changeset
  1022
    $ hg push
16
7a8f9fa7accd Completed Getting Started with Repository.
Shantanu <shantanu@fossee.in>
parents: 15
diff changeset
  1023
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1024
*Note*, we have used a different way to commit. We have used the ``-m``
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1025
argument with the commit message.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1026
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1027
We could look at the graph of the changes, in our web interface, being served
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1028
by the ``hg serve`` command. From the graph it is clear, how the merging has
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1029
occurred. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1030
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1031
That brings us to the end of this tutorial on Mercurial. What we have covered
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1032
is nothing close to all the features of Mercurial. We've only scratched the
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1033
surface, but let's hope that this will get you started and you will be able
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1034
to organize your work and projects, better. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1035
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1036
Additional Reading
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1037
==================
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1038
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1039
I strongly suggest you to go through the following topics, if and when you
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1040
start using Mercurial on a day-to-day basis. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1041
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1042
1. ``.hgignore`` 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1043
#. ``hg rollback`` 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1044
#. ``hg bisect`` 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1045
#. ``hg backout`` 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1046
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1047
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1048
References
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
  1049
==========
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
  1050
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1051
    - `A Visual Guide to Version Control <http://betterexplained.com/articles/a-visual-guide-to-version-control/>`_
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1052
    - `Version Control for the Masses <http://karlagius.com/2009/01/09/version-control-for-the-masses/>`_
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1053
    - `(Illustrated) Intro to Distributed Version Control <http://betterexplained.com/articles/intro-to-distributed-version-control-illustrated/>`_
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1054
    - `Understanding Mercurial <http://mercurial.selenic.com/wiki/UnderstandingMercurial>`_
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1055
    - `A Tutorial on Using Mercurial <http://mercurial.selenic.com/wiki/Tutorial>`_
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1056
    - `Hg Init: a Mercurial tutorial <http://hginit.com/>`_
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1057
    - `Beginners Guides <http://mercurial.selenic.com/wiki/BeginnersGuides>`_
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1058
    - `Software Carpentry <http://software-carpentry.org/4_0/vc/>`_
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1059
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1060
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1061
Appendix A - Definitions
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1062
========================
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1063
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1064
Definitions of a few commonly used terms. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1065
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1066
Add
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1067
    Begin tracking a file (or a set of files) with Version Control. 
96
bb52cf47e920 Text content for vcs.
Shantanu <shantanu@fossee.in>
parents: 60
diff changeset
  1068
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1069
Branch
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1070
    A diverged line of development. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1071
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1072
Changeset
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1073
    An atomic collection of changes to the files in a repository. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1074
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1075
Clone 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1076
    Creating a copy of an existing repository; New repo is self-contained. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1077
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1078
Commit
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1079
    Taking a snapshot of the changes made in the repository (after the
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1080
    previous snapshot) 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1081
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1082
Conflict 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1083
    Occurs when two changesets have overlapping sections that have been
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1084
    modified.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1085
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1086
Head
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1087
    A changeset with no child changesets. 
8
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
  1088
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1089
History
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1090
    Cumulative of all the changesets of a repository. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1091
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1092
Merge 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1093
    Combining two separate changesets into one merge changeset. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1094
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1095
Repository (repo) 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1096
    - Loosely speaking, the folder with all the files and a store
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1097
      of the change history.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1098
    - Strictly speaking, only the ``.hg`` directory that contains the change
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1099
      history. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1100
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1101
Revert
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1102
    Going back to previous committed state of working directory or a file.
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1103
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1104
Revision
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1105
    A particular changeset. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1106
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1107
Server
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1108
    A machine which serves the repository. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1109
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1110
Tip 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1111
    Most recently changed head in a repository. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1112
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1113
Update
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1114
    Updating the working directory to a particular revision or to the tip
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1115
    revision. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1116
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1117
Working Directory
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1118
    The directory where all of the files and directories of the project are
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1119
    present. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1120
150
8526f94072f6 vcs: Add include directive for exercises in handOut.
Puneeth Chaganti <punchagan@fossee.in>
parents: 149
diff changeset
  1121
.. include :: exercises.rst
8526f94072f6 vcs: Add include directive for exercises in handOut.
Puneeth Chaganti <punchagan@fossee.in>
parents: 149
diff changeset
  1122
135
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1123
.. 
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1124
   Local Variables:
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1125
   mode: rst
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1126
   indent-tabs-mode: nil
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1127
   sentence-end-double-space: nil
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1128
   fill-column: 77
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1129
   End:
339230606dc0 vcs: Changes to handout.rst
Puneeth Chaganti <punchagan@fossee.in>
parents: 96
diff changeset
  1130