Using Mercurial on CodePlex

If you're looking for a great Mercurial and CodePlex introduction, check out TekPub's Free Episode.

For instructions on how to get the latest changes from a project into your fork see Updating a Fork with Changes from the Master Repository.

There’s ton of documentation out there on how to use Mercurial and its various clients. For this blog post, you’ll see me use a popular client called TortoiseHg. (Hg is the chemical element symbol for Mercury, hence TortoiseHg in case you’re wondering.) If you’re already familiar with TortoiseSVN, this will be very straight forward.

Step 1: Install TortoiseHg

You can install TortoiseHg from http://tortoisehg.codeplex.com. Note: TortoiseHg is an extension of the Windows Explorer shell, so there is no application to launch.

When prompted for your personal information, the username you specify will not be associated with your CodePlex account. This username is only used for your local commits. We advise you to put in the same username as your Codeplex username.


Step 2: Create a new CodePlex project

In the Create a Project page you’ll see the following:

image

Select Mercurial.

Step 3: Clone the repository

Now you’ll want to create a local clone of the repository. You must do this step; otherwise, you cannot push code (i.e. check-in) to CodePlex.

First, create a new folder on your local machine where you want to download (or clone) the repository.

Next, use TortoiseHg to clone the repository in the newly created folder, as shown in the illustration.

Clone Command

You’ll be prompted by TortoiseHg for the Source path. You’ll need to get this URL from CodePlex. Go to the project, click on the Source Code tab, then click the Clone link in the action bar. You’ll see a popup appear with the Clone URL.

image

The URL is already selected so you can just use your keyboard shortcut to copy it. This is the URL to insert into TortoiseHg Source path, as shown in the below.

Source Path

Press Clone.

Once the clone is completed, the dialog will close and you’ll see a green checkmark indicating this is sync’ed with the Mercurial project on CodePlex.

Mercurial Folder

Now let’s look inside the folder containing the cloned repository. Since the repository is empty, there is only the .hg folder, which stores the Mercurial repository. DO NOT MODIFY THIS FOLDER unless you know exactly what you are doing.


Step 4: Add your files to your local repository

Now you can simply add your files to this folder. In this example, I only have one file that I’m going to add. Now right-click to bring up the Windows Explorer context menu, and select HG Commit. The HG Commit command will commit to local repository.

HG Commit

In the HG Commit dialog, fill out the description of the commit. (again this is just for local repository).

Make sure to check to commit all files (or whatever files you want to commit), as illustrated in red below.

Commit

Press the Commit button, accept any warnings, and you’ll be prompted with a status/success window.

Step 5: Push to CodePlex

To push the code to CodePlex, you’ll need to open the HG Repository Explorer on the Windows Explorer context menu. On the menu, you’ll see the Push icon. Press this to start the push to CodePlex.

Push

You will be prompted for your CodePlex credentials at this point. Once you have typed in your CodePlex username and password, you’ll see a success dialog.

Now you can go to your CodePlex project, click the source code tab, then click the History link to view your commits.

image

Last edited Jan 15 at 5:17 PM by tomcornelius, version 6

Comments

manueldahmen Dec 9, 2012 at 7:48 AM 
hg.exe push https://hg.codeplex.com/emptycanvas
pushing to https://hg.codeplex.com/emptycanvas
searching for changes
abort: repository is unrelated

Why? Since I have pushed 2 commits

vczh Dec 4, 2012 at 12:26 PM 
Found the problem, I should put the msi under C:\, or it will fail.

vczh Dec 4, 2012 at 12:25 PM 
Failed to install TortoiseHg 64bit version in http://tortoisehg.codeplex.com/releases/view/83627

yertmueller Jun 25, 2012 at 11:01 PM 
yertmueller, I have a Mac Power PC 10.4.11 and find it most difficult to get basic updates, Let alone programs that work with my machine. I love the computer. but am really dismayed that ever changing world of computing has a tendency to leave the slower and financially misfortunate as I would describe myself by design out of the loop. When realistically they could still generate incredibly momentous profits if they were capable of feeling the tinniest bit of empathy for their fellow humans. But I'm afraid in to-days climate that is a dream long past impossible.

Thank You,
Yert Mueller

suyashpratapts9 May 21, 2012 at 2:16 PM 
Hey

HamGuy Dec 27, 2011 at 3:33 PM 
我是使用Windows Live帐号登陆的,在克隆或者修改密码的时候总是提示我密码错误,但是我的密码明明是对的啊,不然,我怎么能在这发贴啊

johnnymm Nov 14, 2011 at 2:04 PM 
The password should be the one set in your codeplex user profile page

https://www.codeplex.com/site/users/update

CNSmartCoder Sep 30, 2011 at 8:08 AM 
% hg clone --verbose https://hg01.codeplex.com/cnsmartcodegenerator -- .
URLError: [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
[command returned code 255 Fri Sep 30 16:08:14 2011]

rockylmc Sep 6, 2011 at 9:10 AM 
克隆项目时,老是提示:URLError: [Errno 10060] ,什么原因??

Furiant Aug 6, 2011 at 6:22 PM 
This, and the tutorial by TekPub seems to be quite out of date. Many of the referenced options and dialogs are virtually unrecognizable.

qlfw Jun 7, 2011 at 3:43 AM 
当前无法解决

yongfu May 11, 2011 at 1:51 PM 
How can I get the code of my following projects?

txy779 Mar 22, 2011 at 5:59 AM 
就是不知道各位上传的时候当路径有中文的时候,怎么解决网页乱码问题的?

KiwiCreative Feb 10, 2011 at 11:51 AM 
Says "SSL: Server certificate verify failed" anyone got any ideas?

vuyiswamb Jan 19, 2011 at 1:37 PM 
i get an error that says "Commit:Invalid username, Your username has not been Configured. Please configuire your username and try again"

micsom Oct 3, 2010 at 4:30 AM 
when i try to run tortoisehg-1.1.4-hg-1.6.4-x86, it is showing "this installation package could not be opened"..how can i upload the source code?

shakti_saran May 24, 2010 at 3:27 PM 
The web-site shows different times for change sets pushed from Mercurial and releases uploaded as files and which are different from my computer time

shakti_saran May 24, 2010 at 3:05 PM 
It has been nice and some effort with few things to setup my project. I had to delete my project because after pushing (in terms of Hg) source to the server I realized it had pushed every version and just not the latest version. I think Mercurial is easy and useful.

pkellner May 24, 2010 at 5:01 AM 
I'm one step closer to being an HG user. These instructions worked perfectly! I've got my first project in HG source control. Now, to find out what to do next...

Domenic May 18, 2010 at 11:35 PM 
This is a bit confusing since the cloned repository is empty in the example. This is the case because, in the example, the person has just started a new project. For established projects that you might be cloning to work on locally, you will get a bunch of files inside the local repository upon cloning.

honey52570 Apr 27, 2010 at 7:19 AM 
Good

dexy Apr 23, 2010 at 1:00 PM 
Thanks, I had to go into the settings under Synchronize , for my project's settings (not the global settings), Edit the codeplex Repository Path. Then saved my user name in there. Before doing that it just gave me invalid username error.

mj1987 Apr 17, 2010 at 9:54 AM 
Very clear and simple explanation! Thanks!

Jaykul Mar 31, 2010 at 12:41 AM 
What GTK theme is that?

jdecuyper Mar 23, 2010 at 5:21 PM 
Thanks for the well-explained tutorial!

meteormatt Mar 13, 2010 at 2:12 AM 
这个说明不错.

seointexas Mar 12, 2010 at 4:06 PM 
keeps saying command interrupted

CodePlexAdmin Mar 11, 2010 at 7:57 PM 
If you want to convert your existing project to Mercurial, you can submit a request using our Contact Us form: https://www.codeplex.com/site/contact

senfo Feb 20, 2010 at 1:18 PM 
How do I add Mercurial support for existing projects that I own?

robfe Jan 26, 2010 at 9:18 PM 
Note that the commit username you choose in mercurial (which is what you see listed in the change set) can be different to the credentials you supply to codeplex when pushing. This could cause confusion!