Patchwork [2,of,2] check-seclevel: wrap entry point by function

login
register
mail settings
Submitter Yuya Nishihara
Date Sept. 28, 2015, 3:37 p.m.
Message ID <85bd9d09001b5de46f17.1443454652@mimosa>
Download mbox | patch
Permalink /patch/10672/
State Accepted
Headers show

Comments

Yuya Nishihara - Sept. 28, 2015, 3:37 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1443359994 -32400
#      Sun Sep 27 22:19:54 2015 +0900
# Node ID 85bd9d09001b5de46f178bfff6bf7752adf424b8
# Parent  0b713dff75ada0020c8c8f13a3e3a0a65cd868af
check-seclevel: wrap entry point by function

This is intended to narrow scope of local variables. The global _verbose
flag will be replaced later by ui.verbose.
Augie Fackler - Sept. 28, 2015, 6:27 p.m.
On Tue, Sep 29, 2015 at 12:37:32AM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1443359994 -32400
> #      Sun Sep 27 22:19:54 2015 +0900
> # Node ID 85bd9d09001b5de46f178bfff6bf7752adf424b8
> # Parent  0b713dff75ada0020c8c8f13a3e3a0a65cd868af
> check-seclevel: wrap entry point by function

queued these, thanks!

>
> This is intended to narrow scope of local variables. The global _verbose
> flag will be replaced later by ui.verbose.
>
> diff --git a/doc/check-seclevel.py b/doc/check-seclevel.py
> --- a/doc/check-seclevel.py
> +++ b/doc/check-seclevel.py
> @@ -126,7 +126,7 @@ def checkfile(filename, initlevel):
>              (filename, initlevel))
>      return checkseclevel(doc, 'input from %s' % filename, initlevel)
>
> -if __name__ == "__main__":
> +def main():
>      optparser = optparse.OptionParser("""%prog [options]
>
>  This checks all help documents of Mercurial (topics, commands,
> @@ -159,6 +159,7 @@ option.
>
>      (options, args) = optparser.parse_args()
>
> +    global _verbose
>      _verbose = options.verbose
>
>      if options.file:
> @@ -167,3 +168,6 @@ option.
>      else:
>          if checkhghelps():
>              sys.exit(1)
> +
> +if __name__ == "__main__":
> +    main()
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/doc/check-seclevel.py b/doc/check-seclevel.py
--- a/doc/check-seclevel.py
+++ b/doc/check-seclevel.py
@@ -126,7 +126,7 @@  def checkfile(filename, initlevel):
             (filename, initlevel))
     return checkseclevel(doc, 'input from %s' % filename, initlevel)
 
-if __name__ == "__main__":
+def main():
     optparser = optparse.OptionParser("""%prog [options]
 
 This checks all help documents of Mercurial (topics, commands,
@@ -159,6 +159,7 @@  option.
 
     (options, args) = optparser.parse_args()
 
+    global _verbose
     _verbose = options.verbose
 
     if options.file:
@@ -167,3 +168,6 @@  option.
     else:
         if checkhghelps():
             sys.exit(1)
+
+if __name__ == "__main__":
+    main()