Thursday, December 18, 2008

Setup your own hg local repo with pushlog

I am working on generating repackages on change and the HgLocalePoller looks for the pushlog of a locale's repository. For instance: http://hg.mozilla.org/l10n-central/de/pushlog

Since my development and testing is dependent on commit changes to the l10n repositories, I need to have commit access to generate more changes and since I am not a localizer I do not have access to the l10n repositories.

Therefore there were three options for me:
  1. Gain commit access to the x-testing repository on the l10n repositories and do commits in there. Inconvenience: It is a long process to gain access.
  2. Create my own user repo in hg.mozilla.org. The same inconvenience as the previous one
  3. Setup my own local repo with pushlog
I was lucky enough that ted was around and he proposed me and guided me to do this last option.

Steps to create your own hg repo locally with pushlog:

  1. cd /repos
  2. hg clone http://hg.mozilla.org/users/bsmedberg_mozilla.com/hghooks/
  3. hg clone http://hg.mozilla.org/users/bsmedberg_mozilla.com/hgpoller/
  4. hg clone http://hg.mozilla.org/users/bsmedberg_mozilla.com/hg_templates/
  5. mkdir test-repo
  6. cd test-repo
  7. hg init
  8. cp ../hghooks/examples-hgrc .hg/hgrc // which basically contains the following:
    # the a_ and z_ prefixes are for ordering:
    # any hooks which can veto an action (require-singlehead) should be run before
    # hooks which make permanent logs (record-changeset-info)

    [hooks]
    pretxnchangegroup.a_singlehead = python:mozhghooks.single_head_per_branch.hook
    pretxnchangegroup.z_linearhistory = python:mozhghooks.pushlog.log

  9. export PYTHONPATH=/repos/hghooks/ // /repos is my path, use your own
  10. vi .hg/hgrc // Add the following with your own paths:
    [web]
    templates = /repos/hg_templates
    style = gitweb_mozilla
    [extensions]
    pushlog-feed = /repos/hgpoller/pushlog-feed.py
    buglink = /repos/hgpoller/buglink.py
    hgwebjson = /repos/hgpoller/hgwebjson.py
  11. sudo apt-get install python-simplejson //hgwebjson needs this module
  12. hg serve //To start your hg server

You can now check your own hg server with pushlog:
http://localhost:8000
and your pushlog at:
http://localhost:8000/pushlog

Remember that it is a server and you have to clone first!

  1. export PYTHONPATH=/repos/hghooks/
  2. hg clone test-repo test-repo-2
  3. cd test-repo-2; echo "test data" > testfile;
  4. hg add testfile;
  5. hg ci -m "adding a test file";
  6. hg push ../test-repo

3 comments:

  1. The HG templates repo is located here:
    http://hg.mozilla.org/hg_templates/

    ReplyDelete
  2. Note that Mercurial 1.2 does not work with our hooks. Bug https://bugzilla.mozilla.org/show_bug.cgi?id=486539 to follow it.

    You can do easy_install mercurial=1.1 to get the right version

    ReplyDelete
  3. Armen, remember to check this post:
    http://armenzg.blogspot.com/2008/12/how-to-show-subdirectories-in-your-hg.html
    where the config files is correct:
    [web]
    templates = /repos/hg_templates
    style = gitweb_mozilla
    [paths]
    l10n-central/af = l10n-central/af
    l10n-central/de = l10n-central/de
    mozilla-central = mozilla-central

    ReplyDelete