Mercurial > repos > public > sbplib_julia
comparison benchmark/benchmark_utils.jl @ 1312:f7621dd600e4 tooling/benchmarks
Add hg_at_revision()
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 26 Apr 2023 13:46:37 +0200 |
parents | 5eb1d0ae0ac1 |
children | 708dbfd5edb9 |
comparison
equal
deleted
inserted
replaced
1311:5eb1d0ae0ac1 | 1312:f7621dd600e4 |
---|---|
179 out = readchomp(addenv(cmd, "HGPLAIN"=>"")) | 179 out = readchomp(addenv(cmd, "HGPLAIN"=>"")) |
180 | 180 |
181 return endswith(out, "+") | 181 return endswith(out, "+") |
182 end | 182 end |
183 | 183 |
184 """ | |
185 hg_at_revision(f, rev) | |
186 | |
187 Update the repository to the given revision and run the function `f`. After | |
188 `f` is run the working directory is restored. If there are uncommited changes | |
189 a temporary commit will be used to save the state of the working directory. | |
190 """ | |
191 function hg_at_revision(f, rev) | |
192 if hg_is_dirty() | |
193 hg_with_temporary_commit() do | |
194 _hg_at_revision(f, rev) | |
195 end | |
196 else | |
197 _hg_at_revision(f, rev) | |
198 end | |
199 end | |
200 | |
201 function _hg_at_revision(f, rev) | |
202 @assert !hg_is_dirty() | |
203 | |
204 origin_rev = hg_rev() | |
205 | |
206 hg_update(rev) | |
207 try | |
208 f() | |
209 finally | |
210 hg_update(origin_rev) | |
211 end | |
212 end | |
213 | |
214 """ | |
215 hg_with_temporary_commit(f) | |
216 | |
217 Run the function `f` after making a temporary commit with the current working | |
218 directory. After `f` has finished the working directory is restored to its | |
219 original state and the temporary commit stripped. | |
220 """ | |
221 function hg_with_temporary_commit(f) | |
222 @assert hg_is_dirty() | |
223 | |
224 origin_rev = hg_commit("[Automatic commit by julia]",secret=true) | |
225 | |
226 try | |
227 f() | |
228 finally | |
229 hg_update(origin_rev) | |
230 hg_strip(origin_rev; keep=true) | |
231 end | |
232 end | |
184 | 233 |
185 | 234 |
186 # From Pluto.jl/src/webserver/WebServer.jl (2023-01-24) | 235 # From Pluto.jl/src/webserver/WebServer.jl (2023-01-24) |
187 function open_in_default_browser(url::AbstractString)::Bool | 236 function open_in_default_browser(url::AbstractString)::Bool |
188 try | 237 try |