comparison mercurial/statprof.py @ 40199:b594db74dc13

py3: use raw strings in statprof.py This allows main() and argument parsing to work. Differential Revision: https://phab.mercurial-scm.org/D5017
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 12 Oct 2018 19:07:12 +0200
parents 9d3034348c4f
children 7df42042636d
comparison
equal deleted inserted replaced
40198:9d3034348c4f 40199:b594db74dc13
900 900
901 displayargs = {} 901 displayargs = {}
902 902
903 optstart = 2 903 optstart = 2
904 displayargs['function'] = None 904 displayargs['function'] = None
905 if argv[1] == 'hotpath': 905 if argv[1] == r'hotpath':
906 displayargs['format'] = DisplayFormats.Hotpath 906 displayargs['format'] = DisplayFormats.Hotpath
907 elif argv[1] == 'lines': 907 elif argv[1] == r'lines':
908 displayargs['format'] = DisplayFormats.ByLine 908 displayargs['format'] = DisplayFormats.ByLine
909 elif argv[1] == 'functions': 909 elif argv[1] == r'functions':
910 displayargs['format'] = DisplayFormats.ByMethod 910 displayargs['format'] = DisplayFormats.ByMethod
911 elif argv[1] == 'function': 911 elif argv[1] == r'function':
912 displayargs['format'] = DisplayFormats.AboutMethod 912 displayargs['format'] = DisplayFormats.AboutMethod
913 displayargs['function'] = argv[2] 913 displayargs['function'] = argv[2]
914 optstart = 3 914 optstart = 3
915 elif argv[1] == 'flame': 915 elif argv[1] == r'flame':
916 displayargs['format'] = DisplayFormats.FlameGraph 916 displayargs['format'] = DisplayFormats.FlameGraph
917 else: 917 else:
918 printusage() 918 printusage()
919 return 0 919 return 0
920 920
928 return 2 928 return 2
929 929
930 displayargs['limit'] = 0.05 930 displayargs['limit'] = 0.05
931 path = None 931 path = None
932 for o, value in opts: 932 for o, value in opts:
933 if o in ("-l", "--limit"): 933 if o in (r"-l", r"--limit"):
934 displayargs['limit'] = float(value) 934 displayargs['limit'] = float(value)
935 elif o in ("-f", "--file"): 935 elif o in (r"-f", r"--file"):
936 path = value 936 path = value
937 elif o in ("-o", "--output-file"): 937 elif o in (r"-o", r"--output-file"):
938 displayargs['outputfile'] = value 938 displayargs['outputfile'] = value
939 elif o in ("-p", "--script-path"): 939 elif o in (r"-p", r"--script-path"):
940 displayargs['scriptpath'] = value 940 displayargs['scriptpath'] = value
941 elif o in ("-h", "help"): 941 elif o in (r"-h", r"help"):
942 printusage() 942 printusage()
943 return 0 943 return 0
944 else: 944 else:
945 assert False, "unhandled option %s" % o 945 assert False, "unhandled option %s" % o
946 946
947 if not path: 947 if not path:
948 print('must specify --file to load') 948 print(r'must specify --file to load')
949 return 1 949 return 1
950 950
951 load_data(path=path) 951 load_data(path=path)
952 952
953 display(**pycompat.strkwargs(displayargs)) 953 display(**pycompat.strkwargs(displayargs))
954 954
955 return 0 955 return 0
956 956
957 if __name__ == "__main__": 957 if __name__ == r"__main__":
958 sys.exit(main()) 958 sys.exit(main())