Mercurial
To install and run the Mercurial source control system using Unit:
-
Install Unit with a Python language module.
-
Install Mercurial’s core files. Here we install them at /path/to/app; use a real path in your configuration.
-
Optionally, configure a repository or choose an existing one, noting its directory path.
-
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:
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.
-
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):
# chown -R unit:unit /path/to/app/ # User and group that Unit's router runs as by default
Note:
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 theps aux | grep unitd
command to be sure.For further details, including permissions, see the security checklist.
-
Next, prepare the Mercurial configuration for Unit (use a real value for path):
{ "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" } } }
-
Upload the updated configuration.
Assuming the JSON above was added to
config.json
. Run the following command as root:# 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
After a successful update, you can proceed to work with your Mercurial repository as usual:
hg config --edit
hg clone http://localhost/ project/
cd project/
touch hg_rocks.txt
hg add
hg commit -m 'Official: Mercurial on Unit rocks!'
hg push