equal
deleted
inserted
replaced
141 # ui.log treats the input as a format string, |
141 # ui.log treats the input as a format string, |
142 # so we need to escape any % signs. |
142 # so we need to escape any % signs. |
143 val = val.replace('%', '%%') |
143 val = val.replace('%', '%%') |
144 ui.log('profile', val) |
144 ui.log('profile', val) |
145 fp.close() |
145 fp.close() |
|
146 |
|
147 @contextlib.contextmanager |
|
148 def maybeprofile(ui): |
|
149 """Profile if enabled, else do nothing. |
|
150 |
|
151 This context manager can be used to optionally profile if profiling |
|
152 is enabled. Otherwise, it does nothing. |
|
153 |
|
154 The purpose of this context manager is to make calling code simpler: |
|
155 just use a single code path for calling into code you may want to profile |
|
156 and this function determines whether to start profiling. |
|
157 """ |
|
158 if ui.configbool('profiling', 'enabled'): |
|
159 with profile(ui): |
|
160 yield |
|
161 else: |
|
162 yield |