comparison benchmark/benchmark_utils.jl @ 1313:708dbfd5edb9 tooling/benchmarks

Make hg_at_revision() return the result of f
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 27 Apr 2023 08:48:28 +0200
parents f7621dd600e4
children 0551fd71682f
comparison
equal deleted inserted replaced
1312:f7621dd600e4 1313:708dbfd5edb9
189 a temporary commit will be used to save the state of the working directory. 189 a temporary commit will be used to save the state of the working directory.
190 """ 190 """
191 function hg_at_revision(f, rev) 191 function hg_at_revision(f, rev)
192 if hg_is_dirty() 192 if hg_is_dirty()
193 hg_with_temporary_commit() do 193 hg_with_temporary_commit() do
194 _hg_at_revision(f, rev) 194 return _hg_at_revision(f, rev)
195 end 195 end
196 else 196 else
197 _hg_at_revision(f, rev) 197 return _hg_at_revision(f, rev)
198 end 198 end
199 end 199 end
200 200
201 function _hg_at_revision(f, rev) 201 function _hg_at_revision(f, rev)
202 @assert !hg_is_dirty() 202 @assert !hg_is_dirty()
203 203
204 origin_rev = hg_rev() 204 origin_rev = hg_rev()
205 205
206 hg_update(rev) 206 hg_update(rev)
207 try 207 try
208 f() 208 return f()
209 finally 209 finally
210 hg_update(origin_rev) 210 hg_update(origin_rev)
211 end 211 end
212 end 212 end
213 213
222 @assert hg_is_dirty() 222 @assert hg_is_dirty()
223 223
224 origin_rev = hg_commit("[Automatic commit by julia]",secret=true) 224 origin_rev = hg_commit("[Automatic commit by julia]",secret=true)
225 225
226 try 226 try
227 f() 227 return f()
228 finally 228 finally
229 hg_update(origin_rev) 229 hg_update(origin_rev)
230 hg_strip(origin_rev; keep=true) 230 hg_strip(origin_rev; keep=true)
231 end 231 end
232 end 232 end