Saturday, July 19, 2008

Working with mercurial

A while back I wrote an intro about using mercurial as your own repository that does not require any network connection to commit. Finally I've come to the point where I have to send my modifications onto another machine. So how do I do it? Let's begin with having the project reside on a computer which we will call mainserver. On this machine we already have created a mercurial repo and has committed files into it. Let's say we have another machine which we will call devlaptop. And on the devlaptop there is no copy of the project yet. So here are the steps by steps to get your work done.

1. First we will put a copy of the project into devlaptop. At the mainserver go to the project root directory and run the command `hg serve`. This should make the repo accesible on the default port 8000. Use the -p option to set to a different port. Then on the devlaptop run the command `hg clone http://mainserver:8000 projectname`. That will pull the project from the mainserver and put it into the projectname directory on the devlaptop. (Note: if your routes are not set properly just replace the name mainserver with the actual ip of mainserver)

2. Do your thing. Fix up the project and stuff. Commit to the local repo like there's no tomorrow. Until your finally satisfied. All test have passed and it is time to finally put those changes on the mainserver.

3. Put the changes from devlaptop onto the mainserver. First on the devlaptop go to the project root directory and run `hg serve`. That would make the repo available to others. Then on the mainserver just go to the project root directory and run `hg pull http://devlaptop:8000`. That will pull all the latest changes you've made on the devlaptop. But the repo will now be aware of the changes but have not applied them yet. To apply them run the command `hg update` on the mainserver and it should apply all the changes to the local repo. Now the mainserver has the most latest of your project.

Simple...

1 comment:

Jose said...

Can we push the changes from Devlaptop to mainserver and perform a remote hg update on mainserver? if so, what would be the steps to perform this?

Haiya ala Solah