Wednesday, February 22, 2012

Setting up a Mercurial Repository for team programming

Okay, the whole point of this is to help some Westminster College students set up a repository on their Linux Server and then create a local repository from which they can push and pull code with their fellow team members.

Assumptions:
     1. You have a Windows PC or Laptop
     2. You have Key Authentication for password free connection to the Linux Server
     3. You are somewhat familiar with Agile development, or at least team programming

Use PuTTY to make sure your key authentication is working.

Next set up a folder so you can clone the central repository on the Linux Server.

Pull up Windows Powershell or cmd.exe and "CD" to your working directory.
If you're using Eclipse, then type.

cd \Users\"Your Windows Username Here"\Workspace\

Your command prompt should look like this

Make sure you've installed Mercurial from http://mercurial.selenic.com/wiki/Download

Read Joel Spolsky's site http://hginit.com

Open Explorer.exe (Windows Explorer) and go to C:\Users\"UserName"\

Create an ".ini" file named Mercurial.ini

Now let's edit the ini file so it actually has some settings.

Use this as a template:


[ui]
username = Jacob Wattleworth
ssh = "C:\PuTTY\plink.exe" -ssh -i "C:\PuTTY\my_privkey.ppk"


[extensions]


[web]
push_ssl = false
allow_push = *




Now to initialise your repository.

Type hg init.

Now clone your main repository
This should be in the form "hg -v clone source destination"
Source = The Central Repository on the Linux Server
Destination = The local Repository on your Windows PC or Laptop



Next if you have code in your repo that was pulled from the central repo in the CLONE then import that project into Eclipse.

Open Eclipse and Choose File, Import from the menu bar.



In the import window choose Existing Projects into Workspace

Browse to your local repo myTeamProject or what ever it's called. (mine's bumble in this example)


Click OK and then finish the import.

You can now begin working on the code.

You are now officially a g33x.

cd to your new repo in PowerShell or CMD.exe.

cd \myTeamProject

Remember the basic commands for pushing and pulling and never commit a change until it has been peer reviewed. Or create a branch that doesn't affect production code.

hg pull - Pulls files from the central repo on the Linux Server to your local repo.
hg up - Updates the repos
hg ci -m "comment" - Commits changes on your local repo to the central repo
hg stat - shows any changes that need to be made.

Just read hginit.com for anything else.

Good Luck.

No comments: