Patchwork D875: hgweb: use parsebool for parsing diff query string options

login
register
mail settings
Submitter phabricator
Date Oct. 1, 2017, 1:33 p.m.
Message ID <2c233518be06515ed34b002f70b31b28@localhost.localdomain>
Download mbox | patch
Permalink /patch/24348/
State Not Applicable
Headers show

Comments

phabricator - Oct. 1, 2017, 1:33 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG407ebe7a9b93: hgweb: use parsebool for parsing diff query string options (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D875?vs=2254&id=2285

REVISION DETAIL
  https://phab.mercurial-scm.org/D875

AFFECTED FILES
  mercurial/hgweb/webcommands.py
  mercurial/hgweb/webutil.py

CHANGE DETAILS




To: indygreg, #hg-reviewers, simpkins, yuja
Cc: yuja, mercurial-devel

Patch

diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -177,12 +177,8 @@ 
     for k in ('ignorews', 'ignorewsamount', 'ignorewseol', 'ignoreblanklines'):
         v = req.form.get(k, [None])[0]
         if v is not None:
-            try:
-                v = bool(int(v))
-            except ValueError:
-                v = True
-
-            setattr(diffopts, k, v)
+            v = util.parsebool(v)
+            setattr(diffopts, k, v if v is not None else True)
 
     return diffopts
 
diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -865,9 +865,10 @@ 
 
     The ``ignorews``, ``ignorewsamount``, ``ignorewseol``, and
     ``ignoreblanklines`` query string arguments have the same meaning as
-    their ``[annotate]`` config equivalents. A value of ``0`` sets the
-    whitespace option to false. All other values are true. If not defined,
-    the server default settings are used.
+    their ``[annotate]`` config equivalents. It uses the hgrc boolean
+    parsing logic to interpret the value. e.g. ``0`` and ``false`` are
+    false and ``1`` and ``true`` are true. If not defined, the server
+    default settings are used.
 
     The ``fileannotate`` template is rendered.
     """