Mercurial > hg
view doc/docchecker @ 36859:422be99519e5
hgweb: remove support for short query string based aliases (BC)
Form data exposed by hgweb is post-processed to expand certain
shortcuts. For example, URLs with "?cs=@" is essentially expanded to
"?cmd=changeset&node=@". And the URL router treats this the same
as "/changeset/@".
These shortcuts were initially added in 2005 in 34cb3957d875 and
964baa35faf8. They have rarely been touched in the last decade (just
moving code around a bit).
We have almost no test coverage of this feature. AFAICT no templates
reference URLs of this form. I even looked at the initial version
of paper and coal from ~2008 and they use the "/command/params" URL
form and not these shortcuts.
Furthermore, I couldn't even get some shortcuts to work! For example,
"?sl=@" attempts to do a revision search instead of showing shortlog
starting at revision @. Maybe I'm just doing it wrong?
Because this is ancient, mostly untested code, there is a migration
path to something better, and because anyone passionate enough to
preserve URLs can install URL redirects, let's nuke the feature.
.. bc::
Query string shorts in hgweb like ``?cs=@`` have been removed. Use
URLs of the form ``/:cmd`` instead.
Differential Revision: https://phab.mercurial-scm.org/D2773
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Fri, 09 Mar 2018 17:10:36 -0800 |
parents | c9ab5a0bc7c5 |
children | 9bfbb9fc5871 |
line wrap: on
line source
#!/usr/bin/env python # # docchecker - look for problematic markup # # Copyright 2016 timeless <timeless@mozdev.org> and others # # This software may be used and distributed according to the terms of the # GNU General Public License version 2 or any later version. from __future__ import absolute_import, print_function import re import sys leadingline = re.compile(r'(^\s*)(\S.*)$') checks = [ (r""":hg:`[^`]*'[^`]*`""", """warning: please avoid nesting ' in :hg:`...`"""), (r'\w:hg:`', 'warning: please have a space before :hg:'), (r"""(?:[^a-z][^'.])hg ([^,;"`]*'(?!hg)){2}""", '''warning: please use " instead of ' for hg ... "..."'''), ] def check(line): messages = [] for match, msg in checks: if re.search(match, line): messages.append(msg) if messages: print(line) for msg in messages: print(msg) def work(file): (llead, lline) = ('', '') for line in file: # this section unwraps lines match = leadingline.match(line) if not match: check(lline) (llead, lline) = ('', '') continue lead, line = match.group(1), match.group(2) if (lead == llead): if (lline != ''): lline += ' ' + line else: lline = line else: check(lline) (llead, lline) = (lead, line) check(lline) def main(): for f in sys.argv[1:]: try: with open(f) as file: work(file) except BaseException as e: print("failed to process %s: %s" % (f, e)) main()