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
--- a/contrib/check-code.py Fri May 20 09:47:35 2016 +0900
+++ b/contrib/check-code.py Fri May 20 09:47:35 2016 +0900
@@ -622,7 +622,7 @@
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")
@@ -650,4 +650,7 @@
blame=options.blame, debug=options.debug,
lineno=options.lineno):
ret = 1
- sys.exit(ret)
+ return ret
+
+if __name__ == "__main__":
+ sys.exit(main())