comparison mercurial/hgweb/webcommands.py @ 34391:f6492f482c60

hgweb: query string arguments to control whitespace for annotate This feature should hopefully be pretty straightforward. We simply examine some query string arguments to feed into the diff options. The function to obtain the diff options has been factored into its own generic function to facilitate an upcoming change to the HTML interface and to enable diff settings to be controlled via the same query string arguments on other web commands. The test output for "ignoreblanklines" didn't change. I'm not sure why. Our test coverage for --ignore-blank-lines isn't great and I can't figure out how to make this diff setting do anything meaningful. On a very brief examination of the code, it is possible the setting doesn't work because it is operating at the line level and blank lines detection needs to examine multiple lines. But I'm not an expert in this code, so I'm not sure. Differential Revision: https://phab.mercurial-scm.org/D849
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 30 Sep 2017 09:08:01 +0100
parents db63872e10cc
children 6797f1fbc642
comparison
equal deleted inserted replaced
34390:e16ad1576d71 34391:f6492f482c60
861 /annotate/{revision}/{path} 861 /annotate/{revision}/{path}
862 --------------------------- 862 ---------------------------
863 863
864 Show changeset information for each line in a file. 864 Show changeset information for each line in a file.
865 865
866 The ``ignorews``, ``ignorewsamount``, ``ignorewseol``, and
867 ``ignoreblanklines`` query string arguments have the same meaning as
868 their ``[annotate]`` config equivalents. A value of ``0`` sets the
869 whitespace option to false. All other values are true. If not defined,
870 the server default settings are used.
871
866 The ``fileannotate`` template is rendered. 872 The ``fileannotate`` template is rendered.
867 """ 873 """
868 fctx = webutil.filectx(web.repo, req) 874 fctx = webutil.filectx(web.repo, req)
869 f = fctx.path() 875 f = fctx.path()
870 parity = paritygen(web.stripecount) 876 parity = paritygen(web.stripecount)
893 if fctx.isbinary(): 899 if fctx.isbinary():
894 mt = (mimetypes.guess_type(fctx.path())[0] 900 mt = (mimetypes.guess_type(fctx.path())[0]
895 or 'application/octet-stream') 901 or 'application/octet-stream')
896 lines = [((fctx.filectx(fctx.filerev()), 1), '(binary:%s)' % mt)] 902 lines = [((fctx.filectx(fctx.filerev()), 1), '(binary:%s)' % mt)]
897 else: 903 else:
898 lines = webutil.annotate(fctx, web.repo.ui) 904 lines = webutil.annotate(req, fctx, web.repo.ui)
899 905
900 previousrev = None 906 previousrev = None
901 blockparitygen = paritygen(1) 907 blockparitygen = paritygen(1)
902 for lineno, ((f, targetline), l) in enumerate(lines): 908 for lineno, ((f, targetline), l) in enumerate(lines):
903 rev = f.rev() 909 rev = f.rev()