This site is an archive; learn more about 8 years of OpenHatch.

[OH-Dev] Mercurial Guide

Matt Bachmann bachmann.matt at gmail.com
Tue Mar 19 00:32:55 UTC 2013


Howdy!

During the sprints I did some work with the python dev team and learned the
basics of mercurial. I love Open Hatch's mission so I came by during the
sprint to help out.

Asheesh suggested I make up a mercurial guide using Oppia. There are some
technical hurdles to overcome before using Oppia for Openhatch missions so
I mainly worked on the text. For any input that requires an answer I left a
note for what it was.

I attached a YAML of the lesson. It borrows heavily (read: plagiarizes) the
git lesson wherever it felt appropriate. However, I hope it can at least be
used as a starting place for future work. While making this I found a few
issues with Oppia. I reported the issues on their bug tracker and provided
a patch for a particularly trivial one. I am willing to help on on this as
needed but I head back home tomorrow so no more sprinting for me.

Quick introduction. I work at Cloudlock as a Python dev. I have about six
months of Python experience and a bunch of Java experience. At Pycon I got
my first taste of open source development and I plan on trying to keep up
with it. It looks like Oppia is pretty new so I may work on that some but
ill keep an eye on this list as well :-)

-Bachmann
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openhatch.org/pipermail/devel/attachments/20130318/f142caf2/attachment-0001.html>
-------------- next part --------------
Setting Up Mercurial:
  content:
  - type: text
    value: ''
  - type: text
    value: '<div><h1>About Mercurial</h1><div><span class="itsa-markcolor" style="background-color:#FFFFFF">Mercurial
      is a Distributed Source Control Manager (DSCM) system similar to Git. It was
      written by Matt Mackall. This means that each user''s copy of the code is a
      fully working repository and includes all previous commit information. Rather
      than connecting to a remote server as you would with Subversion or CVS, users
      can work productively offline, choosing to later sync their changes with a remote
      repository or create a patch file.</span><br></div></div><div><br></div><div><h2>To
      learn more about Mercurial visit one of the following:</h2></div><div><ul><li>Mercurial
      Home Page: http://mercurial.selenic.com/<br></li><li>The Mercurial IRC Channel:
      #Mercurial</li><li>Detailed Guide:&nbsp;http://hgbook.red-bean.com/</li></ul><div><br></div><div><br></div><div><h2>This
      mission we will go over:</h2></div><div><ol><li><span style="line-height: 1.22;">Cloning
      a remote repository</span><br></li><li><span style="line-height: 1.22;">Making
      changes to files</span></li><li><span>Committing<span style="line-height: 1.22;">&nbsp;those
      changes to your local repository</span></span></li><li>Creating a patch</li></ol><div>However,
      first we need to install&nbsp;Mercurial</div><div><br></div><div>For various
      Linux systems or Macs with package managers look for a package labeled "mercurial"
      and install it.</div><div>Otherwise visit&nbsp;http://mercurial.selenic.com/
      and click the download button and run the installer.</div><div><br></div><div>Once
      you have it installed you should be able to run the following in a terminal
      window:&nbsp;</div></div></div><div><pre style="overflow-x: auto; overflow-y:
      hidden; padding: 10px; color: rgb(34, 34, 34); line-height: 1.2em; border: 1px
      solid rgb(198, 201, 203); font-size: 1.1em; margin-top: 1.5em; margin-bottom:
      1.5em; -webkit-box-shadow: rgb(216, 216, 216) 1px 1px 1px;"><span class="itsa-fontfamily"
      style="font-family: ''Courier New'';">hg --version</span></pre></div><div>If
      your output is similar to this you are ready to hit continue and move on to
      configuring:</div><div><br></div><div><pre style="overflow-x: auto; overflow-y:
      hidden; padding: 10px; color: rgb(34, 34, 34); line-height: 1.2em; border: 1px
      solid rgb(198, 201, 203); font-size: 1.1em; margin-top: 1.5em; margin-bottom:
      1.5em; -webkit-box-shadow: rgb(216, 216, 216) 1px 1px 1px;"><div style="color:
      rgb(0, 0, 0); font-size: 13px; line-height: 15px; white-space: normal; font-family:
      arial, helvetica, clean, sans-serif;"><span class="itsa-fontfamily yui_3_8_1_2_1363648382487_39
      yui_3_8_1_4_1363648382487_41" style="font-family: ''Courier New'';">Mercurial
      Distributed SCM (version 2.5.2)</span></div><div style="color: rgb(0, 0, 0);
      font-size: 13px; line-height: 15px; white-space: normal; font-family: arial,
      helvetica, clean, sans-serif;"><span class="itsa-fontfamily" style="font-family:
      ''Courier New'';">(see http://mercurial.selenic.com for more information)</span></div><div
      style="color: rgb(0, 0, 0); font-size: 13px; line-height: 15px; white-space:
      normal; font-family: arial, helvetica, clean, sans-serif;"><span><br></span></div><div
      style="color: rgb(0, 0, 0); font-size: 13px; line-height: 15px; white-space:
      normal; font-family: arial, helvetica, clean, sans-serif;"><span class="itsa-fontfamily
      yui_3_8_1_2_1363648382487_41 yui_3_8_1_4_1363648382487_43" style="font-family:
      ''Courier New'';">Copyright (C) 2005-2012 Matt Mackall and others</span></div><div
      style="color: rgb(0, 0, 0); font-size: 13px; line-height: 15px; white-space:
      normal; font-family: arial, helvetica, clean, sans-serif;"><span class="itsa-fontfamily
      yui_3_8_1_2_1363648382487_42 yui_3_8_1_4_1363648382487_44" style="font-family:
      ''Courier New'';">This is free software; see the source for copying conditions.
      There is NO</span></div><div style="color: rgb(0, 0, 0); font-size: 13px; line-height:
      15px; white-space: normal; font-family: arial, helvetica, clean, sans-serif;"><span
      class="itsa-fontfamily yui_3_8_1_2_1363648382487_43 yui_3_8_1_4_1363648382487_45"
      style="font-family: ''Courier New'';">warranty; not even for MERCHANTABILITY
      or FITNESS FOR A PARTICULAR PURPOSE.</span></div></pre></div>'
  param_changes: {}
  widget:
    handlers:
    - name: submit
      rules:
      - code: 'True'
        dest: Configuring Mercurial
        feedback: ''
        inputs: {}
        name: Default
        param_changes: {}
        rule: Default
    params:
      placeholder: Type your answer here.
    widget_id: Continue
Cloning A Repo:
  content:
  - type: text
    value: '<div><h1>Cloning a Repository</h1></div>W00T! Lets clone repository and
      take a look at the code!<div><div><br></div><div>To clone the repository enter
      in the following command:</div><div><span style="line-height: 1.22; font-family:
      ''Courier New'';" class="itsa-fontfamily"><pre style="overflow-x: auto; overflow-y:
      hidden; padding: 10px; color: rgb(34, 34, 34); line-height: 1.2em; border: 1px
      solid rgb(198, 201, 203); font-size: 1.1em; margin-top: 1.5em; margin-bottom:
      1.5em; -webkit-box-shadow: rgb(216, 216, 216) 1px 1px 1px;"><span style="color:
      rgb(0, 0, 0); font-size: 13px; line-height: 15px; white-space: normal; font-family:
      ''Courier New'';" class="itsa-fontfamily">hg clone http://selenic.com/hg mercurial-repo</span><span
      class="itsa-markcolor" style="color: rgb(0, 0, 0); font-size: 13px; line-height:
      15px; white-space: normal; background-color: rgb(255, 255, 0); font-family:
      arial, helvetica, clean, sans-serif;"><span>&nbsp;</span><span style="font-family:
      ''Courier New'';">TODO: DONT USE THE MERCURIAL URL</span></span></pre></span></div><div><span
      style="line-height: 1.22;">When you are ready find out who created this code.</span><span
      style="line-height: 1.22;">&nbsp;Enter the author below to continue.&nbsp;</span><span
      class="itsa-markcolor" style="background-color:#FFFF00"><img class="itsatoolbar-tmpempty"
      src="itsa-buttonicons-2012-08-15.png" width="0" height="0">The answer is: "Batman"</span><br></div><div
      style=""><span style="line-height: 1.22; font-family: ''Courier New'';" class="itsa-fontfamily
      itsa-fontsize"><pre style="overflow-x: auto; overflow-y: hidden; padding: 10px;
      color: rgb(34, 34, 34); line-height: 1.2em; border: 1px solid rgb(198, 201,
      203); margin-top: 1.5em; margin-bottom: 1.5em; -webkit-box-shadow: rgb(216,
      216, 216) 1px 1px 1px;"><span class="itsa-fontfamily" style="font-family: ''Courier
      New'';">hg blame hello.py</span><br></pre></span></div></div>'
  param_changes: {}
  widget:
    handlers:
    - name: submit
      rules:
      - code: equals(u'batman')
        dest: Making a change
        feedback: null
        inputs:
          x: batman
        name: equals(x)
        param_changes: {}
        rule: Answer is equal to {{x|String}}
      - code: 'True'
        dest: Cloning A Repo
        feedback: 'Whoops, that does not look like the author of the file. The author
          should be in the output of the following command.


          hg blame hello.py'
        inputs: {}
        name: Default
        param_changes: {}
        rule: Default
    params:
      placeholder: The Editor Of The File
    widget_id: TextInput
Configuring Mercurial:
  content:
  - type: text
    value: '<h1>Configuring Mercurial</h1><div>Fantastic! Lets get Mercurial configured.
      The basic configuration is done in a file called .hgrc in your home directory.
      On Windows this file is called mercurial.ini</div><div><br></div><div>We need
      to tell Mercurial your name and the email address to use for your identity.
      To do this open up the configuration file your favorite text editor and add
      the following.</div><div><pre style="overflow-x: auto; overflow-y: hidden; padding:
      10px; color: rgb(34, 34, 34); line-height: 1.2em; border: 1px solid rgb(198,
      201, 203); font-size: 1.1em; margin-top: 1.5em; margin-bottom: 1.5em; -webkit-box-shadow:
      rgb(216, 216, 216) 1px 1px 1px;"><div style="color: rgb(0, 0, 0); font-size:
      13px; line-height: 15px; white-space: normal; font-family: arial, helvetica,
      clean, sans-serif;"><span class="itsa-fontfamily yui_3_8_1_6_1363648382487_35"
      style="font-family: ''Courier New'';">[ui]</span></div><div style="color: rgb(0,
      0, 0); font-size: 13px; line-height: 15px; white-space: normal; font-family:
      arial, helvetica, clean, sans-serif;"><span class="itsa-fontfamily yui_3_8_1_6_1363648382487_36"
      style="font-family: ''Courier New'';">username = Your Name &lt;name at domain.com&gt;</span></div></pre></div><div><span
      class="itsa-fontfamily" style="font-family: ''Courier New'';"><br></span></div><div><span
      class="itsa-fontfamily" style="font-family: Arial;">To see if this has been
      done correctly you should be able to run the following</span></div><div><span
      class="itsa-fontfamily yui_3_8_1_6_1363648382487_38" style="font-family: Arial;"><pre
      style="overflow-x: auto; overflow-y: hidden; padding: 10px; color: rgb(34, 34,
      34); line-height: 1.2em; border: 1px solid rgb(198, 201, 203); font-size: 1.1em;
      margin-top: 1.5em; margin-bottom: 1.5em; -webkit-box-shadow: rgb(216, 216, 216)
      1px 1px 1px;"><div style="color: rgb(0, 0, 0); font-size: 13px; line-height:
      15px; white-space: normal; font-family: arial, helvetica, clean, sans-serif;"><span
      class="itsa-fontfamily yui_3_8_1_2_1363642518585_95"><span class="itsa-fontfamily
      yui_3_8_1_6_1363648382487_39" style="font-family: ''Courier New'';">hg showconfig</span></span></div></pre></span></div><div><span
      class="itsa-fontfamily yui_3_8_1_2_1363642518585_95"><span style="font-family:
      Arial;">and somewhere in the output you should see your name:</span></span></div><div><span
      class="itsa-fontfamily yui_3_8_1_2_1363642518585_95"><span style="font-family:
      Arial;" class="yui_3_8_1_6_1363648382487_41"><pre style="overflow-x: auto; overflow-y:
      hidden; padding: 10px; color: rgb(34, 34, 34); line-height: 1.2em; border: 1px
      solid rgb(198, 201, 203); font-size: 1.1em; margin-top: 1.5em; margin-bottom:
      1.5em; -webkit-box-shadow: rgb(216, 216, 216) 1px 1px 1px;"><span style="color:
      rgb(0, 0, 0); font-family: ''Courier New''; font-size: 13px; line-height: 15px;
      white-space: normal;">ui.username=Your Name name at domain.com</span></pre></span></span></div><div>When
      you are ready to clone a repository and edit a file hit continue!<br></div>'
  param_changes: {}
  widget:
    handlers:
    - name: submit
      rules:
      - code: 'True'
        dest: Cloning A Repo
        feedback: ''
        inputs: {}
        name: Default
        param_changes: {}
        rule: Default
    params: {}
    widget_id: Continue
Making a change:
  content:
  - type: text
    value: '<div><h1>Making A Change</h1></div><div><br></div>Now that you have the
      code lets take a look...<div><pre style="overflow-x: auto; overflow-y: hidden;
      padding: 10px; color: rgb(34, 34, 34); line-height: 1.2em; border: 1px solid
      rgb(198, 201, 203); font-size: 1.1em; margin-top: 1.5em; margin-bottom: 1.5em;
      -webkit-box-shadow: rgb(216, 216, 216) 1px 1px 1px;"><div style="color: rgb(0,
      0, 0); font-size: 13px; white-space: normal; font-family: arial, helvetica,
      clean, sans-serif;"><span class="itsa-fontfamily itsa-fontsize" style="font-size:
      13px; font-family: ''Courier New'';">python batman.py</span></div><div style="color:
      rgb(0, 0, 0); font-size: 13px; white-space: normal; font-family: arial, helvetica,
      clean, sans-serif;"><span class="itsa-fontfamily itsa-fontsize" style="font-size:
      13px; font-family: ''Courier New'';">Hello, World!</span></div><div style="color:
      rgb(0, 0, 0); font-size: 13px; white-space: normal; font-family: arial, helvetica,
      clean, sans-serif;"><span class="itsa-fontfamily itsa-fontsize" style="font-size:
      13px; font-family: ''Courier New'';">Hello, World!</span></div></pre><div><br></div><div>There
      seems to be a problem in hello.py</div><div>&nbsp;</div><div>If you run it it
      looks like "Hello, World!" prints twice. We cannot have this!</div><div><br></div><div>Fix
      the file so "Hello, World!" only prints once.</div><div><br></div><div>Now that
      you have it fixed we need to get this code to Batman so he can incorporate it
      into his project! Generally you will be unable to make changes to a project''s
      code directly so instead we are going to make a patch.</div><div><br></div><div>To
      do this run the following:</div><div><pre style="overflow-x: auto; overflow-y:
      hidden; padding: 10px; color: rgb(34, 34, 34); border: 1px solid rgb(198, 201,
      203); font-size: 1.1em; margin-top: 1.5em; margin-bottom: 1.5em; -webkit-box-shadow:
      rgb(216, 216, 216) 1px 1px 1px;"><span style="white-space: normal; font-size:
      13px; font-family: ''Courier New'';" class="itsa-fontsize">hg diff &gt; hello_fix.patch</span></pre></div><div><span
      class="itsa-fontfamily yui_3_8_1_2_1363644529136_80"><span style="color: rgb(34,
      34, 34); font-size: 1.1em; line-height: 1.2em; font-family: ''Courier New'';"
      class="yui_3_8_1_2_1363644529136_88 itsa-fontfamily"><span class="itsa-fontsize"
      style="font-size:13px"><span class="itsa-fontfamily" style="font-family: Arial;">This
      command saves the changes to made into a file that the project maintainer can
      use to add your changes to their codebase.</span></span><br></span></span></div><div><span
      class="itsa-fontfamily yui_3_8_1_2_1363644529136_80"><span style="color: rgb(34,
      34, 34); font-size: 1.1em; line-height: 1.2em; font-family: ''Courier New'';"
      class="yui_3_8_1_2_1363644529136_88 itsa-fontfamily yui_3_8_1_2_1363644529136_97"><span
      class="itsa-fontsize" style="font-size:13px"><span class="itsa-fontfamily" style="font-family:
      Arial;"><br></span></span></span></span></div><div><span class="itsa-fontfamily
      yui_3_8_1_2_1363644529136_80"><span style="color: rgb(34, 34, 34); font-size:
      1.1em; line-height: 1.2em; font-family: ''Courier New'';" class="yui_3_8_1_2_1363644529136_88
      itsa-fontfamily yui_3_8_1_2_1363644529136_97"><span class="itsa-fontsize" style="font-size:13px"><span
      class="itsa-fontfamily" style="font-family: Arial;">Once you have the patch
      file you can undo your changes with the following command</span></span></span></span></div><div><span
      class="itsa-fontfamily yui_3_8_1_2_1363644529136_80"><span style="color: rgb(34,
      34, 34); font-size: 1.1em; line-height: 1.2em; font-family: ''Courier New'';"
      class="yui_3_8_1_2_1363644529136_88 itsa-fontfamily yui_3_8_1_2_1363644529136_97
      yui_3_8_1_10_1363648382487_47"><span class="itsa-fontsize" style="font-size:
      13px;"><span class="itsa-fontfamily yui_3_8_1_10_1363648382487_49" style="font-family:
      Arial;"><pre style="overflow-x: auto; overflow-y: hidden; padding: 10px; line-height:
      1.2em; border: 1px solid rgb(198, 201, 203); font-size: 1.1em; margin-top: 1.5em;
      margin-bottom: 1.5em; -webkit-box-shadow: rgb(216, 216, 216) 1px 1px 1px;"><div
      style="color: rgb(0, 0, 0); font-size: 13px; line-height: 15px; white-space:
      normal; font-family: arial, helvetica, clean, sans-serif;"><span class="itsa-fontfamily
      yui_3_8_1_2_1363644529136_80"><span class="yui_3_8_1_2_1363644529136_88 itsa-fontfamily
      yui_3_8_1_2_1363644529136_97 yui_3_8_1_10_1363648382487_50" style="color: rgb(34,
      34, 34); font-size: 1.1em; line-height: 1.2em;"><span class="itsa-fontsize"
      style="font-size: 13px;"><span class="itsa-fontfamily yui_3_8_1_10_1363648382487_52"
      style="font-family: ''Courier New'';">hg revert -a</span></span></span></span></div></pre></span></span></span></span></div><div><span
      class="itsa-fontfamily" style="font-family: Arial;">If you would like to re-apply
      your changes at any time run the following</span></div><div><span class="itsa-fontfamily"
      style="font-family: ''Courier New'';"><pre style="overflow-x: auto; overflow-y:
      hidden; padding: 10px; color: rgb(34, 34, 34); line-height: 1.2em; border: 1px
      solid rgb(198, 201, 203); font-size: 1.1em; margin-top: 1.5em; margin-bottom:
      1.5em; -webkit-box-shadow: rgb(216, 216, 216) 1px 1px 1px;"><span style="color:
      rgb(0, 0, 0); font-family: ''Courier New''; font-size: 13px; line-height: 15px;
      white-space: normal;">hg import --no-commit hello_fix.patch</span></pre></span></div><div><span
      class="itsa-fontfamily yui_3_8_1_2_1363644529136_192" style="font-family: ''Courier
      New'';"><span class="itsa-fontfamily" style="font-family: Arial;">This will
      apply the changes contained in the patch file your clone of the project.</span></span></div></div><div><span
      class="itsa-fontfamily yui_3_8_1_2_1363644529136_192 yui_3_8_1_6_1363651116541_65"
      style="font-family: ''Courier New'';"><span class="itsa-fontfamily yui_3_8_1_6_1363651116541_66"
      style="font-family: Arial;"><br></span></span></div><div><span class="itsa-fontfamily
      yui_3_8_1_2_1363644529136_192 yui_3_8_1_6_1363651116541_65" style="font-family:
      ''Courier New'';"><span class="itsa-fontfamily yui_3_8_1_6_1363651116541_66"
      style="font-family: Arial;">It looks like Batman liked your change! Check the
      log and enter the message he left you!&nbsp;</span></span><span class="itsa-markcolor"
      style="background-color:#FFFF00">THE ANSWER IS "Thanks old chum"</span></div>'
  param_changes: {}
  widget:
    handlers:
    - name: submit
      rules:
      - code: contains(u'Thanks old chum')
        dest: END
        feedback: ''
        inputs:
          x: Thanks old chum
        name: contains(x)
        param_changes: {}
        rule: Answer contains {{x|String}}
      - code: 'True'
        dest: Making a change
        feedback: ''
        inputs: {}
        name: Default
        param_changes: {}
        rule: Default
    params:
      placeholder: Type your answer here.
    widget_id: TextInput


More information about the Devel mailing list