Skip to main content
This revision made January 13, 2011 20:56, by leawang

» Project Kenai Documentation and Training    » How Do I ...    » Source Code Management

Using Mercurial on Microsoft Windows Systems

Once you have a Mercurial client installed on your local system, you can check out code and check it back into your project repository. The following instructions for command-line Mercurial should get you started. For full instructions on using Mercurial, see http://hgbook.red-bean.com/.

Because of the better security and better handling of large files, it's best to use the SSH protocol to check files into your project repository. This page assumes you have set up an SSH key and you've configured Mercurial to use plink to manage the key, as described on the following two pages:

  1. To initially set up your java.net repository, you need to know the name of the project and the name of the source repository. For example, for a project named bluebird with a Mercurial repository named bluebird~mercurial-code-repository, the default read-write URL would be:
     ssh://your-username@hg.java.net/bluebird~mercurial-code-repository
  2. Change directories on your local machine to the directory in which you want your new hg repository directory to be created, then do the initial clone and create. For example:
     > cd \myproj
     > hg clone ssh://your-username@hg.java.net/bluebird~mercurial-code-repository bluebird-hg
    Note: If the command hangs when you're using Mercurial with PuTTY's Plink command-line interface, Plink is likely to be waiting for you to confirm the Host SSH key signature, which you can't do directly at this point. What you can do is start PuTTY, then in the Session settings enter the Host Name part of the URL (for example, ssh://your-username@hg.java.net) and click Open, and then type Y to save the host SSH key in the registry. You should then see the command complete in the Command window.
  3. Change directories to the new directory:
     > cd bluebird-hg
  4. Copy a file to the local working copy and then add it in Mercurial.
     > cp \myjavafiles\helloworld.java helloworld.java
     > hg add helloworld.java
  5. Commit the file to the local repository.
     > hg commit -m"First commit to bluebird repository" helloworld.java
  6. Pull any changes from the server repository:
     > hg pull
  7. Update the local working copy:
     > hg update
  8. Check the file into your project repository on the server:
     > hg push
  9. You see the a series of messages similar to the following:
     pushing to ssh://your-username@hg.java.net/bluebird~mercurial-code-repository
     searching for changes
     remote: adding changesets
     remote: adding manifests
     remote: adding file changes
     remote: added 1 changesets with 1 changes to 1 files

You now have a file in your java.net repository.

Difference compared to previous revision
<span>* [[Winsshwithputty|Generating and Using an SSH Key on a Microsoft Windows Machine]] * [[Usinghg-winsshsetup|Setting Up Mercurial to Use SSH on a Microsoft Windows Machine]] # To initially set up your <span style="text-decoration:line-through;color:red">ken</span><span style="text-decoration:underline;color:green">j</span>a<span style="text-decoration:line-through;color:red">i</span><span style="text-decoration:underline;color:green">va</span>.<span style="text-decoration:line-through;color:red">com</span><span style="text-decoration:underline;color:green">net</span> repository, you need to know the name of the project and the name of the source repository. For example, for a project named <tt>bluebird</tt> with a Mercurial repository named <tt>bluebird~mercurial-code-repository</tt>, the default read-write URL would be:<br/><tt> &nbsp;<nowiki>ssh://</nowiki>''your-username''<nowiki>@hg.<span style="text-decoration:line-through;color:red">ken</span><span style="text-decoration:underline;color:green">j</span>a<span style="text-decoration:line-through;color:red">i</span><span style="text-decoration:underline;color:green">va</span>.<span style="text-decoration:line-through;color:red">com</span><span style="text-decoration:underline;color:green">net</span>/bluebird~mercurial-code-repository</nowiki></tt> # Change directories on your local machine to the directory in which you want your new hg repository directory to be created, then do the initial clone and create. For example:<br/><tt>&nbsp;> cd \myproj</tt><br/><tt>&nbsp;> hg clone <nowiki>ssh://</nowiki>''your-username''<nowiki>@hg.<span style="text-decoration:line-through;color:red">ken</span><span style="text-decoration:underline;color:green">j</span>a<span style="text-decoration:line-through;color:red">i</span><span style="text-decoration:underline;color:green">va</span>.<span style="text-decoration:line-through;color:red">com</span><span style="text-decoration:underline;color:green">net</span>/bluebird~mercurial-code-repository</nowiki> bluebird-hg</tt><br/>'''Note:''' If the command hangs when you're using Mercurial with PuTTY's Plink command-line interface, Plink is likely to be waiting for you to confirm the Host SSH key signature, which you can't do directly at this point. What you can do is start PuTTY, then in the Session settings enter the Host Name part of the URL (for example, <tt><nowiki>ssh://</nowiki>''your-username''<nowiki>@hg.<span style="text-decoration:line-through;color:red">ken</span><span style="text-decoration:underline;color:green">j</span>a<span style="text-decoration:line-through;color:red">i</span><span style="text-decoration:underline;color:green">va</span>.<span style="text-decoration:line-through;color:red">com</span><span style="text-decoration:underline;color:green">net</span></nowiki></tt>) and click Open, and then type Y to save the host SSH key in the registry. You should then see the command complete in the Command window. # Change directories to the new directory:<br/><tt>&nbsp;> cd bluebird-hg</tt> # Copy a file to the local working copy and then add it in Mercurial.<br/><tt>&nbsp;> cp \myjavafiles\helloworld.java helloworld.java</tt><br/><tt>&nbsp;> hg add helloworld.java</tt> # Commit the file to the local repository.<br/><tt>&nbsp;> hg commit -m"First commit to bluebird repository" helloworld.java</tt> ... # Pull any changes from the server repository:<br/><tt>&nbsp;> hg pull </tt> # Update the local working copy:<br/><tt>&nbsp;> hg update</tt> # Check the file into your project repository on the server:<br/><tt>&nbsp;> hg push</tt> # You see the a series of messages similar to the following:<br/><tt> &nbsp;pushing to <nowiki>ssh://your-username@hg.<span style="text-decoration:line-through;color:red">ken</span><span style="text-decoration:underline;color:green">j</span>a<span style="text-decoration:line-through;color:red">i</span><span style="text-decoration:underline;color:green">va</span>.<span style="text-decoration:line-through;color:red">com</span><span style="text-decoration:underline;color:green">net</span>/bluebird~mercurial-code-repository</nowiki></tt><br/><tt> &nbsp;searching for changes<br/> &nbsp;remote: adding changesets<br/> &nbsp;remote: adding manifests<br/> &nbsp;remote: adding file changes<br/> &nbsp;remote: added 1 changesets with 1 changes to 1 files</tt> You now have a file in your <span style="text-decoration:line-through;color:red">ken</span><span style="text-decoration:underline;color:green">j</span>a<span style="text-decoration:line-through;color:red">i</span><span style="text-decoration:underline;color:green">va</span>.<span style="text-decoration:line-through;color:red">com</span><span style="text-decoration:underline;color:green">net</span> repository. <span>
 
 
Close
loading
Please Confirm
Close