73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
;; 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
;;
|
|
>
|
|
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
;; 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 cmdnum cherrypick do-commit backout hide usedate recomment user comment timestamp timestamp_sec)
(set! result `((uuid . ,rowkey)
(tag0 . ,tag0)
(cmdnum . ,cmdnum)
(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,cmdnum,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
;;
|
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
|
(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 "#======= Start of cherrypick for " uuid "=======")
(print "fossil up " targ)
(print "fossil merge --cherrypick " uuid)
(if #t ;;(member do-commit '("x" "yes"))
(print "fossil commit -m '" (escape-string-for-bash comment) "' "
(if (equal? usedate "no")
""
(conc " --date-override '" nodedate "'"))
" --user-override " user
" --private"))
(print "if [[ $(fossil status | grep CONFLICT | wc -l) -gt 0 ]];then")
(print " echo HAVE CONFLICT - STOPPING")
(print " exit 1")
(print "else")
(print " echo GOOD, marking node " uuid " as DONE")
(print " refdb set " dbfname " timeline " uuid " status DONE")
(print "fi")
(print "#======= end of cherrypick for " uuid "=======")
(print "")
))
;;
(define (gen-rebase-commands dbname)
(let* ((sqldbname (conc "/tmp/" (current-user-name) "-" dbname ".db"))
(dbfname (conc (current-directory) "/" dbname))) ;; want the fully qualified path so we can call the generated script from anywhere
(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 dbfname))
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!!
Usage: fossilrebase cmd [params ...]
where cmd is one of:
|
|
|
|
>
>
>
>
>
>
>
>
>
>
|
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
|
(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 "#======= Start of cherrypick for " uuid "=======")
(print "fossil checkout " targ)
(print "fossil merge --cherrypick " uuid)
(if #t ;;(member do-commit '("x" "yes"))
(print "fossil commit -m '" (escape-string-for-bash comment) "' "
(if (equal? usedate "no")
""
(conc " --date-override '" nodedate "'"))
" --user-override " user
))
(print "if [[ $(fossil status | grep CONFLICT | wc -l) -gt 0 ]];then")
(print " echo HAVE CONFLICT - STOPPING")
(print " exit 1")
(print "else")
(print " echo GOOD, marking node " uuid " as DONE")
(print " refdb set " dbfname " timeline " uuid " status DONE")
(print "fi")
(print "#======= end of cherrypick for " uuid "=======")
(print "")
))
;;
(define (gen-rebase-commands dbname)
(let* ((sqldbname (conc "/tmp/" (current-user-name) "-" dbname ".db"))
(dbfname (conc (current-directory) "/" dbname))) ;; want the fully qualified path so we can call the generated script from anywhere
(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 setup
(dump-setup 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 dbfname))
cherrypicks)
)))
(define (dump-setup db)
(for-each-row
(lambda (cmd)
(print cmd))
db
"SELECT command FROM 'setup' ORDER BY rowkey ASC;"))
(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!!
Usage: fossilrebase cmd [params ...]
where cmd is one of:
|