versionControl/handOut.rst
changeset 152 ac12270f8fdf
parent 151 44838801f255
child 154 148520862e53
equal deleted inserted replaced
151:44838801f255 152:ac12270f8fdf
   225 mercurial to remember these changes, i.e., to take a snapshot at this point
   225 mercurial to remember these changes, i.e., to take a snapshot at this point
   226 in time. We do this by using the ``commit`` command.
   226 in time. We do this by using the ``commit`` command.
   227 
   227 
   228 ::
   228 ::
   229 
   229 
   230     $ hg commit 
   230     $ hg commit -u "Puneeth Chaganti <punchagan@gmail.com" -m "Initial Commit."
   231 
   231 
   232 We are now prompted with a new editor window. We type out our message here
   232 The ``-u`` parameter allows us to specify the user details. It is a general
   233 describing the changes that we have made.
   233 good practice to use full name followed by the email id. The ``-m`` parameter
   234 
   234 allows us to give the commit message --- a message describing the changes
   235 ::
   235 that are being committed.
   236 
       
   237     Initial Commit
       
   238 
       
   239     HG: Enter commit message.  Lines beginning with 'HG:' are removed.
       
   240     HG: Leave message empty to abort commit.
       
   241 
   236 
   242 Mercurial has now taken a snapshot of our repository and has attached our
   237 Mercurial has now taken a snapshot of our repository and has attached our
   243 description along with it. To see the status of the files in the repository,
   238 description along with it. To see the status of the files in the repository,
   244 use the ``hg status`` command. 
   239 use the ``hg status`` command. 
   245 
   240 
   261 ::
   256 ::
   262 
   257 
   263     $ hg log
   258     $ hg log
   264     changeset:   0:cbf6e2a375b4
   259     changeset:   0:cbf6e2a375b4
   265     tag:         tip
   260     tag:         tip
   266     user:        punchagan@shrike.aero.iitb.ac.in
   261     user:        Puneeth Chaganti <punchagan@fossee.in>
   267     date:        Fri Jan 28 14:04:07 2011 +0530
   262     date:        Fri Jan 28 14:04:07 2011 +0530
   268     summary:     Initial Commit
   263     summary:     Initial Commit
   269 
   264 
   270 
   265 
   271 As we already discussed, mercurial keeps track of the changes that are made
   266 As we already discussed, mercurial keeps track of the changes that are made
   276 description of the changeset.
   271 description of the changeset.
   277 
   272 
   278 User information
   273 User information
   279 ----------------
   274 ----------------
   280 
   275 
   281 But there is a slight problem with the user details that mercurial is saving.
   276 But there are two things, that can be changed. Firstly, it is unnecessary to
   282 It saves my username with my machine name. It is a general good practice to
   277 keep typing the user information each and every time we make a commit.
   283 use your full name with your email id. We set our username in the ``.hgrc``
   278 Secondly, it is not very convenient to enter a multi-line commit message from
   284 file in our Home folder. (``$HOME/.hgrc`` on Unix like systems and
   279 the terminal. To solve these problems, we set our user details and editor
   285 ``%HOME%\.hgrc`` on Windows systems) This is a global setting for all the
   280 preferences in the ``.hgrc`` file in our home folder. (``$HOME/.hgrc`` on
   286 projects that we are working on. We could also set the details, at a
   281 Unix like systems and ``%USERPROFILE%\.hgrc`` on Windows systems) This is a
   287 repository level. We shall look at this in due course. 
   282 global setting for all the projects that we are working on. We could also set
   288 
   283 the details, at a repository level. We shall look at this in due course.
   289 We open the file in our favorite editor and add the username details. 
   284 
       
   285 We open the file in our favorite editor and add the username details and our
       
   286 editor preferences. 
   290 
   287 
   291 ::
   288 ::
   292 
   289 
   293     $ emacs ~/.hgrc  
   290     $ emacs ~/.hgrc  
   294     [ui]
   291     [ui]
   295     username = Puneeth Chaganti <punchagan@fossee.in>
   292     username = Puneeth Chaganti <punchagan@fossee.in>
       
   293     editor = emacs
   296 
   294 
   297 We have now set the username details for mercurial to use, in all our future
   295 We have now set the username details for mercurial to use, in all our future
   298 commits. (Note: You can also set user preferences at the repository level.
   296 commits. (Note: You can also set user preferences at the repository level.
   299 Exercise-N asks you to do that)
   297 Exercise-N asks you to do that)
   300 
   298 
   311 
   309 
   312 ::
   310 ::
   313 
   311 
   314     $ hg commit
   312     $ hg commit
   315 
   313 
   316 We are again prompted with the editor window to enter our commit message and
   314 We are now prompted with a window of our favorite editor. We can now type out
   317 we type out our commit message. There are some good practices when typing out
   315 our commit message in the editor window. 
   318 a commit message too. It is a general practice to have a summary line in the
   316 
   319 commit message which is no longer than 60 to 65 characters giving a summary
   317 There are some recommended practices for commit messages, too. It is a
   320 of the change we have made. This is followed up with an explanation of why
   318 general practice to have a summary line in the commit message which is no
   321 this was changed, what is the effect of this change, known bugs/issues
   319 longer than 60 to 65 characters giving a summary of the change committed.
   322 remaining, if any, etc.
   320 This is followed up with an explanation of why this was changed, what is the
       
   321 effect of this change, known bugs/issues remaining, if any, etc.
   323 
   322 
   324 ::
   323 ::
   325 
   324 
   326     Add author info to all the chapters
   325     Add author info to all the chapters
   327 
   326 
  1019 ::
  1018 ::
  1020 
  1019 
  1021     $ hg commit -m "Merge heads."
  1020     $ hg commit -m "Merge heads."
  1022     $ hg push
  1021     $ hg push
  1023 
  1022 
  1024 *Note*, we have used a different way to commit. We have used the ``-m``
       
  1025 argument with the commit message.
       
  1026 
       
  1027 We could look at the graph of the changes, in our web interface, being served
  1023 We could look at the graph of the changes, in our web interface, being served
  1028 by the ``hg serve`` command. From the graph it is clear, how the merging has
  1024 by the ``hg serve`` command. From the graph it is clear, how the merging has
  1029 occurred. 
  1025 occurred. 
  1030 
  1026 
  1031 That brings us to the end of this tutorial on Mercurial. What we have covered
  1027 That brings us to the end of this tutorial on Mercurial. What we have covered