Fossil SCM

Unhacked the fossil backend. IOW reworked the API and made it nicer, more structured, better command and option names. Gave the internals more structure, and simplified the handling of -breakat (old -stopat breakpoint). Updated users, and updated the user visible switches as well. Added a -h switch for help.

aku 2007-09-13 08:02 trunk
Commit 7b2619b7ef45faa0c4b3b56858db692691a9e688
--- tools/import-cvs.tcl
+++ tools/import-cvs.tcl
@@ -66,15 +66,16 @@
6666
set verbosity 0
6767
6868
clinit
6969
while {[string match "-*" [set opt [this]]]} {
7070
switch -exact -- $opt {
71
- --nosign { import::configure -nosign 1 }
72
- --debugcommit { import::configure -debugcommit 1 }
73
- --stopat { next ; import::configure -stopat [this] }
71
+ --breakat { next ; import::configure -breakat [this] }
72
+ --nosign { import::configure -nosign 1 }
73
+ --saveto { next ; import::configure -saveto [file normalize [this]] }
7474
-v { incr verbosity ; ::vc::tools::log::verbosity $verbosity }
75
- default usage
75
+ -h -
76
+ default usage
7677
}
7778
next
7879
}
7980
8081
remainder
@@ -119,15 +120,21 @@
119120
return
120121
}
121122
122123
proc usage {{text {}}} {
123124
global argv0
124
- puts stderr "Usage: $argv0 ?--nosign? ?-v? ?--stopat id? ?--debugcommit? cvs-repository fossil-repository"
125
- if {$text eq ""} return
126
- puts stderr " $text"
125
+ puts stderr "Usage: $argv0 ?-v? ?--nosign? ?--breakat id? ?--saveto path? cvs-repository fossil-repository"
126
+ if {$text eq ""} {
127
+ puts stderr " --nosign: Do not sign the imported changesets."
128
+ puts stderr " --breakat: Stop just before committing the identified changeset."
129
+ puts stderr " --saveto: Save commit command to the specified file."
130
+ puts stderr " -v: Increase log verbosity. Can be used multiple times."
131
+ } else {
132
+ puts stderr " $text"
133
+ }
127134
exit
128135
}
129136
130137
# -----------------------------------------------------------------------------
131138
132139
main
133140
exit
134141
--- tools/import-cvs.tcl
+++ tools/import-cvs.tcl
@@ -66,15 +66,16 @@
66 set verbosity 0
67
68 clinit
69 while {[string match "-*" [set opt [this]]]} {
70 switch -exact -- $opt {
71 --nosign { import::configure -nosign 1 }
72 --debugcommit { import::configure -debugcommit 1 }
73 --stopat { next ; import::configure -stopat [this] }
74 -v { incr verbosity ; ::vc::tools::log::verbosity $verbosity }
75 default usage
 
76 }
77 next
78 }
79
80 remainder
@@ -119,15 +120,21 @@
119 return
120 }
121
122 proc usage {{text {}}} {
123 global argv0
124 puts stderr "Usage: $argv0 ?--nosign? ?-v? ?--stopat id? ?--debugcommit? cvs-repository fossil-repository"
125 if {$text eq ""} return
126 puts stderr " $text"
 
 
 
 
 
 
127 exit
128 }
129
130 # -----------------------------------------------------------------------------
131
132 main
133 exit
134
--- tools/import-cvs.tcl
+++ tools/import-cvs.tcl
@@ -66,15 +66,16 @@
66 set verbosity 0
67
68 clinit
69 while {[string match "-*" [set opt [this]]]} {
70 switch -exact -- $opt {
71 --breakat { next ; import::configure -breakat [this] }
72 --nosign { import::configure -nosign 1 }
73 --saveto { next ; import::configure -saveto [file normalize [this]] }
74 -v { incr verbosity ; ::vc::tools::log::verbosity $verbosity }
75 -h -
76 default usage
77 }
78 next
79 }
80
81 remainder
@@ -119,15 +120,21 @@
120 return
121 }
122
123 proc usage {{text {}}} {
124 global argv0
125 puts stderr "Usage: $argv0 ?-v? ?--nosign? ?--breakat id? ?--saveto path? cvs-repository fossil-repository"
126 if {$text eq ""} {
127 puts stderr " --nosign: Do not sign the imported changesets."
128 puts stderr " --breakat: Stop just before committing the identified changeset."
129 puts stderr " --saveto: Save commit command to the specified file."
130 puts stderr " -v: Increase log verbosity. Can be used multiple times."
131 } else {
132 puts stderr " $text"
133 }
134 exit
135 }
136
137 # -----------------------------------------------------------------------------
138
139 main
140 exit
141
--- tools/lib/fossil.tcl
+++ tools/lib/fossil.tcl
@@ -16,109 +16,86 @@
1616
}
1717
1818
# -----------------------------------------------------------------------------
1919
# API
2020
21
-# Define repository file, and connect to workspace in CWD.
22
-
23
-proc ::vc::fossil::ws::new {} {
24
- variable fr [file normalize [fileutil::tempfile import2_fsl_rp_]]
25
-
26
- # pwd = workspace
27
- dova new $fr ; # create and
28
- dova open $fr ; # connect
29
-
30
- write 0 fossil "Repository: $fr"
31
-
32
- return $fr
33
-}
34
-
35
-# Move generated fossil repository to final destination
36
-
37
-proc ::vc::fossil::ws::destination {path} {
38
- variable fr
39
- file rename $fr $path
40
- return
41
-}
42
-
43
-namespace eval ::vc::fossil::ws {
44
- # Repository file
45
- variable fr {}
46
-
47
- # Debug the commit command (write a Tcl script containing the
48
- # exact command used). And the file the data goes to.
49
- variable debugcommit 0
50
- variable dcfile {}
51
-}
52
-
53
-proc ::vc::fossil::ws::debugcommit {flag} {
54
- variable debugcommit $flag
55
- if {$debugcommit} {
56
- variable dcfile [file normalize cvs2fossil_commit.tcl]
57
- }
58
- return
59
-}
60
-
61
-proc ::vc::fossil::ws::commit {break appname nosign meta ignore} {
62
- variable lastuuid
63
- variable debugcommit
64
- variable dcfile
21
+# vc::fossil::ws::configure key value - Configure the subsystem.
22
+# vc::fossil::ws::begin src - Start new workspace for directory
23
+# vc::fossil::ws::done dst - Close workspace and copy to destination.
24
+# vc::fossil::ws::commit cset usr time msg - Look for changes and commit as new revision.
25
+
26
+# Configuration keys:
27
+#
28
+# -nosign bool default 0 (= sign imported changesets)
29
+# -breakat num default empty, no breakpoint.
30
+# Otherwise stop before committing the identified changeset.
31
+# -saveto path default empty, no saving.
32
+# Otherwise save the commit command to a file.
33
+# -appname string Default empty. Text to add to all commit messages.
34
+# -ignore cmdprefix Command to check if a file is relevant to the commit or not.
35
+# Signature: cmdprefix path -> bool; true => ignore.
36
+
37
+# -----------------------------------------------------------------------------
38
+# API Implementation
39
+
40
+proc ::vc::fossil::ws::configure {key value} {
41
+ variable nosign
42
+ variable breakat
43
+ variable saveto
44
+ variable appname
45
+ variable ignore
46
+
47
+ switch -exact -- $key {
48
+ -appname { set appname $value }
49
+ -breakat { set breakat $value }
50
+ -ignore { set ignore $value }
51
+ -nosign {
52
+ if {![string is boolean -strict $value]} {
53
+ return -code error "Expected boolean, got \"$value\""
54
+ }
55
+ set nosign $value
56
+ }
57
+ -saveto { set saveto $value }
58
+ default {
59
+ return -code error "Unknown switch $key, expected one of \
60
+ -appname, -breakat, -ignore, -nosign, or -saveto"
61
+ }
62
+ }
63
+ return
64
+}
65
+
66
+proc ::vc::fossil::ws::begin {origin} {
67
+ variable rp [file normalize [fileutil::tempfile import2_fsl_rp_]]
68
+
69
+ cd $origin
70
+ dova new $rp ; # create and ...
71
+ dova open $rp ; # ... connect
72
+
73
+ write 0 fossil "Repository: $rp"
74
+ return
75
+}
76
+
77
+proc ::vc::fossil::ws::done {destination} {
78
+ variable rp
79
+ file rename -force $rp $destination
80
+ set rp {}
81
+ return
82
+}
83
+
84
+proc ::vc::fossil::ws::commit {cset user timestamp message} {
85
+ variable lastuuid
6586
6687
# Commit the current state of the workspace. Scan for new and
6788
# removed files and issue the appropriate fossil add/rm commands
6889
# before actually comitting.
6990
70
- # Modified/Removed files first, that way there won't be any ADDED
71
- # indicators. Nor REMOVED, only EDITED. Removed files show up as
72
- # EDITED while they are not registered as removed.
73
-
74
- set added 0
75
- set removed 0
76
- set changed 0
77
-
78
- foreach line [split [dova changes] \n] {
79
- regsub {^\s*EDITED\s*} $line {} path
80
- if {[IGNORE $ignore $path]} continue
81
-
82
- if {![file exists $path]} {
83
- dova rm $path
84
- incr removed
85
- write 2 fossil "- $path"
86
- } else {
87
- incr changed
88
- write 2 fossil "* $path"
89
- }
90
- }
91
-
92
- # Now look for unregistered added files.
93
-
94
- foreach path [split [dova extra] \n] {
95
- if {[IGNORE $ignore $path]} continue
96
- dova add $path
97
- incr added
98
- write 2 fossil "+ $path"
99
- }
91
+ HandleChanges added removed changed
10092
10193
# Now commit, using the provided meta data, and capture the uuid
10294
# of the new baseline.
10395
104
- foreach {user message tstamp} $meta break
105
-
106
- set message [join [list \
107
- "-- Originally by $user @ $tstamp" \
108
- "-- Imported by $appname" \
109
- $message] \n]
110
-
111
- set cmd [list commit -m $message]
112
- if {$nosign} { lappend cmd --nosign }
113
-
114
- if {$debugcommit} {
115
- fileutil::writeFile $dcfile "$cmd\n"
116
- }
117
-
118
- # Stop, do not actually commit.
119
- if {$break} return
96
+ set cmd [Command $cset [Message $user $timestamp $message]]
12097
12198
if {[catch {
12299
do $cmd
123100
} line]} {
124101
if {![string match "*nothing has changed*" $line]} {
@@ -133,28 +110,106 @@
133110
write 1 fossil "UNCHANGED, keeping last"
134111
135112
return [list $lastuuid 0 0 0]
136113
}
137114
138
- set line [string trim $line]
139
- regsub -nocase -- {^\s*New_Version:\s*} $line {} uuid
115
+ # Extract the uuid of the new revision.
116
+ regsub -nocase -- {^\s*New_Version:\s*} [string trim $line] {} uuid
140117
141118
set lastuuid $uuid
142119
return [list $uuid $added $removed $changed]
143120
}
144121
145122
# -----------------------------------------------------------------------------
146
-# Internal helper commands
123
+# Internal helper commands, and data structures.
124
+
125
+proc ::vc::fossil::ws::HandleChanges {av rv cv} {
126
+ upvar 1 $av added $rv removed $cv changed
127
+
128
+ set added 0
129
+ set removed 0
130
+ set changed 0
131
+
132
+ # Look for modified/removed files first, that way there won't be
133
+ # any ADDED indicators. Nor REMOVED, only EDITED. Removed files
134
+ # show up as EDITED while they are not registered as removed.
135
+
136
+ foreach line [split [do changes] \n] {
137
+ regsub {^\s*EDITED\s*} $line {} path
138
+ if {[Ignore $path]} continue
139
+
140
+ if {![file exists $path]} {
141
+ dova rm $path
142
+ incr removed
143
+ write 2 fossil "- $path"
144
+ } else {
145
+ incr changed
146
+ write 2 fossil "* $path"
147
+ }
148
+ }
149
+
150
+ # Now look for unregistered added files.
151
+
152
+ foreach path [split [do extra] \n] {
153
+ if {[Ignore $path]} continue
154
+ dova add $path
155
+ incr added
156
+ write 2 fossil "+ $path"
157
+ }
158
+
159
+ return
160
+}
161
+
162
+proc ::vc::fossil::ws::Message {user timestamp message} {
163
+ variable appname
164
+ set lines {}
165
+ lappend lines "-- Originally by $user @ $timestamp"
166
+ if {$appname ne ""} {
167
+ lappend lines "-- Imported by $appname"
168
+ }
169
+ lappend lines [string trim $message]
170
+ return [join $lines \n]
171
+}
172
+
173
+proc ::vc::fossil::ws::Command {cset message} {
174
+ variable nosign
175
+ variable saveto
176
+ variable breakat
177
+
178
+ set cmd [list commit -m $message]
179
+
180
+ if {$nosign} { lappend cmd --nosign }
181
+ if {$saveto ne ""} { fileutil::writeFile $saveto "$cmd\n" }
182
+
183
+ if {$breakat eq $cset} {
184
+ write 0 fossil Stopped.
185
+ exit 0
186
+ }
187
+
188
+ return $cmd
189
+}
147190
148
-proc ::vc::fossil::ws::IGNORE {ignore path} {
191
+proc ::vc::fossil::ws::Ignore {path} {
192
+ variable ignore
193
+ if {![llength $ignore]} {return 0}
149194
return [uplevel #0 [linsert $ignore end $path]]
150195
}
151196
152197
namespace eval ::vc::fossil::ws {
153
- namespace export new destination debugcommit commit
198
+ # Configuration settings.
199
+ variable nosign 0 ; # Sign imported changesets
200
+ variable breakat {} ; # Do not stop
201
+ variable saveto {} ; # Do not save commit message
202
+ variable appname {} ; # Name of importer application using the package.
203
+ variable ignore {} ; # No files to ignore.
204
+
205
+ variable rp {} ; # Repository the package works on.
206
+ variable lastuuid {} ; # Uuid of last imported changeset.
207
+
208
+ namespace export configure begin done commit
154209
}
155210
156211
# -----------------------------------------------------------------------------
157212
# Ready
158213
159214
package provide vc::fossil::ws 1.0
160215
return
161216
--- tools/lib/fossil.tcl
+++ tools/lib/fossil.tcl
@@ -16,109 +16,86 @@
16 }
17
18 # -----------------------------------------------------------------------------
19 # API
20
21 # Define repository file, and connect to workspace in CWD.
22
23 proc ::vc::fossil::ws::new {} {
24 variable fr [file normalize [fileutil::tempfile import2_fsl_rp_]]
25
26 # pwd = workspace
27 dova new $fr ; # create and
28 dova open $fr ; # connect
29
30 write 0 fossil "Repository: $fr"
31
32 return $fr
33 }
34
35 # Move generated fossil repository to final destination
36
37 proc ::vc::fossil::ws::destination {path} {
38 variable fr
39 file rename $fr $path
40 return
41 }
42
43 namespace eval ::vc::fossil::ws {
44 # Repository file
45 variable fr {}
46
47 # Debug the commit command (write a Tcl script containing the
48 # exact command used). And the file the data goes to.
49 variable debugcommit 0
50 variable dcfile {}
51 }
52
53 proc ::vc::fossil::ws::debugcommit {flag} {
54 variable debugcommit $flag
55 if {$debugcommit} {
56 variable dcfile [file normalize cvs2fossil_commit.tcl]
57 }
58 return
59 }
60
61 proc ::vc::fossil::ws::commit {break appname nosign meta ignore} {
62 variable lastuuid
63 variable debugcommit
64 variable dcfile
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
66 # Commit the current state of the workspace. Scan for new and
67 # removed files and issue the appropriate fossil add/rm commands
68 # before actually comitting.
69
70 # Modified/Removed files first, that way there won't be any ADDED
71 # indicators. Nor REMOVED, only EDITED. Removed files show up as
72 # EDITED while they are not registered as removed.
73
74 set added 0
75 set removed 0
76 set changed 0
77
78 foreach line [split [dova changes] \n] {
79 regsub {^\s*EDITED\s*} $line {} path
80 if {[IGNORE $ignore $path]} continue
81
82 if {![file exists $path]} {
83 dova rm $path
84 incr removed
85 write 2 fossil "- $path"
86 } else {
87 incr changed
88 write 2 fossil "* $path"
89 }
90 }
91
92 # Now look for unregistered added files.
93
94 foreach path [split [dova extra] \n] {
95 if {[IGNORE $ignore $path]} continue
96 dova add $path
97 incr added
98 write 2 fossil "+ $path"
99 }
100
101 # Now commit, using the provided meta data, and capture the uuid
102 # of the new baseline.
103
104 foreach {user message tstamp} $meta break
105
106 set message [join [list \
107 "-- Originally by $user @ $tstamp" \
108 "-- Imported by $appname" \
109 $message] \n]
110
111 set cmd [list commit -m $message]
112 if {$nosign} { lappend cmd --nosign }
113
114 if {$debugcommit} {
115 fileutil::writeFile $dcfile "$cmd\n"
116 }
117
118 # Stop, do not actually commit.
119 if {$break} return
120
121 if {[catch {
122 do $cmd
123 } line]} {
124 if {![string match "*nothing has changed*" $line]} {
@@ -133,28 +110,106 @@
133 write 1 fossil "UNCHANGED, keeping last"
134
135 return [list $lastuuid 0 0 0]
136 }
137
138 set line [string trim $line]
139 regsub -nocase -- {^\s*New_Version:\s*} $line {} uuid
140
141 set lastuuid $uuid
142 return [list $uuid $added $removed $changed]
143 }
144
145 # -----------------------------------------------------------------------------
146 # Internal helper commands
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
148 proc ::vc::fossil::ws::IGNORE {ignore path} {
 
 
149 return [uplevel #0 [linsert $ignore end $path]]
150 }
151
152 namespace eval ::vc::fossil::ws {
153 namespace export new destination debugcommit commit
 
 
 
 
 
 
 
 
 
 
154 }
155
156 # -----------------------------------------------------------------------------
157 # Ready
158
159 package provide vc::fossil::ws 1.0
160 return
161
--- tools/lib/fossil.tcl
+++ tools/lib/fossil.tcl
@@ -16,109 +16,86 @@
16 }
17
18 # -----------------------------------------------------------------------------
19 # API
20
21 # vc::fossil::ws::configure key value - Configure the subsystem.
22 # vc::fossil::ws::begin src - Start new workspace for directory
23 # vc::fossil::ws::done dst - Close workspace and copy to destination.
24 # vc::fossil::ws::commit cset usr time msg - Look for changes and commit as new revision.
25
26 # Configuration keys:
27 #
28 # -nosign bool default 0 (= sign imported changesets)
29 # -breakat num default empty, no breakpoint.
30 # Otherwise stop before committing the identified changeset.
31 # -saveto path default empty, no saving.
32 # Otherwise save the commit command to a file.
33 # -appname string Default empty. Text to add to all commit messages.
34 # -ignore cmdprefix Command to check if a file is relevant to the commit or not.
35 # Signature: cmdprefix path -> bool; true => ignore.
36
37 # -----------------------------------------------------------------------------
38 # API Implementation
39
40 proc ::vc::fossil::ws::configure {key value} {
41 variable nosign
42 variable breakat
43 variable saveto
44 variable appname
45 variable ignore
46
47 switch -exact -- $key {
48 -appname { set appname $value }
49 -breakat { set breakat $value }
50 -ignore { set ignore $value }
51 -nosign {
52 if {![string is boolean -strict $value]} {
53 return -code error "Expected boolean, got \"$value\""
54 }
55 set nosign $value
56 }
57 -saveto { set saveto $value }
58 default {
59 return -code error "Unknown switch $key, expected one of \
60 -appname, -breakat, -ignore, -nosign, or -saveto"
61 }
62 }
63 return
64 }
65
66 proc ::vc::fossil::ws::begin {origin} {
67 variable rp [file normalize [fileutil::tempfile import2_fsl_rp_]]
68
69 cd $origin
70 dova new $rp ; # create and ...
71 dova open $rp ; # ... connect
72
73 write 0 fossil "Repository: $rp"
74 return
75 }
76
77 proc ::vc::fossil::ws::done {destination} {
78 variable rp
79 file rename -force $rp $destination
80 set rp {}
81 return
82 }
83
84 proc ::vc::fossil::ws::commit {cset user timestamp message} {
85 variable lastuuid
86
87 # Commit the current state of the workspace. Scan for new and
88 # removed files and issue the appropriate fossil add/rm commands
89 # before actually comitting.
90
91 HandleChanges added removed changed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
93 # Now commit, using the provided meta data, and capture the uuid
94 # of the new baseline.
95
96 set cmd [Command $cset [Message $user $timestamp $message]]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
98 if {[catch {
99 do $cmd
100 } line]} {
101 if {![string match "*nothing has changed*" $line]} {
@@ -133,28 +110,106 @@
110 write 1 fossil "UNCHANGED, keeping last"
111
112 return [list $lastuuid 0 0 0]
113 }
114
115 # Extract the uuid of the new revision.
116 regsub -nocase -- {^\s*New_Version:\s*} [string trim $line] {} uuid
117
118 set lastuuid $uuid
119 return [list $uuid $added $removed $changed]
120 }
121
122 # -----------------------------------------------------------------------------
123 # Internal helper commands, and data structures.
124
125 proc ::vc::fossil::ws::HandleChanges {av rv cv} {
126 upvar 1 $av added $rv removed $cv changed
127
128 set added 0
129 set removed 0
130 set changed 0
131
132 # Look for modified/removed files first, that way there won't be
133 # any ADDED indicators. Nor REMOVED, only EDITED. Removed files
134 # show up as EDITED while they are not registered as removed.
135
136 foreach line [split [do changes] \n] {
137 regsub {^\s*EDITED\s*} $line {} path
138 if {[Ignore $path]} continue
139
140 if {![file exists $path]} {
141 dova rm $path
142 incr removed
143 write 2 fossil "- $path"
144 } else {
145 incr changed
146 write 2 fossil "* $path"
147 }
148 }
149
150 # Now look for unregistered added files.
151
152 foreach path [split [do extra] \n] {
153 if {[Ignore $path]} continue
154 dova add $path
155 incr added
156 write 2 fossil "+ $path"
157 }
158
159 return
160 }
161
162 proc ::vc::fossil::ws::Message {user timestamp message} {
163 variable appname
164 set lines {}
165 lappend lines "-- Originally by $user @ $timestamp"
166 if {$appname ne ""} {
167 lappend lines "-- Imported by $appname"
168 }
169 lappend lines [string trim $message]
170 return [join $lines \n]
171 }
172
173 proc ::vc::fossil::ws::Command {cset message} {
174 variable nosign
175 variable saveto
176 variable breakat
177
178 set cmd [list commit -m $message]
179
180 if {$nosign} { lappend cmd --nosign }
181 if {$saveto ne ""} { fileutil::writeFile $saveto "$cmd\n" }
182
183 if {$breakat eq $cset} {
184 write 0 fossil Stopped.
185 exit 0
186 }
187
188 return $cmd
189 }
190
191 proc ::vc::fossil::ws::Ignore {path} {
192 variable ignore
193 if {![llength $ignore]} {return 0}
194 return [uplevel #0 [linsert $ignore end $path]]
195 }
196
197 namespace eval ::vc::fossil::ws {
198 # Configuration settings.
199 variable nosign 0 ; # Sign imported changesets
200 variable breakat {} ; # Do not stop
201 variable saveto {} ; # Do not save commit message
202 variable appname {} ; # Name of importer application using the package.
203 variable ignore {} ; # No files to ignore.
204
205 variable rp {} ; # Repository the package works on.
206 variable lastuuid {} ; # Uuid of last imported changeset.
207
208 namespace export configure begin done commit
209 }
210
211 # -----------------------------------------------------------------------------
212 # Ready
213
214 package provide vc::fossil::ws 1.0
215 return
216
--- tools/lib/importcvs.tcl
+++ tools/lib/importcvs.tcl
@@ -12,10 +12,13 @@
1212
namespace eval ::vc::fossil::import::cvs {
1313
vc::tools::log::system import
1414
namespace import ::vc::tools::log::write
1515
namespace eval cvs { namespace import ::vc::cvs::ws::* }
1616
namespace eval fossil { namespace import ::vc::fossil::ws::* }
17
+
18
+ fossil::configure -appname cvs2fossil
19
+ fossil::configure -ignore ::vc::cvs::ws::wsignore
1720
}
1821
1922
# -----------------------------------------------------------------------------
2023
# API
2124
@@ -22,54 +25,39 @@
2225
# Configuration
2326
#
2427
# vc::fossil::import::cvs::configure key value - Set configuration
2528
#
2629
# Legal keys: -nosign <bool>, default false
27
-# -debugcommit <bool>, default false
28
-# -stopat <int>, default :none:
30
+# -breakat <int>, default :none:
31
+# -saveto <path>, default :none:
2932
#
3033
# Functionality
3134
#
3235
# vc::fossil::import::cvs::run src dst - Perform an import.
3336
3437
# -----------------------------------------------------------------------------
3538
# API Implementation - Functionality
3639
3740
proc ::vc::fossil::import::cvs::configure {key value} {
38
- variable nosign
39
- variable stopat
40
-
41
+ # The options are simply passed through to the fossil importer
42
+ # backend.
4143
switch -exact -- $key {
42
- -debugcommit {
43
- if {![string is boolean -strict $value]} {
44
- return -code error "Expected boolean, got \"$value\""
45
- }
46
- fossil::debugcommit $value
47
- }
48
- -nosign {
49
- if {![string is boolean -strict $value]} {
50
- return -code error "Expected boolean, got \"$value\""
51
- }
52
- set nosign $value
53
- }
54
- -stopat {
55
- set stopat $value
56
- }
44
+ -breakat { fossil::configure -breakat $value }
45
+ -nosign { fossil::configure -nosign $value }
46
+ -saveto { fossil::configure -saveto $value }
5747
default {
5848
return -code error "Unknown switch $key, expected one of \
59
- -debugcommit, -nosign, or -stopat"
49
+ -breakat, -nosign, or -saveto"
6050
}
6151
}
6252
return
6353
}
6454
6555
# Import the CVS repository found at directory 'src' into the new
6656
# fossil repository at 'dst'.
6757
6858
proc ::vc::fossil::import::cvs::run {src dst} {
69
- variable stopat
70
-
7159
cvs::at $src ; # Define location of CVS repository
7260
cvs::scan ; # Gather revision data from the archives
7361
cvs::csets ; # Group changes into sets
7462
cvs::rtree ; # Build revision tree (trunk only right now).
7563
@@ -77,12 +65,12 @@
7765
set nto 0
7866
7967
write 0 import {Begin conversion}
8068
write 0 import {Setting up workspaces}
8169
82
- cvs::workspace ; # cd's to workspace
83
- fossil::new ; # Uses cwd as workspace to connect to.
70
+ cvs::workspace ; # cd's to workspace
71
+ fossil::begin [pwd] ; # Uses cwd as workspace to connect to.
8472
8573
set ntrunk [cvs::ntrunk] ; set ntfmt %[string length $ntrunk]s
8674
set nmax [cvs::ncsets] ; set nmfmt %[string length $nmax]s
8775
8876
cvs::foreach_cset cset [cvs::root] {
@@ -92,14 +80,12 @@
9280
9381
write 0 import "========= [string repeat = 61]"
9482
write 0 import "Imported $nto [expr {($nto == 1) ? "changeset" : "changesets"}]"
9583
write 0 import "Within [format %.2f $tot] seconds (avg [format %.2f [expr {$tot/$nto}]] seconds/changeset)"
9684
97
- if {$stopat == $cset} return
98
-
9985
cvs::wsclear
100
- fossil::destination $dst
86
+ fossil::close $dst
10187
write 0 import Ok.
10288
return
10389
}
10490
10591
# -----------------------------------------------------------------------------
@@ -124,25 +110,13 @@
124110
write 3 import "st rem [format %7.2f $rem] sec [format %6.2f [expr {$rem/60}]] min [format %5.2f [expr {$rem/3600}]] hr"
125111
return
126112
}
127113
128114
proc ::vc::fossil::import::cvs::OneChangeSet {cset} {
129
- variable nosign
130
- variable stopat
131
-
132
- if {$stopat == $cset} {
133
- fossil::commit 1 cvs2fossil $nosign \
134
- [cvs::wssetup $cset] ::vc::cvs::ws::wsignore
135
- write 0 import Stopped.
136
- return -code break
137
- }
138
-
139115
set usec [lindex [time {
140
- foreach {uuid ad rm ch} \
141
- [fossil::commit 0 cvs2fossil $nosign \
142
- [cvs::wssetup $cset] ::vc::cvs::ws::wsignore] \
143
- break
116
+ foreach {user message timestamp} [cvs::wssetup $cset] break
117
+ foreach {uuid ad rm ch} [fossil::commit $cset $user $timestamp $message] break
144118
} 1] 0]
145119
cvs::uuid $cset $uuid
146120
147121
set sec [expr {$usec/1e6}]
148122
@@ -153,17 +127,13 @@
153127
}
154128
155129
# -----------------------------------------------------------------------------
156130
157131
namespace eval ::vc::fossil::import::cvs {
158
- variable debugcommit 0 ; # Debug the commit operation.
159
- variable nosign 0 ; # Require signing
160
- variable stopat {} ; # Stop nowhere
161
-
162132
namespace export run configure
163133
}
164134
165135
# -----------------------------------------------------------------------------
166136
# Ready
167137
168138
package provide vc::fossil::import::cvs 1.0
169139
return
170140
--- tools/lib/importcvs.tcl
+++ tools/lib/importcvs.tcl
@@ -12,10 +12,13 @@
12 namespace eval ::vc::fossil::import::cvs {
13 vc::tools::log::system import
14 namespace import ::vc::tools::log::write
15 namespace eval cvs { namespace import ::vc::cvs::ws::* }
16 namespace eval fossil { namespace import ::vc::fossil::ws::* }
 
 
 
17 }
18
19 # -----------------------------------------------------------------------------
20 # API
21
@@ -22,54 +25,39 @@
22 # Configuration
23 #
24 # vc::fossil::import::cvs::configure key value - Set configuration
25 #
26 # Legal keys: -nosign <bool>, default false
27 # -debugcommit <bool>, default false
28 # -stopat <int>, default :none:
29 #
30 # Functionality
31 #
32 # vc::fossil::import::cvs::run src dst - Perform an import.
33
34 # -----------------------------------------------------------------------------
35 # API Implementation - Functionality
36
37 proc ::vc::fossil::import::cvs::configure {key value} {
38 variable nosign
39 variable stopat
40
41 switch -exact -- $key {
42 -debugcommit {
43 if {![string is boolean -strict $value]} {
44 return -code error "Expected boolean, got \"$value\""
45 }
46 fossil::debugcommit $value
47 }
48 -nosign {
49 if {![string is boolean -strict $value]} {
50 return -code error "Expected boolean, got \"$value\""
51 }
52 set nosign $value
53 }
54 -stopat {
55 set stopat $value
56 }
57 default {
58 return -code error "Unknown switch $key, expected one of \
59 -debugcommit, -nosign, or -stopat"
60 }
61 }
62 return
63 }
64
65 # Import the CVS repository found at directory 'src' into the new
66 # fossil repository at 'dst'.
67
68 proc ::vc::fossil::import::cvs::run {src dst} {
69 variable stopat
70
71 cvs::at $src ; # Define location of CVS repository
72 cvs::scan ; # Gather revision data from the archives
73 cvs::csets ; # Group changes into sets
74 cvs::rtree ; # Build revision tree (trunk only right now).
75
@@ -77,12 +65,12 @@
77 set nto 0
78
79 write 0 import {Begin conversion}
80 write 0 import {Setting up workspaces}
81
82 cvs::workspace ; # cd's to workspace
83 fossil::new ; # Uses cwd as workspace to connect to.
84
85 set ntrunk [cvs::ntrunk] ; set ntfmt %[string length $ntrunk]s
86 set nmax [cvs::ncsets] ; set nmfmt %[string length $nmax]s
87
88 cvs::foreach_cset cset [cvs::root] {
@@ -92,14 +80,12 @@
92
93 write 0 import "========= [string repeat = 61]"
94 write 0 import "Imported $nto [expr {($nto == 1) ? "changeset" : "changesets"}]"
95 write 0 import "Within [format %.2f $tot] seconds (avg [format %.2f [expr {$tot/$nto}]] seconds/changeset)"
96
97 if {$stopat == $cset} return
98
99 cvs::wsclear
100 fossil::destination $dst
101 write 0 import Ok.
102 return
103 }
104
105 # -----------------------------------------------------------------------------
@@ -124,25 +110,13 @@
124 write 3 import "st rem [format %7.2f $rem] sec [format %6.2f [expr {$rem/60}]] min [format %5.2f [expr {$rem/3600}]] hr"
125 return
126 }
127
128 proc ::vc::fossil::import::cvs::OneChangeSet {cset} {
129 variable nosign
130 variable stopat
131
132 if {$stopat == $cset} {
133 fossil::commit 1 cvs2fossil $nosign \
134 [cvs::wssetup $cset] ::vc::cvs::ws::wsignore
135 write 0 import Stopped.
136 return -code break
137 }
138
139 set usec [lindex [time {
140 foreach {uuid ad rm ch} \
141 [fossil::commit 0 cvs2fossil $nosign \
142 [cvs::wssetup $cset] ::vc::cvs::ws::wsignore] \
143 break
144 } 1] 0]
145 cvs::uuid $cset $uuid
146
147 set sec [expr {$usec/1e6}]
148
@@ -153,17 +127,13 @@
153 }
154
155 # -----------------------------------------------------------------------------
156
157 namespace eval ::vc::fossil::import::cvs {
158 variable debugcommit 0 ; # Debug the commit operation.
159 variable nosign 0 ; # Require signing
160 variable stopat {} ; # Stop nowhere
161
162 namespace export run configure
163 }
164
165 # -----------------------------------------------------------------------------
166 # Ready
167
168 package provide vc::fossil::import::cvs 1.0
169 return
170
--- tools/lib/importcvs.tcl
+++ tools/lib/importcvs.tcl
@@ -12,10 +12,13 @@
12 namespace eval ::vc::fossil::import::cvs {
13 vc::tools::log::system import
14 namespace import ::vc::tools::log::write
15 namespace eval cvs { namespace import ::vc::cvs::ws::* }
16 namespace eval fossil { namespace import ::vc::fossil::ws::* }
17
18 fossil::configure -appname cvs2fossil
19 fossil::configure -ignore ::vc::cvs::ws::wsignore
20 }
21
22 # -----------------------------------------------------------------------------
23 # API
24
@@ -22,54 +25,39 @@
25 # Configuration
26 #
27 # vc::fossil::import::cvs::configure key value - Set configuration
28 #
29 # Legal keys: -nosign <bool>, default false
30 # -breakat <int>, default :none:
31 # -saveto <path>, default :none:
32 #
33 # Functionality
34 #
35 # vc::fossil::import::cvs::run src dst - Perform an import.
36
37 # -----------------------------------------------------------------------------
38 # API Implementation - Functionality
39
40 proc ::vc::fossil::import::cvs::configure {key value} {
41 # The options are simply passed through to the fossil importer
42 # backend.
 
43 switch -exact -- $key {
44 -breakat { fossil::configure -breakat $value }
45 -nosign { fossil::configure -nosign $value }
46 -saveto { fossil::configure -saveto $value }
 
 
 
 
 
 
 
 
 
 
 
 
47 default {
48 return -code error "Unknown switch $key, expected one of \
49 -breakat, -nosign, or -saveto"
50 }
51 }
52 return
53 }
54
55 # Import the CVS repository found at directory 'src' into the new
56 # fossil repository at 'dst'.
57
58 proc ::vc::fossil::import::cvs::run {src dst} {
 
 
59 cvs::at $src ; # Define location of CVS repository
60 cvs::scan ; # Gather revision data from the archives
61 cvs::csets ; # Group changes into sets
62 cvs::rtree ; # Build revision tree (trunk only right now).
63
@@ -77,12 +65,12 @@
65 set nto 0
66
67 write 0 import {Begin conversion}
68 write 0 import {Setting up workspaces}
69
70 cvs::workspace ; # cd's to workspace
71 fossil::begin [pwd] ; # Uses cwd as workspace to connect to.
72
73 set ntrunk [cvs::ntrunk] ; set ntfmt %[string length $ntrunk]s
74 set nmax [cvs::ncsets] ; set nmfmt %[string length $nmax]s
75
76 cvs::foreach_cset cset [cvs::root] {
@@ -92,14 +80,12 @@
80
81 write 0 import "========= [string repeat = 61]"
82 write 0 import "Imported $nto [expr {($nto == 1) ? "changeset" : "changesets"}]"
83 write 0 import "Within [format %.2f $tot] seconds (avg [format %.2f [expr {$tot/$nto}]] seconds/changeset)"
84
 
 
85 cvs::wsclear
86 fossil::close $dst
87 write 0 import Ok.
88 return
89 }
90
91 # -----------------------------------------------------------------------------
@@ -124,25 +110,13 @@
110 write 3 import "st rem [format %7.2f $rem] sec [format %6.2f [expr {$rem/60}]] min [format %5.2f [expr {$rem/3600}]] hr"
111 return
112 }
113
114 proc ::vc::fossil::import::cvs::OneChangeSet {cset} {
 
 
 
 
 
 
 
 
 
 
115 set usec [lindex [time {
116 foreach {user message timestamp} [cvs::wssetup $cset] break
117 foreach {uuid ad rm ch} [fossil::commit $cset $user $timestamp $message] break
 
 
118 } 1] 0]
119 cvs::uuid $cset $uuid
120
121 set sec [expr {$usec/1e6}]
122
@@ -153,17 +127,13 @@
127 }
128
129 # -----------------------------------------------------------------------------
130
131 namespace eval ::vc::fossil::import::cvs {
 
 
 
 
132 namespace export run configure
133 }
134
135 # -----------------------------------------------------------------------------
136 # Ready
137
138 package provide vc::fossil::import::cvs 1.0
139 return
140

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button