Tuesday, 13 September 2011

HG Mercurial Quick Setup Tutorial

Setting up Remote (build in) http server for multiple repositories

* Create Directory Structure

  - repo-root
   |- Project1.hg
   |- Project2.hg
   hgweb.config
   run.bat
 
* Edit hgweb.config as follows

  [collections]
  repos/ = .

  [web]
  style = gitweb
  push_ssl = false
  allow_push = *
 
* Edit run.bat as follows and run it

  hg serve --webdir-conf hgweb.config

Http Server is running on http://localhost:8000/ 
 

Setting up Remote Repository

* Create Folder /repo-root/Project1.hg
* Run hg init from within that folder


Setting up Local Repository

* Go to your local project directory /projects
* Clone remote repository locally

  hg clone http://localhost:8000/Project1.hg Project1

If you have an existing project and want to push it to remote repository

* Run hg push http://localhost:8000/Project1.hg

Or set default remote repository

* Create file /projects/Project1/.hg/hgrc
* Add this to file

  [paths]
  default =
http://localhost:8000/Project1.hg

* Now you can use hg push
 
Basic Commands

hg add (schedule files to be added to local repository)
hg commit (add files to local repository)
hg revert (revert changes to last commit)
hg push (push changes from remote repository)
hg pull (get changes from remote repository)
 

For more info look at Joel Spolsky Hg Init Mercurial Tutorial

No comments:

Post a Comment