[PATCH 2 of 5 V3] check-code: factor out boot procedure into main

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Fri Jul 15 11:29:43 EDT 2016


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1463705255 -32400
#      Fri May 20 09:47:35 2016 +0900
# Node ID 4fa5a7fa43ebab4170fdbd754c8adf92519881b9
# Parent  cf54693a2b23005be994149cc89579af06224d46
check-code: factor out boot procedure into main

This is a part of preparation for adding check-code.py extra checks by
another python script in subsequent patch.

This is also useful for SkeletonExtensionPlan.

    https://www.mercurial-scm.org/wiki/SkeletonExtensionPlan

diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -621,7 +621,7 @@ def checkfile(f, logfunc=_defaultlogger.
 
     return result
 
-if __name__ == "__main__":
+def main():
     parser = optparse.OptionParser("%prog [options] [files]")
     parser.add_option("-w", "--warnings", action="store_true",
                       help="include warning-level checks")
@@ -649,4 +649,7 @@ if __name__ == "__main__":
                          blame=options.blame, debug=options.debug,
                          lineno=options.lineno):
             ret = 1
-    sys.exit(ret)
+    return ret
+
+if __name__ == "__main__":
+    sys.exit(main())


More information about the Mercurial-devel mailing list