--- svn2cvs 2024/09/30 00:29:31 1.1 +++ svn2cvs 2024/10/09 11:58:36 1.4 @@ -11,18 +11,21 @@ set rev "[lindex $argv 3]" set old "[pwd]" set log [exec svn log --incremental "$svn" -r "$rev" | tail -n1] +set added "" +set removed "" + exec -ignorestderr svn up "$svn" -r "$rev" exec -ignorestderr cvs up -d "$cvs" proc rescan {path prefix} { - global svn cvs cache old + global svn cvs cache old added foreach name [glob -tails -nocomplain -directory "$path" *] { if { [file type "$path/$name"] == "directory" } { if { ! [file exists "$cvs/$prefix/$name"] } { file mkdir "$cvs/$prefix/$name" file mkdir "$cache/$prefix/$name" cd "$cvs" - exec -ignorestderr cvs add "[string range "$prefix/$name" 1 [string length "$prefix/$name"]]" + lappend added "[string range "$prefix/$name" 1 [string length "$prefix/$name"]]" cd "$old" } rescan "$path/$name" "$prefix/$name" @@ -36,7 +39,7 @@ proc rescan {path prefix} { file copy -force "$path/$name" "$cvs/$prefix/$name" file copy -force "$path/$name" "$cache/$prefix/$name" cd "$cvs" - exec -ignorestderr cvs add "[string range "$prefix/$name" 1 [string length "$prefix/$name"]]" + lappend added "[string range "$prefix/$name" 1 [string length "$prefix/$name"]]" cd "$old" } else { set hash1 [::sha2::sha256 -hex -filename "$path/$name"] @@ -54,7 +57,7 @@ proc rescan {path prefix} { } proc remove_left {path prefix} { - global svn cvs cache old + global svn cvs cache old removed foreach name [glob -tails -nocomplain -directory "$path" *] { if { [file type "$path/$name"] == "directory" } { if { "$name" != "CVS" } { @@ -64,7 +67,7 @@ proc remove_left {path prefix} { if { [file exists "$cvs/$prefix/$name"] && ![file exists "$svn/$prefix/$name"] } { cd "$cvs" file delete "[string range "$prefix/$name" 1 [string length "$prefix/$name"]]" - exec -ignorestderr cvs rm "[string range "$prefix/$name" 1 [string length "$prefix/$name"]]" + lappend removed "[string range "$prefix/$name" 1 [string length "$prefix/$name"]]" cd "$old" file delete "$cache/$prefix/$name" @@ -77,6 +80,12 @@ rescan "$svn" "" remove_left "$cvs" "" cd "$cvs" +if { "$added" != "" } { + exec -ignorestderr cvs add $added >/dev/stdout 2>@1 +} +if { "$removed" != "" } { + exec -ignorestderr cvs rm $removed >/dev/stdout 2>@1 +} exec -ignorestderr cvs ci -m "$log" cd "$old"