Patchwork [1,of,2,V2] revsetlang: add a getboolean helper function

login
register
mail settings
Submitter Denis Laxalde
Date April 15, 2017, 9:41 a.m.
Message ID <b7086dbbff268161576b.1492249311@marimba>
Download mbox | patch
Permalink /patch/20210/
State Accepted
Headers show

Comments

Denis Laxalde - April 15, 2017, 9:41 a.m.
# HG changeset patch
# User Denis Laxalde <denis@laxalde.org>
# Date 1492248369 -7200
#      Sat Apr 15 11:26:09 2017 +0200
# Node ID b7086dbbff268161576bd62a374eec531bdabd7d
# Parent  4c2c30bc38b4f84ce8f215146bbf158e299065b3
revsetlang: add a getboolean helper function

This will be used to parse followlines's "descend" argument.
Yuya Nishihara - April 15, 2017, 10:05 a.m.
On Sat, 15 Apr 2017 11:41:51 +0200, Denis Laxalde wrote:
> # HG changeset patch
> # User Denis Laxalde <denis@laxalde.org>
> # Date 1492248369 -7200
> #      Sat Apr 15 11:26:09 2017 +0200
> # Node ID b7086dbbff268161576bd62a374eec531bdabd7d
> # Parent  4c2c30bc38b4f84ce8f215146bbf158e299065b3
> revsetlang: add a getboolean helper function

Queued, thanks.

Patch

diff --git a/mercurial/revsetlang.py b/mercurial/revsetlang.py
--- a/mercurial/revsetlang.py
+++ b/mercurial/revsetlang.py
@@ -199,6 +199,12 @@  def getinteger(x, err, default=_notset):
     except ValueError:
         raise error.ParseError(err)
 
+def getboolean(x, err):
+    value = util.parsebool(getsymbol(x))
+    if value is not None:
+        return value
+    raise error.ParseError(err)
+
 def getlist(x):
     if not x:
         return []