Mercurial

To install and run the Mercurial source control system using Unit:

  1. Install Unit with a Python language module.

  2. Install Mercurial’s core files. Here we install them at /path/to/app; use a real path in your configuration.

  3. Optionally, configure a repository or choose an existing one, noting its directory path.

  4. Unit uses WSGI to run Python apps, so it requires a wrapper script to publish a Mercurial repo. Here, it’s /path/to/app/hgweb.py (note the extension); the application callable is the entry point:

python
from mercurial.hgweb import hgweb   # path to a repo or a hgweb config file to serve in UTF-8 (see 'hg help hgweb')  application = hgweb("/path/to/app/repo/or/config/file".encode("utf-8")) # Replace with a real path in your configuration

This is a very basic script; to elaborate on it, see the Mercurial repo publishing guide.

  1. Change ownership:

    Run the following command (as root) so Unit can access the application directory (If the application uses several directories, run the command for each one):

    console
    # chown -R unit:unit /path/to/app/ # User and group that Unit's router runs as by default 
    The unit:unit user-group pair is available only with official packages , Docker images, and some third-party repos. Otherwise, account names may differ; run the ps aux | grep unitd command to be sure.

    For further details, including permissions, see the security checklist.

  2. Next, prepare the Mercurial configuration for Unit (use a real value for path):

    json
    {  "listeners": {  "*:80": {  "pass": "applications/hg"  }  },   "applications": {  "hg": {  "type": "python",  "path": "/path/to/app/",  "_comment_path": "Path to the WSGI file referenced by the module option; use a real path in your configuration",  "module": "hgweb",  "_comment_module": "WSGI module basename with extension omitted"  }  } }
  3. Upload the updated configuration.

    Assuming the JSON above was added to config.json. Run the following command as root:

    console
    # curl -X PUT --data-binary @config.json --unix-socket \  /path/to/control.unit.sock \ # Path to Unit's control socket in your installation  http://localhost/config/ # Path to the config section in Unit's control API 
    The control socket path may vary; run unitd -h or see Startup and shutdown for details.

    After a successful update, you can proceed to work with your Mercurial repository as usual:

    console
    hg config --edit 
    console
    hg clone http://localhost/ project/ 
    console
    cd project/ 
    console
    touch hg_rocks.txt 
    console
    hg add 
    console
    hg commit -m 'Official: Mercurial on Unit rocks!' 
    console
    hg push 

    Mercurial on Unit - Changeset Screen