ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/svn2cvs/svn2cvs
Revision: 1.2
Committed: Tue Oct 1 02:38:00 2024 UTC (6 weeks, 3 days ago) by nishi
Branch: MAIN
Changes since 1.1: +12 -3 lines
Log Message:
do this instead bc it is just more efficient

File Contents

# Content
1 #!/usr/bin/env tclsh
2 package require sha256
3 if { $argc < 4 } {
4 puts "Usage: $argv0 svn cvs cache svn_revision"
5 exit 1
6 }
7 set svn "[lindex $argv 0]"
8 set cvs "[lindex $argv 1]"
9 set cache "[lindex $argv 2]"
10 set rev "[lindex $argv 3]"
11 set old "[pwd]"
12 set log [exec svn log --incremental "$svn" -r "$rev" | tail -n1]
13
14 set added ""
15 set removed ""
16
17 exec -ignorestderr svn up "$svn" -r "$rev"
18 exec -ignorestderr cvs up -d "$cvs"
19
20 proc rescan {path prefix} {
21 global svn cvs cache old
22 foreach name [glob -tails -nocomplain -directory "$path" *] {
23 if { [file type "$path/$name"] == "directory" } {
24 if { ! [file exists "$cvs/$prefix/$name"] } {
25 file mkdir "$cvs/$prefix/$name"
26 file mkdir "$cache/$prefix/$name"
27 cd "$cvs"
28 lappend added "[string range "$prefix/$name" 1 [string length "$prefix/$name"]]"
29 cd "$old"
30 }
31 rescan "$path/$name" "$prefix/$name"
32 } else {
33 set new 0
34 if { ! [file exists "$cvs/$prefix/$name"] } {
35 set new 1
36 }
37 if { $new } {
38 puts "New file: `$prefix/$name'"
39 file copy -force "$path/$name" "$cvs/$prefix/$name"
40 file copy -force "$path/$name" "$cache/$prefix/$name"
41 cd "$cvs"
42 lappend added "[string range "$prefix/$name" 1 [string length "$prefix/$name"]]"
43 cd "$old"
44 } else {
45 set hash1 [::sha2::sha256 -hex -filename "$path/$name"]
46 set hash2 [::sha2::sha256 -hex -filename "$cache/$prefix/$name"]
47 if { $hash1 != $hash2 } {
48 puts "Modified: `$prefix/$name'"
49 file copy -force "$path/$name" "$cvs/$prefix/$name"
50 file copy -force "$path/$name" "$cache/$prefix/$name"
51 } else {
52 puts "Not modified: `$prefix/$name'"
53 }
54 }
55 }
56 }
57 }
58
59 proc remove_left {path prefix} {
60 global svn cvs cache old
61 foreach name [glob -tails -nocomplain -directory "$path" *] {
62 if { [file type "$path/$name"] == "directory" } {
63 if { "$name" != "CVS" } {
64 remove_left "$path/$name" "$prefix/$name"
65 }
66 } else {
67 if { [file exists "$cvs/$prefix/$name"] && ![file exists "$svn/$prefix/$name"] } {
68 cd "$cvs"
69 file delete "[string range "$prefix/$name" 1 [string length "$prefix/$name"]]"
70 lappend removed "[string range "$prefix/$name" 1 [string length "$prefix/$name"]]"
71 cd "$old"
72 file delete "$cache/$prefix/$name"
73
74 }
75 }
76 }
77 }
78
79 rescan "$svn" ""
80 remove_left "$cvs" ""
81
82 cd "$cvs"
83 if { "$added" != "" } {
84 exec -ignorestderr cvs add \"[join $added "\",\""]\"
85 }
86 if { "$removed" != "" } {
87 exec -ignorestderr cvs rm \"[join $removed "\",\""]\"
88 }
89 exec -ignorestderr cvs ci -m "$log"
90 cd "$old"
91
92 if { [regexp -- {\[release ([^\]]+)\]} "$log" -> ver] } {
93 cd "$cvs"
94 exec -ignorestderr cvs tag "v[regsub -all -- {\.} "$ver" {_}]"
95 cd "$old"
96 }
97
98 puts "This commit was: $log"