interplane.Get Omega
Read in your language

interplane-forge

INTERPLANE Forge

Brought by drakestapleton

branch main Branches Tags History

interplane-forge / collab / co4pat.om

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