versionControl/handOut.rst
changeset 136 68508b5175db
parent 135 339230606dc0
child 139 d309b09761b9
equal deleted inserted replaced
135:339230606dc0 136:68508b5175db
    24 more organized and systematic. You surely would've saved your files, some
    24 more organized and systematic. You surely would've saved your files, some
    25 time or the other as ``oldproject.py``, ``latestproject.py`` and so on, or
    25 time or the other as ``oldproject.py``, ``latestproject.py`` and so on, or
    26 date-tagging them as ``project-21-01-10.py``, ``project-20-02-10.py`` and so
    26 date-tagging them as ``project-21-01-10.py``, ``project-20-02-10.py`` and so
    27 on. 
    27 on. 
    28 
    28 
       
    29 It is, in some ways, similar to playing a video game. We generally play games
       
    30 in stages, saving the game, each time we finish a stage or complete a task.
       
    31 We continue playing, but we could, if necessary, choose to go back to one of
       
    32 the saved states and start over. In this manner we could change the state of
       
    33 the game. 
       
    34 
    29 Why Use Version Control
    35 Why Use Version Control
    30 =======================
    36 =======================
    31  
    37  
    32 We have seen that one of the main motivation to use a version system control
    38 We have seen that one of the main motivation to use a version system control
    33 system is the ability to go back to a working version of the file, when
    39 system is the ability to go back to a working version of the file, when
    93 
    99 
    94 Just say ``hg`` in your shell, to see some of the commands that ``hg``
   100 Just say ``hg`` in your shell, to see some of the commands that ``hg``
    95 provides and say ``hg version`` to see the version of ``hg`` that has
   101 provides and say ``hg version`` to see the version of ``hg`` that has
    96 been installed on your system. 
   102 been installed on your system. 
    97 
   103 
    98 Let there be Repository
   104 Let there be a Repository
    99 =======================
   105 =========================
   100 
   106 
   101 To start using Mercurial (or ``hg``) and get the benefits of using a version
   107 To start using Mercurial (or ``hg``) and get the benefits of using a version
   102 control system, we should first have a **repository**. A repository is a
   108 control system, we should first have a **repository**. A repository is a
   103 folder with all your files and a store of all the changes that were made to
   109 folder with all your files and a store of all the changes that were made to
   104 it. To save disk space, ``hg`` doesn't save all the files, but only saves
   110 it. To save disk space, ``hg`` doesn't save all the files, but only saves
   171       R = removed
   177       R = removed
   172       C = clean
   178       C = clean
   173       ! = missing (deleted by non-hg command, but still tracked)
   179       ! = missing (deleted by non-hg command, but still tracked)
   174       ? = not tracked
   180       ? = not tracked
   175       I = ignored
   181       I = ignored
   176         = origin of the previous file listed as A (added)
   182         = origin of the previous file listed as A (added)        
   177     ...
   183     ...
   178 
   184 
   179 By looking at the codes, it is clear that our files are not *yet* being
   185 By looking at the codes, it is clear that our files are not *yet* being
   180 tracked by ``hg``. We now use the add command to ask ``hg`` to track these
   186 tracked by ``hg``. We now use the add command to ask ``hg`` to track these
   181 files.
   187 files.
   196     A chapter2.txt
   202     A chapter2.txt
   197     A chapter3.txt
   203     A chapter3.txt
   198     $
   204     $
   199 
   205 
   200 This simply adds all the files in the (working) directory, to the repository.
   206 This simply adds all the files in the (working) directory, to the repository.
   201 As expected, the ``status`` command shows an ``A`` before he file names.
   207 As expected, the ``status`` command shows an ``A`` before he file names. We
       
   208 could also specify files individually, for example
       
   209 
       
   210 ::
       
   211     $ hg add chapter1.txt
       
   212     adding chapter1.txt
       
   213 
   202 
   214 
   203 Taking Snapshots
   215 Taking Snapshots
   204 ----------------
   216 ----------------
   205 
   217 
   206 We have added a set of new files to the repository, but we haven't told
   218 We have added a set of new files to the repository, but we haven't told
   233 The command does not return anything, when there are no uncommitted changes.
   245 The command does not return anything, when there are no uncommitted changes.
   234 Also, notice that I have started getting lazy and used only a short name
   246 Also, notice that I have started getting lazy and used only a short name
   235 ``st`` for the status command. Mercurial accepts short names, as long as they
   247 ``st`` for the status command. Mercurial accepts short names, as long as they
   236 can be disambiguated (just like tab completion).
   248 can be disambiguated (just like tab completion).
   237 
   249 
   238 Viewing the History
   250 Snapshot's Thumbnail views
   239 -------------------
   251 --------------------------
   240 
   252 
   241 To see the history of the changes to our repository, we use ``hg log``. We
   253 To see the history of the changes to our repository, we use ``hg log``. We
   242 can view the change that we just made to our repository.
   254 can view the change that we just made to our repository.
   243 
   255 
   244 ::
   256 ::
   263 
   275 
   264 But there is a slight problem with the user details that mercurial is saving.
   276 But there is a slight problem with the user details that mercurial is saving.
   265 It saves my username with my machine name. It is a general good practice to
   277 It saves my username with my machine name. It is a general good practice to
   266 use your full name with your email id. We set our username in the ``.hgrc``
   278 use your full name with your email id. We set our username in the ``.hgrc``
   267 file in our Home folder. (``$HOME/.hgrc`` on Unix like systems and
   279 file in our Home folder. (``$HOME/.hgrc`` on Unix like systems and
   268 ``%HOME%\.hgrc`` on Windows systems)
   280 ``%HOME%\.hgrc`` on Windows systems) This is a global setting for all the
       
   281 projects that we are working on. We could also set the details, at a
       
   282 repository level. We shall look at this in due course. 
   269 
   283 
   270 We open the file in our favorite editor and add the username details. 
   284 We open the file in our favorite editor and add the username details. 
   271 
   285 
   272 ::
   286 ::
   273 
   287 
   316 the username settings are being used and also, the summary of the changeset
   330 the username settings are being used and also, the summary of the changeset
   317 shows only the first line in the description that we have added. Also, notice
   331 shows only the first line in the description that we have added. Also, notice
   318 that ``hg`` shows the commits in the reverse chronological order, which is
   332 that ``hg`` shows the commits in the reverse chronological order, which is
   319 useful.
   333 useful.
   320 
   334 
   321 Mercurial Magic
   335 But why commit?
   322 ===============
   336 ===============
   323 
   337 
   324 You must already be wondering, why we need all the overhead of
   338 You must already be wondering, why we need all the overhead of
   325 ``commit`` and ``log``, etc. What is all this fuss about? "Isn't it
   339 ``commit`` and ``log``, etc. What is all this fuss about? "Isn't it
   326 just a waste of time?"
   340 just a waste of time?"
   625     push_ssl=False
   639     push_ssl=False
   626     allow_push=*
   640     allow_push=*
   627 
   641 
   628 This will allow anybody to push to the repository, now. 
   642 This will allow anybody to push to the repository, now. 
   629 
   643 
       
   644 By the way, this ``hgrc`` is a repository level configuration file. We could
       
   645 also set the details of the user information in this file. 
       
   646 
   630 Madhusudan can now push and his changes will appear in the central
   647 Madhusudan can now push and his changes will appear in the central
   631 repository. 
   648 repository. 
   632 
   649 
   633 ::
   650 ::
   634 
   651