Mercurial > hg > sonic-visualiser
comparison vext.sml @ 1723:b97b2b7af50c vext
Update Vext
author | Chris Cannam |
---|---|
date | Thu, 29 Jun 2017 11:23:15 +0100 |
parents | bf8a5ce8fb62 |
children | e4352ff029cf |
comparison
equal
deleted
inserted
replaced
1722:fd23206b0d9a | 1723:b97b2b7af50c |
---|---|
31 Particular Programs Ltd shall not be used in advertising or | 31 Particular Programs Ltd shall not be used in advertising or |
32 otherwise to promote the sale, use or other dealings in this | 32 otherwise to promote the sale, use or other dealings in this |
33 Software without prior written authorization. | 33 Software without prior written authorization. |
34 *) | 34 *) |
35 | 35 |
36 val vext_version = "0.9.2" | 36 val vext_version = "0.9.3" |
37 | 37 |
38 | 38 |
39 datatype vcs = | 39 datatype vcs = |
40 HG | | 40 HG | |
41 GIT | 41 GIT |
1204 end | 1204 end |
1205 | 1205 |
1206 fun update_to context (libname, "") = | 1206 fun update_to context (libname, "") = |
1207 ERROR "Non-empty id (tag or revision id) required for update_to" | 1207 ERROR "Non-empty id (tag or revision id) required for update_to" |
1208 | update_to context (libname, id) = | 1208 | update_to context (libname, id) = |
1209 case hg_command context libname ["update", "-r" ^ id] of | 1209 let val pull_result = pull context libname |
1210 OK () => id_of context libname | 1210 in |
1211 | ERROR _ => | 1211 case hg_command context libname ["update", "-r", id] of |
1212 case pull context libname of | 1212 OK _ => id_of context libname |
1213 ERROR e => ERROR e | 1213 | ERROR e => |
1214 | _ => | 1214 case pull_result of |
1215 case hg_command context libname ["update", "-r" ^ id] of | 1215 ERROR e' => ERROR e' (* this was the ur-error *) |
1216 ERROR e => ERROR e | 1216 | _ => ERROR e |
1217 | _ => id_of context libname | 1217 end |
1218 | 1218 |
1219 end | 1219 end |
1220 | 1220 |
1221 structure GitControl :> VCS_CONTROL = struct | 1221 structure GitControl :> VCS_CONTROL = struct |
1222 | 1222 |
1268 if String.isPrefix id_or_tag id orelse | 1268 if String.isPrefix id_or_tag id orelse |
1269 String.isPrefix id id_or_tag | 1269 String.isPrefix id id_or_tag |
1270 then OK true | 1270 then OK true |
1271 else | 1271 else |
1272 case git_command_output context libname | 1272 case git_command_output context libname |
1273 ["rev-list", "-1", id_or_tag] of | 1273 ["show-ref", |
1274 ERROR e => OK false (* id_or_tag is not an id or tag, but | 1274 "refs/tags/" ^ id_or_tag] of |
1275 that could just mean it hasn't been | 1275 OK "" => OK false |
1276 fetched *) | 1276 | ERROR _ => OK false |
1277 | OK tid => OK (tid = id) | 1277 | OK s => OK (id = hd (String.tokens (fn c => c = #" ") s)) |
1278 | 1278 |
1279 fun branch_tip context (libname, branch) = | 1279 fun branch_tip context (libname, branch) = |
1280 git_command_output context libname | 1280 git_command_output context libname |
1281 ["rev-list", "-1", | 1281 ["rev-list", "-1", |
1282 remote_branch_name branch] | 1282 remote_branch_name branch] |
1330 remote_branch_name branch] of | 1330 remote_branch_name branch] of |
1331 ERROR e => ERROR e | 1331 ERROR e => ERROR e |
1332 | _ => id_of context libname | 1332 | _ => id_of context libname |
1333 | 1333 |
1334 (* This function is dealing with a specific id or tag, so if we | 1334 (* This function is dealing with a specific id or tag, so if we |
1335 can successfully check it out (detached) then that's all we need | 1335 can successfully check it out (detached) then that's all we |
1336 to do. Otherwise we need to fetch and try again *) | 1336 need to do, regardless of whether fetch succeeded or not. We do |
1337 attempt the fetch first, though, purely in order to avoid ugly | |
1338 error messages in the common case where we're being asked to | |
1339 update to a new pin (from the lock file) that hasn't been | |
1340 fetched yet. *) | |
1337 | 1341 |
1338 fun update_to context (libname, "") = | 1342 fun update_to context (libname, "") = |
1339 ERROR "Non-empty id (tag or revision id) required for update_to" | 1343 ERROR "Non-empty id (tag or revision id) required for update_to" |
1340 | update_to context (libname, id) = | 1344 | update_to context (libname, id) = |
1341 case git_command context libname ["checkout", "--detach", id] of | 1345 let val fetch_result = git_command context libname ["fetch"] |
1342 OK () => id_of context libname | 1346 in |
1343 | ERROR _ => | 1347 case git_command context libname ["checkout", "--detach", id] of |
1344 case git_command context libname ["fetch"] of | 1348 OK _ => id_of context libname |
1345 ERROR e => ERROR e | 1349 | ERROR e => |
1346 | _ => | 1350 case fetch_result of |
1347 case git_command context libname ["checkout", "--detach", id] of | 1351 ERROR e' => ERROR e' (* this was the ur-error *) |
1348 ERROR e => ERROR e | 1352 | _ => ERROR e |
1349 | _ => id_of context libname | 1353 end |
1354 | |
1350 end | 1355 end |
1351 | 1356 |
1352 structure AnyLibControl :> LIB_CONTROL = struct | 1357 structure AnyLibControl :> LIB_CONTROL = struct |
1353 | 1358 |
1354 structure H = LibControlFn(HgControl) | 1359 structure H = LibControlFn(HgControl) |