Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions pillar/base/haproxy.sls
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,6 @@ haproxy:
hsts_preload: False

listens:
hg_ssh:
bind: :20100
service: hg-ssh

buildbot_worker:
bind: :20101
service: buildbot-master-worker
Expand Down
20 changes: 2 additions & 18 deletions salt/hg/config/hg.apache.conf.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,14 @@
Require all granted
</Directory>

# The lookup app is better run with few processes, since it uses a cache.
WSGIDaemonProcess hglookup user=hg group=hg \
threads=2 processes=1 maximum-requests=1000 \
display-name=hglookup
# The Location hack ensures the lookup app is run within
# this process group
<Location /lookup>
WSGIProcessGroup hglookup
ProxyPass http://localhost:8000/lookup
</Location>

WSGIScriptAlias /lookup /srv/hg/wsgi/lookup.wsgi

# A lightweight standin for revision app to maintain support for /lookup
WSGIDaemonProcess hgrev user=hg group=hg \
threads=1 processes=6 maximum-requests=100 \
display-name=hgrev
# The Location hack ensures the lookup app is run within
# this process group
<LocationMatch "^(.*)/rev/([A-Fa-f0-9]{12,40})/?">
WSGIProcessGroup hgrev
ProxyPass http://localhost:8000
</LocationMatch>

WSGIScriptAliasMatch "^(.*)/rev/([A-Fa-f0-9]{12,40})/?" /srv/hg/wsgi/rev.wsgi

# Staticly serve hg repos over HTTP
DocumentRoot /srv/hg/hg-static/
<Directory /srv/hg/hg-static>
Expand Down
17 changes: 17 additions & 0 deletions salt/hg/config/hgmin.service.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[Unit]
Description=Minimal HG service
After=network.target

[Service]
Environment=LC_ALL=en_US.UTF-8
Environment=LANG=en_US.UTF-8
WorkingDirectory=/srv/hg/src
ExecStart=/srv/hg/env/bin/gunicorn app:app -w 4 --access-logfile - --error-logfile -
ExecReload=/bin/kill -HUP $MAINPID
ExecStop = /bin/kill -s TERM $MAINPID
Restart=on-failure
User=hg
Group=hg

[Install]
WantedBy=multi-user.target
19 changes: 0 additions & 19 deletions salt/hg/config/repos.conf

This file was deleted.

76 changes: 0 additions & 76 deletions salt/hg/files/hg/bin/gcrepos

This file was deleted.

80 changes: 0 additions & 80 deletions salt/hg/files/hg/bin/genauth

This file was deleted.

72 changes: 72 additions & 0 deletions salt/hg/files/hg/src/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import io
import os
import subprocess
import shlex
import json

from flask import current_app, Flask, make_response, redirect

app = Flask(__name__)

HG_COMMITS = os.path.join(os.path.dirname(__file__), "hg_commits.json")
app.hg_commits = set()
with io.open(HG_COMMITS, "r", encoding="utf-8") as file:
hg_commits = json.load(file)
hg_commits = set(hg_commits)
hg_commits.update(commit[:12] for commit in list(hg_commits))
app.hg_commits = frozenset(hg_commits)


@app.route("/lookup/<rev>")
def lookup(rev):
url = None
if rev.startswith("hg") or rev in current_app.hg_commits:
if rev.startswith("hg"):
rev = rev[len("hg") :]
url = "https://hg.python.org/cpython/rev/" + rev
elif rev.startswith("r"):
url = "http://svn.python.org/view?view=revision&revision=" + rev[1:]
else:
if rev.startswith("git"):
rev = rev[len("git") :]
url = "https://github.com/python/cpython/commit/" + rev
if url is None:
return make_response(
(
"Usage: /lookup/GITHEXHASH or gitGITHEXHASH "
"(10, 11, or 40 hex characters)\n",
"/lookup/HGHEXNODE or hgHGHEXNODE (12 or 40 hex characters)\n",
"/lookup/rSVNREVISION\n",
),
404,
)
else:
return redirect(url, code=303)


@app.route("/<path:repo>/rev/<rev>")
def hgrev(repo, rev):
hg_repo = os.path.join("/srv/hg/repos", repo, ".hg")
if not os.path.exists(hg_repo):
return make_response(f"repo not found ({repo}) ({rev})", 404)
command = ["hg", "log", "-v", "-p", "-r", shlex.quote(rev)]
try:
result = subprocess.run(
command,
cwd=hg_repo,
capture_output=True,
text=False,
shell=False,
check=True,
)
except Exception as e:
return make_response(
(
f"{str(e)}\n"
"Usage: path/to/hg/repo/rev/HGHEXNODE "
"(12 or 40 hex characters)\n"
),
404,
)

return make_response(result.stdout, 200)
70 changes: 0 additions & 70 deletions salt/hg/files/hg/src/hglookup.py

This file was deleted.

Loading