--- a/mercurial/hgweb/webutil.py Sun Mar 26 16:51:19 2017 -0700
+++ b/mercurial/hgweb/webutil.py Thu Jan 19 17:41:00 2017 +0100
@@ -18,6 +18,7 @@
from .common import (
ErrorResponse,
+ HTTP_BAD_REQUEST,
HTTP_NOT_FOUND,
paritygen,
)
@@ -317,6 +318,26 @@
return fctx
+def linerange(req):
+ linerange = req.form.get('linerange')
+ if linerange is None:
+ return None
+ if len(linerange) > 1:
+ raise ErrorResponse(HTTP_BAD_REQUEST,
+ 'redundant linerange parameter')
+ try:
+ fromline, toline = map(int, linerange[0].split(':', 1))
+ except ValueError:
+ raise ErrorResponse(HTTP_BAD_REQUEST,
+ 'invalid linerange parameter')
+ try:
+ return util.processlinerange(fromline, toline)
+ except error.ParseError as exc:
+ raise ErrorResponse(HTTP_BAD_REQUEST, str(exc))
+
+def formatlinerange(fromline, toline):
+ return '%d:%d' % (fromline + 1, toline)
+
def commonentry(repo, ctx):
node = ctx.node()
return {