On 3/25/2014 1:23 PM, Andy Goth wrote:
I didn't know [fossil addremove] existed.  That would have eliminated
the need for [fossil changes]!  How convenient.

Here's an updated version of the script that uses [fossil addremove].
It also fixes a bug which included the user and tags in the comments.

#!/usr/bin/env tclsh
set repo1 CORRUPT.fossil
set repo2 REBUILT.fossil
proc fossil {args} {
    puts [concat fossil $args]
    exec fossil {*}$args
}
set pwd [pwd]
file mkdir tmp
cd tmp
fossil open [file join $pwd $repo1]
foreach line [split [fossil timeline -t ci -n 0 -W 0] \n] {
    if {![regexp {^=== (\d{4}-\d\d-\d\d) ===$} $line _ date]
     && [regexp {(?x)^(\d\d:\d\d:\d\d)\ \[([[:xdigit:]]+)\]
                 \ (?:\*CURRENT\*\ )?(.*)\ \(user:\ .*\ tags:\ .*\)$}\
                $line _ time version comment]} {
        lappend history [list "$date $time" $version $comment]
    }
}
set date [clock format [clock add [clock scan $date] -1 day]\
        -format %Y-%m-%d]
fossil new --date-override "$date 00:00:00" [file join $pwd $repo2]
file rename .fslckout [file join $pwd repo1.fslckout]
fossil open [file join $pwd $repo2]
file rename .fslckout [file join $pwd repo2.fslckout]
foreach checkin [lreverse $history] {
    lassign $checkin timestamp version comment
    file rename [file join $pwd repo1.fslckout] .fslckout
    fossil update $version
    file rename .fslckout [file join $pwd repo1.fslckout]
    file rename [file join $pwd repo2.fslckout] .fslckout
    fossil addremove
    fossil commit --allow-empty --no-warnings\
            --date-override $timestamp --comment $comment
    file rename .fslckout [file join $pwd repo2.fslckout]
}
file rename [file join $pwd repo1.fslckout] .fslckout
fossil close
file rename [file join $pwd repo2.fslckout] .fslckout
fossil close
cd $pwd
file delete -force tmp
# vim: set sts=4 sw=4 tw=80 et ft=tcl:

--
Andy Goth | <andrew.m.goth/at/gmail/dot/com>
_______________________________________________
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users

Reply via email to