--- svn2cvs 2024/09/30 00:29:31 1.1 +++ svn2cvs 2024/10/17 10:08:53 1.6 @@ -11,18 +11,22 @@ set rev "[lindex $argv 3]" set old "[pwd]" set log [exec svn log --incremental "$svn" -r "$rev" | tail -n1] +set added "" +set removed "" +set added_dir "" + 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 added_dir 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_dir "[string range "$prefix/$name" 1 [string length "$prefix/$name"]]" cd "$old" } rescan "$path/$name" "$prefix/$name" @@ -36,7 +40,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 +58,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 +68,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 +81,15 @@ rescan "$svn" "" remove_left "$cvs" "" cd "$cvs" +if { "$added_dir" != "" } { + eval exec -ignorestderr cvs add \"[join $added_dir "\" \""]\" >/dev/stdout 2>@1 +} +if { "$added" != "" } { + eval exec -ignorestderr cvs add \"[join $added "\" \""]\" >/dev/stdout 2>@1 +} +if { "$removed" != "" } { + eval exec -ignorestderr cvs rm \"[join $removed "\" \""]\" >/dev/stdout 2>@1 +} exec -ignorestderr cvs ci -m "$log" cd "$old"