diff options
Diffstat (limited to 'main.py')
| -rwxr-xr-x | main.py | 19 |
1 files changed, 18 insertions, 1 deletions
| @@ -27,6 +27,7 @@ import optparse | |||
| 27 | import os | 27 | import os |
| 28 | import re | 28 | import re |
| 29 | import sys | 29 | import sys |
| 30 | import time | ||
| 30 | import urllib2 | 31 | import urllib2 |
| 31 | 32 | ||
| 32 | from trace import SetTrace | 33 | from trace import SetTrace |
| @@ -56,6 +57,9 @@ global_options.add_option('--no-pager', | |||
| 56 | global_options.add_option('--trace', | 57 | global_options.add_option('--trace', |
| 57 | dest='trace', action='store_true', | 58 | dest='trace', action='store_true', |
| 58 | help='trace git command execution') | 59 | help='trace git command execution') |
| 60 | global_options.add_option('--time', | ||
| 61 | dest='time', action='store_true', | ||
| 62 | help='time repo command execution') | ||
| 59 | global_options.add_option('--version', | 63 | global_options.add_option('--version', |
| 60 | dest='show_version', action='store_true', | 64 | dest='show_version', action='store_true', |
| 61 | help='display this version of repo') | 65 | help='display this version of repo') |
| @@ -125,7 +129,20 @@ class _Repo(object): | |||
| 125 | RunPager(config) | 129 | RunPager(config) |
| 126 | 130 | ||
| 127 | try: | 131 | try: |
| 128 | cmd.Execute(copts, cargs) | 132 | start = time.time() |
| 133 | try: | ||
| 134 | cmd.Execute(copts, cargs) | ||
| 135 | finally: | ||
| 136 | elapsed = time.time() - start | ||
| 137 | hours, remainder = divmod(elapsed, 3600) | ||
| 138 | minutes, seconds = divmod(remainder, 60) | ||
| 139 | if gopts.time: | ||
| 140 | if hours == 0: | ||
| 141 | print >>sys.stderr, 'real\t%dm%.3fs' \ | ||
| 142 | % (minutes, seconds) | ||
| 143 | else: | ||
| 144 | print >>sys.stderr, 'real\t%dh%dm%.3fs' \ | ||
| 145 | % (hours, minutes, seconds) | ||
| 129 | except ManifestInvalidRevisionError, e: | 146 | except ManifestInvalidRevisionError, e: |
| 130 | print >>sys.stderr, 'error: %s' % str(e) | 147 | print >>sys.stderr, 'error: %s' % str(e) |
| 131 | sys.exit(1) | 148 | sys.exit(1) |
