ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/svn2cvs/svn2cvs
Revision: 1.1
Committed: Mon Sep 30 00:29:31 2024 UTC (6 months, 3 weeks ago) by yakumo_izuru
Branch: MAIN
Log Message:
Initial release

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 exec -ignorestderr svn up "$svn" -r "$rev"
15 exec -ignorestderr cvs up -d "$cvs"
16
17 proc rescan {path prefix} {
18 global svn cvs cache old
19 foreach name [glob -tails -nocomplain -directory "$path" *] {
20 if { [file type "$path/$name"] == "directory" } {
21 if { ! [file exists "$cvs/$prefix/$name"] } {
22 file mkdir "$cvs/$prefix/$name"
23 file mkdir "$cache/$prefix/$name"
24 cd "$cvs"
25 exec -ignorestderr cvs add "[string range "$prefix/$name" 1 [string length "$prefix/$name"]]"
26 cd "$old"
27 }
28 rescan "$path/$name" "$prefix/$name"
29 } else {
30 set new 0
31 if { ! [file exists "$cvs/$prefix/$name"] } {
32 set new 1
33 }
34 if { $new } {
35 puts "New file: `$prefix/$name'"
36 file copy -force "$path/$name" "$cvs/$prefix/$name"
37 file copy -force "$path/$name" "$cache/$prefix/$name"
38 cd "$cvs"
39 exec -ignorestderr cvs add "[string range "$prefix/$name" 1 [string length "$prefix/$name"]]"
40 cd "$old"
41 } else {
42 set hash1 [::sha2::sha256 -hex -filename "$path/$name"]
43 set hash2 [::sha2::sha256 -hex -filename "$cache/$prefix/$name"]
44 if { $hash1 != $hash2 } {
45 puts "Modified: `$prefix/$name'"
46 file copy -force "$path/$name" "$cvs/$prefix/$name"
47 file copy -force "$path/$name" "$cache/$prefix/$name"
48 } else {
49 puts "Not modified: `$prefix/$name'"
50 }
51 }
52 }
53 }
54 }
55
56 proc remove_left {path prefix} {
57 global svn cvs cache old
58 foreach name [glob -tails -nocomplain -directory "$path" *] {
59 if { [file type "$path/$name"] == "directory" } {
60 if { "$name" != "CVS" } {
61 remove_left "$path/$name" "$prefix/$name"
62 }
63 } else {
64 if { [file exists "$cvs/$prefix/$name"] && ![file exists "$svn/$prefix/$name"] } {
65 cd "$cvs"
66 file delete "[string range "$prefix/$name" 1 [string length "$prefix/$name"]]"
67 exec -ignorestderr cvs rm "[string range "$prefix/$name" 1 [string length "$prefix/$name"]]"
68 cd "$old"
69 file delete "$cache/$prefix/$name"
70
71 }
72 }
73 }
74 }
75
76 rescan "$svn" ""
77 remove_left "$cvs" ""
78
79 cd "$cvs"
80 exec -ignorestderr cvs ci -m "$log"
81 cd "$old"
82
83 if { [regexp -- {\[release ([^\]]+)\]} "$log" -> ver] } {
84 cd "$cvs"
85 exec -ignorestderr cvs tag "v[regsub -all -- {\.} "$ver" {_}]"
86 cd "$old"
87 }
88
89 puts "This commit was: $log"