omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / apps / interplane-forge / collab / co4pat.om
| 1 | note collab/co4pat.om (ForgePatches): one patch page: header, linked verdicts, description, revisions, |
| 2 | note activity in change order, and the diff of one revision (latest not redacted, or ?rev=<id prefix>). |
| 3 | text tccode "<code>" |
| 4 | text tccodee "</code>" |
| 5 | text tcdiff "diff" |
| 6 | text tcnoext "--no-ext-diff" |
| 7 | text tcoptm "-M" |
| 8 | text tcstat "--stat=160,100" |
| 9 | text tcrevq "rev" |
| 10 | text tcdsuf ".diff" |
| 11 | text tcfull "--full-index" |
| 12 | text tccach ".full.diff" |
| 13 | text tcctxt "text/plain; charset=utf-8" |
| 14 | text tcph1 "<section class=\"rhead\"><h1>" |
| 15 | text tcph2 " <span class=\"muted mono\">" |
| 16 | text tcph3 "</span></h1>\n<p class=\"meta\">" |
| 17 | text tcph4 " · opened by " |
| 18 | text tcph5 " on " |
| 19 | text tcph6 " · id <code>" |
| 20 | text tcph7 "</code></p></section>\n" |
| 21 | text tcvh1 "<section class=\"box\"><h2>Linked verdicts</h2>\n" |
| 22 | text tcvh2 "<p class=\"muted\">No review verdict names a head of this patch.</p>\n" |
| 23 | text tcvh4 "</section>\n" |
| 24 | text tcvr1 "<p><b>" |
| 25 | text tcvr2 "</b><br><span class=\"meta\">revision " |
| 26 | text tcvr3 ", head <code>" |
| 27 | text tcvr4 "</code></span></p>\n" |
| 28 | text tcdc1 "<p>forge decide: " |
| 29 | text tcdc2 "<b class=\"ok\">MERGE OK</b>" |
| 30 | text tcdc3 "<b class=\"bad\">HOLD " |
| 31 | text tcdc4 "</b><br><span class=\"meta\">revision " |
| 32 | text tcdc5 "; gate receipt: gate_rc=" |
| 33 | text tcdc6 ", negctl_rc=" |
| 34 | text tcdc7 ", author <code>" |
| 35 | text tcdc8 "</code>" |
| 36 | text tcdc9 "; no gate receipt shown" |
| 37 | text tcdc10 "</span></p>\n" |
| 38 | text tcdw3 "VERDICT_UNREADABLE" |
| 39 | text tcdw4 "VERDICT_MALFORMED" |
| 40 | text tcdw5 "VERDICT_MERGE_AFTER_FIX" |
| 41 | text tcdw6 "VERDICT_REJECT" |
| 42 | text tcdw7 "HEAD_MISMATCH" |
| 43 | text tcdw8 "NO_REVIEWER" |
| 44 | text tcdw9 "RECEIPT_UNREADABLE" |
| 45 | text tcdw10 "RECEIPT_MALFORMED" |
| 46 | text tcdw11 "NO_NEGCTL" |
| 47 | text tcdw12 "CLONE_MISMATCH" |
| 48 | text tcdw13 "GATE_FAIL" |
| 49 | text tcdw14 "NEGCTL_PASSED" |
| 50 | text tcdw15 "SELF_REVIEW" |
| 51 | text tcdw17 "RECEIPT_AMBIGUOUS" |
| 52 | note tcbldc: the commit the running forged was built from; run.sh writes it here at build time when |
| 53 | note the composed units match that commit, else it stays "unrecorded" (review forge-web-13102b54 P1) |
| 54 | text tcbldc "unrecorded" |
| 55 | text tcbl1 "<p class=\"meta\">This forge runs forged built from commit <code>" |
| 56 | text tcbl2 "</code>.</p>\n" |
| 57 | text tcbl3 "<p class=\"meta\">This forge runs a forged build whose commit was not recorded.</p>\n" |
| 58 | text tcmg1 "<p class=\"ok\">Merged: revision " |
| 59 | text tcmg2 " as commit <code>" |
| 60 | text tcmg3 "</code> by " |
| 61 | text tcmg4 "</p>\n" |
| 62 | text tcdh1 "<h2>Description</h2>\n" |
| 63 | text tcpre1 "<pre class=\"hit\">" |
| 64 | text tcpre2 "</pre>\n" |
| 65 | text tcnodesc "<p class=\"muted\">No description.</p>\n" |
| 66 | text tclab1 "<p class=\"meta\">Labels: " |
| 67 | text tcasg1 "<p class=\"meta\">Assignees: " |
| 68 | text tcpend "</p>\n" |
| 69 | text tcrt1 "<h2>Revisions</h2>\n<table><tr><th>#</th><th>Revision</th><th>Base</th><th>Head</th><th>Author</th><th>Date</th><th>Verdict</th></tr>\n" |
| 70 | text tcrt2 "<tr><td>" |
| 71 | text tctd "</td><td>" |
| 72 | text tcrt3 "</td></tr>\n" |
| 73 | text tcrt4 "</table>\n" |
| 74 | text tcrevr " (redacted)" |
| 75 | text tcrq "?rev=" |
| 76 | text tcrfrag "#changes" |
| 77 | text tcah1 "<h2>Activity</h2>\n<ul class=\"repos\">\n" |
| 78 | text tcai1 "<li><p class=\"meta\">" |
| 79 | text tcai2 "</p>" |
| 80 | text tcai3 "</li>\n" |
| 81 | text tcaopen " opened this patch with revision 1" |
| 82 | text tcarev " pushed revision " |
| 83 | text tcarevw " reviewed revision " |
| 84 | text tcacom " commented on revision " |
| 85 | text tcacomx " commented" |
| 86 | text tcamrg " merged revision " |
| 87 | text tcaacc ": <b class=\"ok\">accept</b>" |
| 88 | text tcarej ": <b class=\"bad\">reject</b>" |
| 89 | text tcaredc "<p class=\"muted\">Comment redacted.</p>" |
| 90 | text tcaat " at <code>" |
| 91 | text tcacc "</code>" |
| 92 | text tcahead " head <code>" |
| 93 | text tcdf1 "<h2 id=\"changes\">Changes in revision " |
| 94 | text tcdf2 "</h2>\n<p class=\"meta\">git diff <code>" |
| 95 | text tcdf3 "</code> to <code>" |
| 96 | text tcdf4 "</code> · <a href=\"" |
| 97 | text tcdf5 "\">raw diff</a></p>\n" |
| 98 | text tcdferr "<p class=\"bad\">git diff failed for this revision (exit status " |
| 99 | text tcdfcut "<p class=\"muted\">The diff is cut at 1 MiB on this page; use the raw diff for the rest.</p>\n" |
| 100 | text tcdfnone "<p class=\"muted\">Every revision is redacted; there is no diff to show.</p>\n" |
| 101 | text tcspok "<span class=\"ok\">" |
| 102 | text tcspbad "<span class=\"bad\">" |
| 103 | text tcspmut "<span class=\"muted\">" |
| 104 | text tcspend "</span>" |
| 105 | text tctpat " - patch - " |
| 106 | note copatpg: the page of the patch whose id prefix is gcrq; 404 when unknown or ambiguous |
| 107 | fn copatpg to long |
| 108 | if eq corefs 2 false |
| 109 | ret 500 |
| 110 | end |
| 111 | colsav |
| 112 | if eq corefs 1 false |
| 113 | ret 500 |
| 114 | end |
| 115 | if eq coresolve false |
| 116 | ret 404 |
| 117 | end |
| 118 | if eq coload 1 false |
| 119 | ret 404 |
| 120 | end |
| 121 | if ne get gcov 0 0 |
| 122 | fincut |
| 123 | ret 500 |
| 124 | end |
| 125 | for r ulong get gcrn 0 |
| 126 | cdlook r |
| 127 | end |
| 128 | colscan |
| 129 | copttl |
| 130 | frepohd 5 |
| 131 | copthd |
| 132 | copverd |
| 133 | qnshow |
| 134 | copmerge |
| 135 | codref coqrev |
| 136 | copdesc |
| 137 | copmeta |
| 138 | coprevs |
| 139 | copact |
| 140 | coformc 1 |
| 141 | copdiffs coqrev |
| 142 | ret 200 |
| 143 | end |
| 144 | note cottlcut O: after a cut title (more than 256 bytes at gcpool[O..]), when byte O+256 continues a |
| 145 | note UTF-8 character the cut fell inside it: drop that character's first bytes (at most 3) so the |
| 146 | note page title stays valid UTF-8. copttl and coittl call it only for a title over 256 bytes. |
| 147 | fn cottlcut o ulong to void |
| 148 | m = get ftil 0 |
| 149 | for j ulong 3 bound 3 |
| 150 | if gt m 0 |
| 151 | c = get gcpool add o m |
| 152 | if and ge c 128 le c 191 |
| 153 | m = sub m 1 |
| 154 | end |
| 155 | end |
| 156 | end |
| 157 | put ftil 0 m |
| 158 | end |
| 159 | note copttl: the page title carries at most 256 bytes of the title (fti is 256 bytes). The count is |
| 160 | note capped here: a count past the bound is trap 4, which ends the server (exit 104). |
| 161 | fn copttl to void |
| 162 | put ftil 0 0 |
| 163 | o = get gcm 0 |
| 164 | n = get gcm 1 |
| 165 | for k ulong hmin n 256 bound 256 |
| 166 | ftic get gcpool add o k |
| 167 | end |
| 168 | if gt n 256 |
| 169 | cottlcut o |
| 170 | end |
| 171 | for k ulong len tctpat |
| 172 | ftic get tctpat k |
| 173 | end |
| 174 | ftirepo |
| 175 | end |
| 176 | fn copthd to void |
| 177 | fput tcph1 |
| 178 | copoolm 0 |
| 179 | if eq get gcm 1 0 |
| 180 | fput tcnot |
| 181 | end |
| 182 | fput tcph2 |
| 183 | coidh 7 |
| 184 | fput tcph3 |
| 185 | costbadge 1 costate |
| 186 | fput tcph4 |
| 187 | coauth 0 |
| 188 | fput tcph5 |
| 189 | codate get gccts 0 |
| 190 | fput tcmidd |
| 191 | fnum get gcrn 0 |
| 192 | fput tcli6 |
| 193 | if ne get gcrn 0 1 |
| 194 | fputc 115 |
| 195 | end |
| 196 | fput tcph6 |
| 197 | coidh 40 |
| 198 | fput tcph7 |
| 199 | end |
| 200 | fn copverd to void |
| 201 | fput tcvh1 |
| 202 | m = ulong 0 |
| 203 | for r ulong get gcrn 0 |
| 204 | if gt get gcrvl r 0 |
| 205 | copvrow r |
| 206 | m = add m 1 |
| 207 | end |
| 208 | end |
| 209 | for r ulong get gcrn 0 |
| 210 | if ne get gcdw r 100 |
| 211 | copdrow r |
| 212 | end |
| 213 | end |
| 214 | if eq m 0 |
| 215 | fput tcvh2 |
| 216 | end |
| 217 | colisec |
| 218 | copbld |
| 219 | fput tcvh4 |
| 220 | end |
| 221 | note copdrow r: the forge decide word of revision r and its receipt, when one is shown |
| 222 | fn copdrow r ulong to void |
| 223 | fput tcdc1 |
| 224 | d = get gcdw r |
| 225 | if eq d 0 |
| 226 | fput tcdc2 |
| 227 | else |
| 228 | fput tcdc3 |
| 229 | copdword d |
| 230 | end |
| 231 | fput tcdc4 |
| 232 | fnum add r 1 |
| 233 | fput tcvr3 |
| 234 | cohhex r 40 |
| 235 | fput tccodee |
| 236 | if eq get gcrsh r 0 |
| 237 | fput tcdc9 |
| 238 | else |
| 239 | fput tcdc5 |
| 240 | fnum get gcrgc r |
| 241 | fput tcdc6 |
| 242 | fnum get gcrnc r |
| 243 | fput tcdc7 |
| 244 | for k ulong get gcral r bound 256 |
| 245 | fescc get gcrau add mul r 256 k |
| 246 | end |
| 247 | fput tcdc8 |
| 248 | end |
| 249 | fput tcdc10 |
| 250 | end |
| 251 | fn copdword d ulong to void |
| 252 | if eq d 3 |
| 253 | fput tcdw3 |
| 254 | end |
| 255 | if eq d 4 |
| 256 | fput tcdw4 |
| 257 | end |
| 258 | if eq d 5 |
| 259 | fput tcdw5 |
| 260 | end |
| 261 | if eq d 6 |
| 262 | fput tcdw6 |
| 263 | end |
| 264 | if eq d 7 |
| 265 | fput tcdw7 |
| 266 | end |
| 267 | if eq d 8 |
| 268 | fput tcdw8 |
| 269 | end |
| 270 | if eq d 9 |
| 271 | fput tcdw9 |
| 272 | end |
| 273 | if eq d 10 |
| 274 | fput tcdw10 |
| 275 | end |
| 276 | if eq d 11 |
| 277 | fput tcdw11 |
| 278 | end |
| 279 | if eq d 12 |
| 280 | fput tcdw12 |
| 281 | end |
| 282 | if eq d 13 |
| 283 | fput tcdw13 |
| 284 | end |
| 285 | if eq d 14 |
| 286 | fput tcdw14 |
| 287 | end |
| 288 | if eq d 15 |
| 289 | fput tcdw15 |
| 290 | end |
| 291 | if eq d 17 |
| 292 | fput tcdw17 |
| 293 | end |
| 294 | end |
| 295 | note copbld: name the commit the running binary was built from, when it was recorded as 40 hex |
| 296 | fn copbld to void |
| 297 | if cobldok tcbldc |
| 298 | fput tcbl1 |
| 299 | fput tcbldc |
| 300 | fput tcbl2 |
| 301 | ret |
| 302 | end |
| 303 | fput tcbl3 |
| 304 | end |
| 305 | fn cobldok t view uchar * to bool |
| 306 | if ne len t 40 |
| 307 | ret false |
| 308 | end |
| 309 | for i ulong 40 |
| 310 | if eq cohexc get t i false |
| 311 | ret false |
| 312 | end |
| 313 | end |
| 314 | ret true |
| 315 | end |
| 316 | fn copvrow r ulong to void |
| 317 | fput tcvr1 |
| 318 | for k ulong get gcrvl r bound 256 |
| 319 | fescc get gcrvd add mul r 256 k |
| 320 | end |
| 321 | fput tcvr2 |
| 322 | fnum add r 1 |
| 323 | fput tcvr3 |
| 324 | cohhex r 40 |
| 325 | fput tcvr4 |
| 326 | end |
| 327 | fn copmerge to void |
| 328 | for m ulong get gcmn 0 |
| 329 | fput tcmg1 |
| 330 | fnum add get gcmr m 1 |
| 331 | fput tcmg2 |
| 332 | comhex m 40 |
| 333 | fput tcmg3 |
| 334 | coauth get gcmt m |
| 335 | fput tcph5 |
| 336 | codate get gccts get gcmt m |
| 337 | fput tcmg4 |
| 338 | end |
| 339 | end |
| 340 | fn copdesc to void |
| 341 | fput tcdh1 |
| 342 | if eq get gcrn 0 0 |
| 343 | fput tcnodesc |
| 344 | ret |
| 345 | end |
| 346 | n = get gcrd 1 |
| 347 | if eq n 0 |
| 348 | fput tcnodesc |
| 349 | ret |
| 350 | end |
| 351 | comd get gcrd 0 n |
| 352 | end |
| 353 | fn copmeta to void |
| 354 | if gt get gcm 4 0 |
| 355 | fput tclab1 |
| 356 | copoolm 3 |
| 357 | fput tcpend |
| 358 | end |
| 359 | if gt get gcm 6 0 |
| 360 | fput tcasg1 |
| 361 | copoolm 5 |
| 362 | fput tcpend |
| 363 | end |
| 364 | end |
| 365 | fn coprevs to void |
| 366 | fput tcrt1 |
| 367 | for r ulong get gcrn 0 |
| 368 | coprow r |
| 369 | end |
| 370 | fput tcrt4 |
| 371 | end |
| 372 | fn coprow r ulong to void |
| 373 | fput tcrt2 |
| 374 | fnum add r 1 |
| 375 | fput tctd |
| 376 | fput tcah |
| 377 | copatl |
| 378 | coidh 40 |
| 379 | fput tcrq |
| 380 | corhex r 40 |
| 381 | fput tcrfrag |
| 382 | fput tcqg |
| 383 | fput tccode |
| 384 | corhex r 8 |
| 385 | fput tccodee |
| 386 | fput tcae |
| 387 | if eq get gcrx r 1 |
| 388 | fput tcrevr |
| 389 | end |
| 390 | fput tctd |
| 391 | fput tccode |
| 392 | cobhex r 8 |
| 393 | fput tccodee |
| 394 | fput tctd |
| 395 | fput tccode |
| 396 | cohhex r 8 |
| 397 | fput tccodee |
| 398 | fput tctd |
| 399 | coauth get gcrt r |
| 400 | coprow2 r |
| 401 | end |
| 402 | fn coprow2 r ulong to void |
| 403 | fput tctd |
| 404 | codate get gccts get gcrt r |
| 405 | fput tctd |
| 406 | for k ulong get gcrvl r bound 256 |
| 407 | fescc get gcrvd add mul r 256 k |
| 408 | end |
| 409 | fput tcrt3 |
| 410 | end |
| 411 | note ---- activity: every change in causal order with what it did |
| 412 | fn copact to void |
| 413 | fput tcah1 |
| 414 | for ci ulong get gccn 0 |
| 415 | copactc ci |
| 416 | end |
| 417 | fput tcluln |
| 418 | end |
| 419 | fn copactc ci ulong to void |
| 420 | for r ulong get gcrn 0 |
| 421 | if eq get gcrt r ci |
| 422 | coparev ci r |
| 423 | end |
| 424 | end |
| 425 | for w ulong get gcwn 0 |
| 426 | if eq get gcwt w ci |
| 427 | coparvw ci w |
| 428 | end |
| 429 | end |
| 430 | for q ulong get gcqn 0 |
| 431 | if eq get gcqt q ci |
| 432 | copacom ci q |
| 433 | end |
| 434 | end |
| 435 | for m ulong get gcmn 0 |
| 436 | if eq get gcmt m ci |
| 437 | copamrg ci m |
| 438 | end |
| 439 | end |
| 440 | end |
| 441 | fn copahd ci ulong to void |
| 442 | fput tcai1 |
| 443 | coauth ci |
| 444 | end |
| 445 | fn copatl2 ci ulong to void |
| 446 | fput tcph5 |
| 447 | codate get gccts ci |
| 448 | fput tcai2 |
| 449 | end |
| 450 | fn coparev ci ulong r ulong to void |
| 451 | copahd ci |
| 452 | if eq r 0 |
| 453 | fput tcaopen |
| 454 | else |
| 455 | fput tcarev |
| 456 | fnum add r 1 |
| 457 | end |
| 458 | fput tcahead |
| 459 | cohhex r 8 |
| 460 | fput tcacc |
| 461 | copatl2 ci |
| 462 | fput tcai3 |
| 463 | end |
| 464 | fn coparvw ci ulong w ulong to void |
| 465 | copahd ci |
| 466 | fput tcarevw |
| 467 | copnum get gcwr w |
| 468 | if eq get gcwv w 1 |
| 469 | fput tcaacc |
| 470 | end |
| 471 | if eq get gcwv w 2 |
| 472 | fput tcarej |
| 473 | end |
| 474 | copatl2 ci |
| 475 | n = get gcws add mul w 2 1 |
| 476 | if gt n 0 |
| 477 | comd get gcws mul w 2 n |
| 478 | end |
| 479 | fput tcai3 |
| 480 | end |
| 481 | fn copnum r ulong to void |
| 482 | if lt r 64 |
| 483 | fnum add r 1 |
| 484 | else |
| 485 | fputc 63 |
| 486 | end |
| 487 | end |
| 488 | fn copacom ci ulong q ulong to void |
| 489 | copahd ci |
| 490 | r = get gcqr q |
| 491 | if eq r 9999 |
| 492 | fput tcacomx |
| 493 | else |
| 494 | fput tcacom |
| 495 | copnum r |
| 496 | end |
| 497 | copatl2 ci |
| 498 | if eq get gcqx q 1 |
| 499 | fput tcaredc |
| 500 | else |
| 501 | comd get gcqs mul q 2 get gcqs add mul q 2 1 |
| 502 | end |
| 503 | fput tcai3 |
| 504 | end |
| 505 | fn copamrg ci ulong m ulong to void |
| 506 | copahd ci |
| 507 | fput tcamrg |
| 508 | copnum get gcmr m |
| 509 | fput tcaat |
| 510 | comhex m 8 |
| 511 | fput tcacc |
| 512 | copatl2 ci |
| 513 | fput tcai3 |
| 514 | end |
| 515 | note ---- the diff of one revision |
| 516 | note coqrev: the revision named by ?rev=<4..40 hex prefix of a revision id>, else the newest not redacted (9999 none) |
| 517 | fn coqrev to ulong |
| 518 | n = fqget tcrevq |
| 519 | if ge n 4 |
| 520 | r = coqrevp ulong n |
| 521 | if lt r 64 |
| 522 | ret r |
| 523 | end |
| 524 | end |
| 525 | k = get gcrn 0 |
| 526 | for i ulong k |
| 527 | r = sub sub k i 1 |
| 528 | if eq get gcrx r 0 |
| 529 | ret r |
| 530 | end |
| 531 | end |
| 532 | ret ulong 9999 |
| 533 | end |
| 534 | fn coqrevp n ulong to ulong |
| 535 | if gt n 40 |
| 536 | ret ulong 9999 |
| 537 | end |
| 538 | m = ulong 0 |
| 539 | w = ulong 9999 |
| 540 | for r ulong get gcrn 0 |
| 541 | if coqrevm r n |
| 542 | m = add m 1 |
| 543 | w = r |
| 544 | end |
| 545 | end |
| 546 | if eq m 1 |
| 547 | ret w |
| 548 | end |
| 549 | ret ulong 9999 |
| 550 | end |
| 551 | fn coqrevm r ulong n ulong to bool |
| 552 | for k ulong n |
| 553 | if ne get gcrv add mul r 40 k get fval k |
| 554 | ret false |
| 555 | end |
| 556 | end |
| 557 | ret true |
| 558 | end |
| 559 | note cokdiff r st: argv git diff <base> <head> -- for revision r (st: with --stat) |
| 560 | fn cokdiff r ulong st bool to void |
| 561 | fkgit |
| 562 | fka tcdiff |
| 563 | fka tcnocol |
| 564 | fka tcnoext |
| 565 | fka tcoptm |
| 566 | if st |
| 567 | fka tcstat |
| 568 | end |
| 569 | fkopen |
| 570 | for k ulong 40 |
| 571 | fkc get gcrb add mul r 40 k |
| 572 | end |
| 573 | fkopen |
| 574 | for k ulong 40 |
| 575 | fkc get gcro add mul r 40 k |
| 576 | end |
| 577 | fka tcdd |
| 578 | end |
| 579 | fn copdiffs r ulong to void |
| 580 | if gt r 63 |
| 581 | fput tcdfnone |
| 582 | ret |
| 583 | end |
| 584 | fput tcdf1 |
| 585 | fnum add r 1 |
| 586 | fput tcdf2 |
| 587 | cobhex r 8 |
| 588 | fput tcdf3 |
| 589 | cohhex r 8 |
| 590 | fput tcdf4 |
| 591 | copatl |
| 592 | coidh 40 |
| 593 | fput tcdsuf |
| 594 | fput tcrq |
| 595 | corhex r 40 |
| 596 | fput tcdf5 |
| 597 | cokdiff r true |
| 598 | x = fexec 10000000000 |
| 599 | if ne x 0 |
| 600 | copdferr x |
| 601 | ret |
| 602 | end |
| 603 | fput tcpre1 |
| 604 | fxesc 0 get fxol 0 |
| 605 | fput tcpre2 |
| 606 | cokdiff r false |
| 607 | x = fexec 10000000000 |
| 608 | if ne x 0 |
| 609 | copdferr x |
| 610 | ret |
| 611 | end |
| 612 | copdiffr |
| 613 | end |
| 614 | fn copdferr x long to void |
| 615 | fput tcdferr |
| 616 | if lt x 0 |
| 617 | fputc 45 |
| 618 | fnum ulong sub 0 x |
| 619 | else |
| 620 | fnum ulong x |
| 621 | end |
| 622 | fputc 41 |
| 623 | fput tcpend |
| 624 | end |
| 625 | note copdiffr: fxo holds a unified diff; colour +/- lines, hunk and file headers; stop at 1 MiB |
| 626 | fn copdiffr to void |
| 627 | n = get fxol 0 |
| 628 | c = n |
| 629 | if gt c 1048576 |
| 630 | c = ulong 1048576 |
| 631 | end |
| 632 | fput tcpre1 |
| 633 | p = ulong 0 |
| 634 | while lt p c bound 16777216 |
| 635 | q = coeol p n |
| 636 | copdline p q |
| 637 | p = add q 1 |
| 638 | end |
| 639 | fput tcpre2 |
| 640 | if or gt n c gt get fxotr 0 0 |
| 641 | fput tcdfcut |
| 642 | end |
| 643 | end |
| 644 | fn copdline a ulong b ulong to void |
| 645 | k = copdkind a b |
| 646 | if eq k 1 |
| 647 | fput tcspok |
| 648 | end |
| 649 | if eq k 2 |
| 650 | fput tcspbad |
| 651 | end |
| 652 | if eq k 3 |
| 653 | fput tcspmut |
| 654 | end |
| 655 | if eq k 4 |
| 656 | fput tcbon |
| 657 | end |
| 658 | fxesc a sub b a |
| 659 | if eq k 4 |
| 660 | fput tcboff |
| 661 | else |
| 662 | if gt k 0 |
| 663 | fput tcspend |
| 664 | end |
| 665 | end |
| 666 | fputc 10 |
| 667 | end |
| 668 | note copdkind: 1 added 2 removed 3 hunk header 4 file header (diff/---/+++/rename/index) 0 context |
| 669 | fn copdkind a ulong b ulong to ulong |
| 670 | if ge a b |
| 671 | ret ulong 0 |
| 672 | end |
| 673 | c = get fxo a |
| 674 | if eq c 64 |
| 675 | ret ulong 3 |
| 676 | end |
| 677 | if eq c 100 |
| 678 | ret ulong 4 |
| 679 | end |
| 680 | if and eq c 43 copd3 a b 43 |
| 681 | ret ulong 4 |
| 682 | end |
| 683 | if and eq c 45 copd3 a b 45 |
| 684 | ret ulong 4 |
| 685 | end |
| 686 | if eq c 43 |
| 687 | ret ulong 1 |
| 688 | end |
| 689 | if eq c 45 |
| 690 | ret ulong 2 |
| 691 | end |
| 692 | ret ulong 0 |
| 693 | end |
| 694 | note copd3: the line starts with three bytes c and a space (a --- or +++ file line) |
| 695 | fn copd3 a ulong b ulong c uchar to bool |
| 696 | if lt sub b a 4 |
| 697 | ret false |
| 698 | end |
| 699 | if ne get fxo add a 1 c |
| 700 | ret false |
| 701 | end |
| 702 | if ne get fxo add a 2 c |
| 703 | ret false |
| 704 | end |
| 705 | ret eq get fxo add a 3 32 |
| 706 | end |
| 707 | note copraw: /patches/<id>.diff[?rev=] as text/plain. git diff --full-index writes the whole diff |
| 708 | note (--output) to <tfdata>collab/<rid>/<base>-<head>.full.diff once (temporary name, then rename). |
| 709 | note Full object ids, not git's growing abbreviation, so a later commit cannot change the bytes. |
| 710 | note The .full.diff name leaves an older abbreviated .diff file unread. The server streams it (kind 3). |
| 711 | text tccoll "collab" |
| 712 | text tctmpx ".tmp" |
| 713 | text tcoutp "--output=" |
| 714 | global gccf uchar 4096 |
| 715 | global gccfl ulong 1 |
| 716 | fn copraw to long |
| 717 | if eq corefs 1 false |
| 718 | ret 500 |
| 719 | end |
| 720 | if eq coresolve false |
| 721 | ret 404 |
| 722 | end |
| 723 | if eq coload 1 false |
| 724 | ret 404 |
| 725 | end |
| 726 | if ne get gcov 0 0 |
| 727 | fincut |
| 728 | ret 500 |
| 729 | end |
| 730 | r = coqrev |
| 731 | if gt r 63 |
| 732 | ret 404 |
| 733 | end |
| 734 | if eq copfin r false |
| 735 | ret 500 |
| 736 | end |
| 737 | if ge cocsize 0 |
| 738 | coctouch |
| 739 | else |
| 740 | x = copbuild r |
| 741 | if ne x 200 |
| 742 | ret x |
| 743 | end |
| 744 | end |
| 745 | put fkind 0 3 |
| 746 | fsetct tcctxt |
| 747 | put ffilel 0 0 |
| 748 | for i ulong get gccfl 0 bound 4096 |
| 749 | ffilc get gccf i |
| 750 | end |
| 751 | ret 200 |
| 752 | end |
| 753 | note copfin r: gccf = <tfdata>collab/<rid>/<base>-<head>.full.diff, creating the two directories |
| 754 | fn copfin r ulong to bool |
| 755 | fpb |
| 756 | fpt tfdata |
| 757 | fpt tccoll |
| 758 | x = makedir fpth 0 get fpthl 0 448 |
| 759 | fpc 47 |
| 760 | for i ulong get fridl 0 bound 64 |
| 761 | fpc get frid i |
| 762 | end |
| 763 | x = makedir fpth 0 get fpthl 0 448 |
| 764 | if and ne x 0 ne x -17 |
| 765 | ret false |
| 766 | end |
| 767 | fpc 47 |
| 768 | o = mul r 40 |
| 769 | for k ulong 40 |
| 770 | fpc get gcrb add o k |
| 771 | end |
| 772 | fpc 45 |
| 773 | for k ulong 40 |
| 774 | fpc get gcro add o k |
| 775 | end |
| 776 | fpt tccach |
| 777 | n = get fpthl 0 |
| 778 | for i ulong n bound 4096 |
| 779 | put gccf i get fpth i |
| 780 | end |
| 781 | put gccfl 0 n |
| 782 | ret true |
| 783 | end |
| 784 | note copbuild r: generate the raw diff of revision r into the cache, refuse one over cocfmax, then |
| 785 | note evict least recently used diffs until the cache is at or under cocap |
| 786 | text tcdfbig "<p class=\"bad\">This diff is larger than 512 MiB, the most the forge keeps. Clone the repository and run git diff locally.</p>\n" |
| 787 | fn copbuild r ulong to long |
| 788 | x = copgen r |
| 789 | if ne x 0 |
| 790 | ret 500 |
| 791 | end |
| 792 | s = cocsize |
| 793 | if gt s long cocfmax |
| 794 | y = unlink gccf 0 get gccfl 0 |
| 795 | fput tcdfbig |
| 796 | ret 500 |
| 797 | end |
| 798 | cocevict |
| 799 | if lt cocsize 0 |
| 800 | ret 500 |
| 801 | end |
| 802 | ret 200 |
| 803 | end |
| 804 | note copgen r: run git diff --output=<gccf>.<pid>.tmp, then rename it to gccf; 0 on success |
| 805 | fn copgen r ulong to long |
| 806 | fpb |
| 807 | for i ulong get gccfl 0 bound 4096 |
| 808 | fpc get gccf i |
| 809 | end |
| 810 | fpc 46 |
| 811 | copdec ulong getpid |
| 812 | fpt tctmpx |
| 813 | cokdiffo r |
| 814 | x = fexec 60000000000 |
| 815 | if ne x 0 |
| 816 | y = unlink fpth 0 get fpthl 0 |
| 817 | ret -1 |
| 818 | end |
| 819 | fkb |
| 820 | fkopen |
| 821 | for i ulong get fpthl 0 bound 4096 |
| 822 | fkc get fpth i |
| 823 | end |
| 824 | fkopen |
| 825 | for i ulong get gccfl 0 bound 4096 |
| 826 | fkc get gccf i |
| 827 | end |
| 828 | x = renames fpk 0 get fpkl 0 0 |
| 829 | if ne x 0 |
| 830 | y = unlink fpth 0 get fpthl 0 |
| 831 | ret x |
| 832 | end |
| 833 | ret 0 |
| 834 | end |
| 835 | fn copdec v ulong to void |
| 836 | d = new uchar 20 0 |
| 837 | i = ulong 20 |
| 838 | x = v |
| 839 | for it ulong 20 |
| 840 | i = sub i 1 |
| 841 | put d i uchar add rem x 10 48 |
| 842 | x = div x 10 |
| 843 | if eq x 0 |
| 844 | break |
| 845 | end |
| 846 | end |
| 847 | for k ulong sub 20 i bound 20 |
| 848 | fpc get d add i k |
| 849 | end |
| 850 | end |
| 851 | note cokdiffo r: argv git diff --full-index --output=<fpth> <base> <head> -- for revision r |
| 852 | fn cokdiffo r ulong to void |
| 853 | fkgit |
| 854 | fka tcdiff |
| 855 | fka tcnocol |
| 856 | fka tcnoext |
| 857 | fka tcfull |
| 858 | fka tcoptm |
| 859 | fkopen |
| 860 | fkt tcoutp |
| 861 | for i ulong get fpthl 0 bound 4096 |
| 862 | fkc get fpth i |
| 863 | end |
| 864 | o = mul r 40 |
| 865 | fkopen |
| 866 | for k ulong 40 |
| 867 | fkc get gcrb add o k |
| 868 | end |
| 869 | fkopen |
| 870 | for k ulong 40 |
| 871 | fkc get gcro add o k |
| 872 | end |
| 873 | fka tcdd |
| 874 | end |