Index: fossil-utils/fossilrebase.scm ================================================================== --- fossil-utils/fossilrebase.scm +++ fossil-utils/fossilrebase.scm @@ -1,6 +1,6 @@ -(use yaml matchable srfi-1) +(use yaml matchable srfi-1 sqlite3) (define (get-timeline) (let* ((inp (open-input-pipe "fossil json timeline checkin -n 0")) (res (yaml-load inp))) (close-input-pipe inp) @@ -64,10 +64,144 @@ (refdb-set-value dbname "extra" uuid "parents" (string-intersperse (get-val rec "parents") ",")) (refdb-set-value dbname "timeline" uuid "timestamp" (seconds->std-time-str (get-val rec "timestamp"))) (refdb-set-value dbname "timeline" uuid "timestamp_sec" (any->string (get-val rec "timestamp"))) )))) timeline)))) + +;; tag0 tag1 tag2 cherrypick backout hide usedate recomment user +;; comment timestamp timestamp_sec +;; +(define (get-node-details db node-id) + (let* ((result #f) + (count 0)) + (for-each-row + (lambda (rowkey tag0 cherrypick do-commit backout hide usedate recomment user comment timestamp timestamp_sec) + (set! result `((uuid . ,rowkey) + (tag0 . ,tag0) + (cherrypick . ,cherrypick) + (do-commit . ,do-commit) + (backout . ,backout) + (hide . ,hide) + (usedate . ,usedate) + (recomment . ,recomment) + (user . ,user) + (comment . ,comment) + (timestamp . ,timestamp) + (timestamp_sec . ,timestamp_sec))) + (set! count (+ count 1))) + db + "SELECT rowkey,tag0,cherrypick,do_commit,backout,hide,usedate,recomment,user,comment,timestamp,timestamp_sec FROM timeline WHERE rowkey LIKE ?;" + node-id) + (if (> count 1) + (print "WARNING: more than one node matches " node-id ", found " count " nodes")) + result)) + +;; get branches to create +;; +(define (get-new-branches db) + (let* ((res '())) + (for-each-row + (lambda (rowkey node mode) + (set! res (cons `((branch . ,rowkey) + (node . ,node) + (mode . ,mode)) + res))) + db + "SELECT rowkey,node,mode FROM branches;") + res)) + +;; get cherrypicks +;; +(define (get-cherry-picks db) + (let* ((res '())) + (for-each-row + (lambda (rowkey tag0 cherrypick do-commit usedate comment recomment) + (set! res (cons `((uuid . ,rowkey) + (tag0 . ,tag0) + (cherrypick . ,cherrypick) + (do-commit . ,do-commit) + (usedate . ,usedate) + (comment . ,comment) + (recomment . ,recomment)) + res))) + db + "SELECT rowkey,tag0,cherrypick,do_commit,usedate,comment,recomment FROM timeline WHERE cherrypick != '' AND cherrypick NOT NULL;") + res)) + +;; always private and same time as parent node + 1 second +;; +;; fossil branch new BRANCH-NAME BASIS ?OPTIONS? +;; +;; Create a new branch BRANCH-NAME off of check-in BASIS. +;; Supported options for this subcommand include: +;; --private branch is private (i.e., remains local) +;; --bgcolor COLOR use COLOR instead of automatic background +;; --nosign do not sign contents on this branch +;; --date-override DATE DATE to use instead of 'now' +;; --user-override USER USER to use instead of the current default +;; +;; DATE may be "now" or "YYYY-MM-DDTHH:MM:SS.SSS". If in +;; year-month-day form, it may be truncated, the "T" may be +;; replaced by a space, and it may also name a timezone offset +;; from UTC as "-HH:MM" (westward) or "+HH:MM" (eastward). +;; Either no timezone suffix or "Z" means UTC. +;; +(define (create-branch db branch-name parent-node) + (let* ((parent-info (get-node-details db (conc parent-node "%")))) + (if (not parent-info) + (print "ERROR: no info found for node " parent-node) + (let* ((parent-date (alist-ref 'timestamp parent-info)) + (parent-user (alist-ref 'user parent-info))) + (print "fossil branch new " branch-name " " parent-node " --private --date-override '" parent-date "'") + ;; (print "Creating private branch " branch-name " from node " parent-node) + ;; (pp parent-info) + ;; (print "") + )))) + +(define (do-cherrypick db cherrypick) + (let* ((tag0 (alist-ref 'tag0 cherrypick)) + (uuid (alist-ref 'uuid cherrypick)) + (nodeinf (get-node-details db uuid)) + (nodedate (alist-ref 'timestamp nodeinf)) + (user (alist-ref 'user nodeinf)) + (targ (alist-ref 'cherrypick cherrypick)) ;; do fossil up to this node + (do-commit (alist-ref 'do-commit cherrypick)) ;; if yes do a commit + (usedate (alist-ref 'usedate cherrypick)) ;; if no use current time + (comment (alist-ref 'comment cherrypick)) + (recomment (alist-ref 'recomment cherrypick))) + (print "fossil up " targ) + (print "fossil merge --cherrypick " uuid) + (if (member do-commit '("x" "yes")) + (print "fossil commit -m '" comment "' " + (if (equal? usedate "no") + "" + (conc " --date-override '" nodedate "'")) + " --user-override " user + " --private")))) + +;; +(define (gen-rebase-commands dbname) + (let* ((sqldbname (conc dbname ".db"))) + (print "Create sqlite db " sqldbname "...") + (system (conc "refdb dump2sqlite3 " dbname " " sqldbname)) + (let* ((db (open-database sqldbname)) + (branches (get-new-branches db)) + (cherrypicks (get-cherry-picks db))) + ;; create the branches + (for-each + (lambda (branchdat) + (create-branch db + (alist-ref 'branch branchdat) + (alist-ref 'node branchdat))) + branches) + + ;; create the cherrypicks + (for-each + (lambda (cherrypick) + (do-cherrypick db cherrypick)) + cherrypicks) + ))) (define help "fossilrebase - register commits in a refdb, edit them by hand then execute them WARNING: It is highly recommended you do this on a disconnected copy of your fossil database!! @@ -83,12 +217,12 @@ (begin (print help) (exit 1)) (match (command-line-arguments) (("genrefdb" fname branches) (gen-refdb fname branches)) - (("dumpcmds" fname) (dump-cmds)) + (("dumpcmds" fname) (gen-rebase-commands fname)) (else (print "Sorry, didn't know what to do with \"" (string-intersperse (command-line-arguments) " ") "\"") (exit 1))))) (main) Index: fossil-utils/justtesting/sheet-names.cfg ================================================================== --- fossil-utils/justtesting/sheet-names.cfg +++ fossil-utils/justtesting/sheet-names.cfg @@ -1,2 +1,3 @@ timeline extra +branches Index: fossil-utils/justtesting/sxml/_sheets.sxml ================================================================== --- fossil-utils/justtesting/sxml/_sheets.sxml +++ fossil-utils/justtesting/sxml/_sheets.sxml @@ -29,13 +29,13 @@ (urn:oasis:names:tc:opendocument:xmlns:office:1.0:document-meta (@ (urn:oasis:names:tc:opendocument:xmlns:office:1.0:version "1.2")) (urn:oasis:names:tc:opendocument:xmlns:office:1.0:meta (http://purl.org/dc/elements/1.1/:date - "2020-05-29T06:19:57Z") + "2020-05-29T15:48:39Z") (urn:oasis:names:tc:opendocument:xmlns:meta:1.0:creation-date - "2020-05-29T05:57:00Z"))) + "2020-05-29T15:48:27Z"))) (http://www.gnumeric.org/v10.dtd:Calculation (@ (MaxIterations "100") (ManualRecalc "0") (IterationTolerance "0.001") (FloatRadix "2") @@ -47,10 +47,14 @@ (http://www.gnumeric.org/v10.dtd:Cols "256")) "timeline") (http://www.gnumeric.org/v10.dtd:SheetName (@ (http://www.gnumeric.org/v10.dtd:Rows "65536") (http://www.gnumeric.org/v10.dtd:Cols "256")) - "extra")) + "extra") + (http://www.gnumeric.org/v10.dtd:SheetName + (@ (http://www.gnumeric.org/v10.dtd:Rows "65536") + (http://www.gnumeric.org/v10.dtd:Cols "256")) + "branches")) (http://www.gnumeric.org/v10.dtd:Geometry - (@ (Width "1570") (Height "888"))) + (@ (Width "1440") (Height "647"))) (http://www.gnumeric.org/v10.dtd:UIData (@ (SelectedTab "0")))) Index: fossil-utils/justtesting/sxml/timeline.sxml ================================================================== --- fossil-utils/justtesting/sxml/timeline.sxml +++ fossil-utils/justtesting/sxml/timeline.sxml @@ -7,11 +7,11 @@ (HideGrid "0") (HideColHeader "0") (GridColor "0:0:0") (DisplayOutlines "1") (DisplayFormulas "0")) - (http://www.gnumeric.org/v10.dtd:MaxCol "11") + (http://www.gnumeric.org/v10.dtd:MaxCol "14") (http://www.gnumeric.org/v10.dtd:MaxRow "65535") (http://www.gnumeric.org/v10.dtd:Zoom "1") (http://www.gnumeric.org/v10.dtd:Names (http://www.gnumeric.org/v10.dtd:Name (http://www.gnumeric.org/v10.dtd:name @@ -110,17 +110,19 @@ (HardSize "1") (Count "3"))) (http://www.gnumeric.org/v10.dtd:ColInfo (@ (Unit "63.75") (No "4"))) (http://www.gnumeric.org/v10.dtd:ColInfo - (@ (Unit "188.2") (No "7"))) + (@ (Unit "66.75") (No "10") (HardSize "1"))) + (http://www.gnumeric.org/v10.dtd:ColInfo + (@ (Unit "140.2") (No "11") (HardSize "1"))) + (http://www.gnumeric.org/v10.dtd:ColInfo + (@ (Unit "198.8") (No "12") (HardSize "1"))) (http://www.gnumeric.org/v10.dtd:ColInfo - (@ (Unit "198.8") (No "9") (HardSize "1"))) + (@ (Unit "104.2") (No "13"))) (http://www.gnumeric.org/v10.dtd:ColInfo - (@ (Unit "104.2") (No "10"))) - (http://www.gnumeric.org/v10.dtd:ColInfo - (@ (Unit "78.75") (No "11")))) + (@ (Unit "78.75") (No "14")))) (http://www.gnumeric.org/v10.dtd:Rows (@ (DefaultSizePts "12.1")) (http://www.gnumeric.org/v10.dtd:RowInfo (@ (Unit "13.5") (No "0"))) (http://www.gnumeric.org/v10.dtd:RowInfo @@ -168,48 +170,58 @@ (@ (Unit "12.1") (No "445") (Hidden "1") (Count "11"))) (http://www.gnumeric.org/v10.dtd:RowInfo + (@ (Unit "13.5") (No "456"))) + (http://www.gnumeric.org/v10.dtd:RowInfo (@ (Unit "12.1") (No "457") (Hidden "1") (Count "3"))) + (http://www.gnumeric.org/v10.dtd:RowInfo + (@ (Unit "13.5") (No "460") (Count "3"))) (http://www.gnumeric.org/v10.dtd:RowInfo (@ (Unit "12.1") (No "463") (Hidden "1") (Count "4"))) (http://www.gnumeric.org/v10.dtd:RowInfo - (@ (Unit "13.5") (No "468"))) + (@ (Unit "13.5") (No "467") (Count "2"))) + (http://www.gnumeric.org/v10.dtd:RowInfo + (@ (Unit "13.5") (No "470") (Count "9"))) (http://www.gnumeric.org/v10.dtd:RowInfo - (@ (Unit "13.5") (No "474") (Count "4"))) + (@ (Unit "13.5") (No "483"))) (http://www.gnumeric.org/v10.dtd:RowInfo - (@ (Unit "13.5") (No "487"))) + (@ (Unit "13.5") (No "486") (Count "2"))) (http://www.gnumeric.org/v10.dtd:RowInfo (@ (Unit "12.1") (No "488") (Hidden "1"))) (http://www.gnumeric.org/v10.dtd:RowInfo - (@ (Unit "13.5") (No "498"))) + (@ (Unit "13.5") (No "489"))) + (http://www.gnumeric.org/v10.dtd:RowInfo + (@ (Unit "13.5") (No "492"))) + (http://www.gnumeric.org/v10.dtd:RowInfo + (@ (Unit "13.5") (No "498") (Count "2"))) (http://www.gnumeric.org/v10.dtd:RowInfo (@ (Unit "12.1") (No "503") (Hidden "1") (Count "65033")))) (http://www.gnumeric.org/v10.dtd:Selections - (@ (CursorRow "499") (CursorCol "4")) + (@ (CursorRow "421") (CursorCol "6")) (http://www.gnumeric.org/v10.dtd:Selection - (@ (startRow "499") - (startCol "4") - (endRow "499") - (endCol "4")))) + (@ (startRow "421") + (startCol "6") + (endRow "421") + (endCol "6")))) (http://www.gnumeric.org/v10.dtd:SheetLayout - (@ (TopLeft "A2")) + (@ (TopLeft "A422")) (http://www.gnumeric.org/v10.dtd:FreezePanes (@ (UnfrozenTopLeft "A2") (FrozenTopLeft "A1")))) (http://www.gnumeric.org/v10.dtd:Filters (http://www.gnumeric.org/v10.dtd:Filter - (@ (Area "A1:K65536")) + (@ (Area "A1:N65536")) (http://www.gnumeric.org/v10.dtd:Field (@ (ValueType0 "v1.65-newview") (Value0 "60") (Type "expr") (Op0 "eq") Index: fossil-utils/justtesting/timeline.dat ================================================================== --- fossil-utils/justtesting/timeline.dat +++ fossil-utils/justtesting/timeline.dat cannot compute difference between binary files