Mercurial > hg > sonic-visualiser
comparison vext.sml @ 1766:762ef5d2722a
Update Vext
author | Chris Cannam |
---|---|
date | Fri, 02 Feb 2018 11:40:24 +0000 |
parents | cd10346cc810 |
children | 128c4544036d |
comparison
equal
deleted
inserted
replaced
1765:bfdffe725fe4 | 1766:762ef5d2722a |
---|---|
36 shall not be used in advertising or otherwise to promote the sale, | 36 shall not be used in advertising or otherwise to promote the sale, |
37 use or other dealings in this Software without prior written | 37 use or other dealings in this Software without prior written |
38 authorization. | 38 authorization. |
39 *) | 39 *) |
40 | 40 |
41 val vext_version = "0.9.94" | 41 val vext_version = "0.9.95" |
42 | 42 |
43 | 43 |
44 datatype vcs = | 44 datatype vcs = |
45 HG | | 45 HG | |
46 GIT | | 46 GIT | |
340 else if cmdlist = nil then "" | 340 else if cmdlist = nil then "" |
341 else hd (rev cmdlist) | 341 else hd (rev cmdlist) |
342 in | 342 in |
343 print (" " ^ | 343 print (" " ^ |
344 Vector.sub(tick_chars, !tick_cycle) ^ " " ^ | 344 Vector.sub(tick_chars, !tick_cycle) ^ " " ^ |
345 pad_to 24 name ^ | 345 pad_to 70 name ^ |
346 "\r"); | 346 "\r"); |
347 tick_cycle := (if !tick_cycle = n - 1 then 0 else 1 + !tick_cycle) | 347 tick_cycle := (if !tick_cycle = n - 1 then 0 else 1 + !tick_cycle) |
348 end | 348 end |
349 | 349 |
350 fun run_command context libname cmdlist redirect = | 350 fun run_command context libname cmdlist redirect = |
351 let open OS | 351 let open OS |
352 val dir = libpath context libname | 352 val dir = libpath context libname |
353 val cmd = expand_commandline cmdlist | 353 val cmd = expand_commandline cmdlist |
354 val _ = if verbose () | 354 val _ = if verbose () |
355 then print ("Running: " ^ cmd ^ | 355 then print ("\n=== " ^ dir ^ "\n<<< " ^ cmd ^ "\n") |
356 " (in dir " ^ dir ^ ")...\n") | |
357 else tick libname cmdlist | 356 else tick libname cmdlist |
358 val _ = FileSys.chDir dir | 357 val _ = FileSys.chDir dir |
359 val status = case redirect of | 358 val status = case redirect of |
360 NONE => Process.system cmd | 359 NONE => Process.system cmd |
361 | SOME file => Process.system (cmd ^ ">" ^ file) | 360 | SOME file => Process.system (cmd ^ ">" ^ file) |
373 let open OS | 372 let open OS |
374 val tmpFile = FileSys.tmpName () | 373 val tmpFile = FileSys.tmpName () |
375 val result = run_command context libname cmdlist (SOME tmpFile) | 374 val result = run_command context libname cmdlist (SOME tmpFile) |
376 val contents = file_contents tmpFile | 375 val contents = file_contents tmpFile |
377 val _ = if verbose () | 376 val _ = if verbose () |
378 then print ("Output was:\n\"" ^ contents ^ "\"\n") | 377 then print (">>> \"" ^ contents ^ "\"\n") |
379 else () | 378 else () |
380 in | 379 in |
381 FileSys.remove tmpFile handle _ => (); | 380 FileSys.remove tmpFile handle _ => (); |
382 case result of | 381 case result of |
383 OK () => OK contents | 382 OK () => OK contents |
1376 ERROR e => OK false (* HEAD nonexistent, expected in empty repo *) | 1375 ERROR e => OK false (* HEAD nonexistent, expected in empty repo *) |
1377 | OK id => | 1376 | OK id => |
1378 if String.isPrefix id_or_tag id orelse | 1377 if String.isPrefix id_or_tag id orelse |
1379 String.isPrefix id id_or_tag | 1378 String.isPrefix id id_or_tag |
1380 then OK true | 1379 then OK true |
1381 else | 1380 else is_at_tag context (libname, id, id_or_tag) |
1381 | |
1382 and is_at_tag context (libname, id, tag) = | |
1383 (* For annotated tags (with message) show-ref returns the tag | |
1384 object ref rather than that of the revision being tagged; | |
1385 we need the subsequent rev-list to chase that up. In fact | |
1386 the rev-list on its own is enough to get us the id direct | |
1387 from the tag name, but it fails with an error if the tag | |
1388 doesn't exist, whereas we want to handle that quietly in | |
1389 case the tag simply hasn't been pulled yet *) | |
1390 case git_command_output context libname | |
1391 ["show-ref", "refs/tags/" ^ tag, "--"] of | |
1392 OK "" => OK false (* Not a tag *) | |
1393 | ERROR _ => OK false | |
1394 | OK s => | |
1395 let val tag_ref = hd (String.tokens (fn c => c = #" ") s) | |
1396 in | |
1382 case git_command_output context libname | 1397 case git_command_output context libname |
1383 ["show-ref", | 1398 ["rev-list", "-1", tag_ref] of |
1384 "refs/tags/" ^ id_or_tag, | 1399 OK tagged => OK (id = tagged) |
1385 "--"] of | |
1386 OK "" => OK false | |
1387 | ERROR _ => OK false | 1400 | ERROR _ => OK false |
1388 | OK s => OK (id = hd (String.tokens (fn c => c = #" ") s)) | 1401 end |
1389 | 1402 |
1390 fun branch_tip context (libname, branch) = | 1403 fun branch_tip context (libname, branch) = |
1391 (* We don't have access to the source info or the network | 1404 (* We don't have access to the source info or the network |
1392 here, as this is used by status (e.g. via is_on_branch) as | 1405 here, as this is used by status (e.g. via is_on_branch) as |
1393 well as review. It's possible the remote branch won't exist, | 1406 well as review. It's possible the remote branch won't exist, |
1394 e.g. if the repo was checked out by something other than | 1407 e.g. if the repo was checked out by something other than |
2375 else pad_to n (str ^ " ") | 2388 else pad_to n (str ^ " ") |
2376 | 2389 |
2377 fun hline_to 0 = "" | 2390 fun hline_to 0 = "" |
2378 | hline_to n = "-" ^ hline_to (n-1) | 2391 | hline_to n = "-" ^ hline_to (n-1) |
2379 | 2392 |
2380 val libname_width = 25 | 2393 val libname_width = 28 |
2381 val libstate_width = 11 | 2394 val libstate_width = 11 |
2382 val localstate_width = 17 | 2395 val localstate_width = 17 |
2383 val notes_width = 5 | 2396 val notes_width = 5 |
2384 val divider = " | " | 2397 val divider = " | " |
2385 val clear_line = "\r" ^ pad_to 80 ""; | 2398 val clear_line = "\r" ^ pad_to 80 ""; |