Fossil SCM

Re-added the user feedback and error reporting utilities, with modifications, and completed the handling of the informational options.

aku 2007-10-02 05:33 trunk
Commit d57b7b4a05e30c09737c989fb3c5772a5842bd3e
--- tools/cvs2fossil/lib/c2f_option.tcl
+++ tools/cvs2fossil/lib/c2f_option.tcl
@@ -17,11 +17,12 @@
1717
1818
# # ## ### ##### ######## ############# #####################
1919
## Requirements
2020
2121
package require Tcl 8.4 ; # Required runtime.
22
-package require snit ; # OO system
22
+package require snit ; # OO system.
23
+package require vc::tools::trouble ; # Error reporting.
2324
2425
# # ## ### ##### ######## ############# #####################
2526
##
2627
2728
snit::type ::vc::fossil::import::cvs::option {
@@ -75,12 +76,59 @@
7576
Validate
7677
return
7778
}
7879
7980
# # ## ### ##### ######## #############
80
- ## Internal methods and state
81
+ ## Internal methods, printing information.
82
+
83
+ proc PrintHelp {} {
84
+ global argv0
85
+ trouble info "Usage: $argv0 $usage"
86
+ trouble info ""
87
+ trouble info " Information options"
88
+ trouble info ""
89
+ trouble info " -h, --help Print this message and exit with success"
90
+ trouble info " --help-passes Print list of passes and exit with success"
91
+ trouble info " --version Print version number of $argv0"
92
+ trouble info ""
93
+ # --project, --cache
94
+ # ...
95
+ exit 0
96
+ }
97
+
98
+ proc PrintHelpPasses {} {
99
+ trouble info ""
100
+ trouble info "Conversion passes:"
101
+ trouble info ""
102
+ set n 0
103
+ foreach {p desc} {
104
+ CollectAr {Collect archives}
105
+ CollectRev {Collect revisions}
106
+ } { trouble info " [format %2d $n]: $p $desc" ; incr n }
107
+ trouble info ""
108
+ exit 0
109
+ }
110
+
111
+ proc PrintVersion {} {
112
+ global argv0
113
+ set v [package require vc::fossil::import::cvs]
114
+ trouble info "$argv0 v$v"
115
+ exit 0
116
+ }
117
+
118
+ proc Usage {{text {}}} {
119
+ global argv0
120
+ if {$text ne ""} {set text \n$text}
121
+ trouble fatal "Usage: $argv0 $usage$text"
122
+ # Not reached
123
+ return
124
+ }
125
+
126
+ # # ## ### ##### ######## #############
127
+ ## Internal methods, command line processing
81128
129
+ typevariable usage "?option ?value?...? cvs-repository-path"
82130
typevariable nocvs " The cvs-repository-path is missing."
83131
typevariable badoption " Bad option "
84132
typevariable gethelp " Use --help to get help."
85133
86134
proc IsOption {av _ ov} {
@@ -97,32 +145,31 @@
97145
set v [lindex $arguments 0]
98146
set arguments [lrange $arguments 1 end]
99147
return $v
100148
}
101149
150
+ # # ## ### ##### ######## #############
151
+ ## Internal methods, state validation
152
+
102153
proc Validate {} {
103154
return
104155
}
105156
106
- proc Usage {{text {}}} {
107
- global argv0
108
- if {$text ne ""} {set text \n$text}
109
- #trouble fatal "Usage: $argv0 ?option ?value?...? cvs-repository-path$text"
110
- puts "Usage: $argv0 ?option ?value?...? cvs-repository-path$text"
111
- exit 1
112
- }
113
-
114157
# # ## ### ##### ######## #############
115158
## Configuration
116159
117160
pragma -hasinstances no ; # singleton
118161
pragma -hastypeinfo no ; # no introspection
119162
pragma -hastypedestroy no ; # immortal
120163
121164
# # ## ### ##### ######## #############
122165
}
166
+
167
+namespace eval ::vc::fossil::import::cvs::option {
168
+ namespace import ::vc::tools::trouble
169
+}
123170
124171
# # ## ### ##### ######## ############# #####################
125172
## Ready
126173
127174
package provide vc::fossil::import::cvs::option 1.0
128175
return
129176
130177
ADDED tools/cvs2fossil/lib/log.tcl
--- tools/cvs2fossil/lib/c2f_option.tcl
+++ tools/cvs2fossil/lib/c2f_option.tcl
@@ -17,11 +17,12 @@
17
18 # # ## ### ##### ######## ############# #####################
19 ## Requirements
20
21 package require Tcl 8.4 ; # Required runtime.
22 package require snit ; # OO system
 
23
24 # # ## ### ##### ######## ############# #####################
25 ##
26
27 snit::type ::vc::fossil::import::cvs::option {
@@ -75,12 +76,59 @@
75 Validate
76 return
77 }
78
79 # # ## ### ##### ######## #############
80 ## Internal methods and state
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
 
82 typevariable nocvs " The cvs-repository-path is missing."
83 typevariable badoption " Bad option "
84 typevariable gethelp " Use --help to get help."
85
86 proc IsOption {av _ ov} {
@@ -97,32 +145,31 @@
97 set v [lindex $arguments 0]
98 set arguments [lrange $arguments 1 end]
99 return $v
100 }
101
 
 
 
102 proc Validate {} {
103 return
104 }
105
106 proc Usage {{text {}}} {
107 global argv0
108 if {$text ne ""} {set text \n$text}
109 #trouble fatal "Usage: $argv0 ?option ?value?...? cvs-repository-path$text"
110 puts "Usage: $argv0 ?option ?value?...? cvs-repository-path$text"
111 exit 1
112 }
113
114 # # ## ### ##### ######## #############
115 ## Configuration
116
117 pragma -hasinstances no ; # singleton
118 pragma -hastypeinfo no ; # no introspection
119 pragma -hastypedestroy no ; # immortal
120
121 # # ## ### ##### ######## #############
122 }
 
 
 
 
123
124 # # ## ### ##### ######## ############# #####################
125 ## Ready
126
127 package provide vc::fossil::import::cvs::option 1.0
128 return
129
130 DDED tools/cvs2fossil/lib/log.tcl
--- tools/cvs2fossil/lib/c2f_option.tcl
+++ tools/cvs2fossil/lib/c2f_option.tcl
@@ -17,11 +17,12 @@
17
18 # # ## ### ##### ######## ############# #####################
19 ## Requirements
20
21 package require Tcl 8.4 ; # Required runtime.
22 package require snit ; # OO system.
23 package require vc::tools::trouble ; # Error reporting.
24
25 # # ## ### ##### ######## ############# #####################
26 ##
27
28 snit::type ::vc::fossil::import::cvs::option {
@@ -75,12 +76,59 @@
76 Validate
77 return
78 }
79
80 # # ## ### ##### ######## #############
81 ## Internal methods, printing information.
82
83 proc PrintHelp {} {
84 global argv0
85 trouble info "Usage: $argv0 $usage"
86 trouble info ""
87 trouble info " Information options"
88 trouble info ""
89 trouble info " -h, --help Print this message and exit with success"
90 trouble info " --help-passes Print list of passes and exit with success"
91 trouble info " --version Print version number of $argv0"
92 trouble info ""
93 # --project, --cache
94 # ...
95 exit 0
96 }
97
98 proc PrintHelpPasses {} {
99 trouble info ""
100 trouble info "Conversion passes:"
101 trouble info ""
102 set n 0
103 foreach {p desc} {
104 CollectAr {Collect archives}
105 CollectRev {Collect revisions}
106 } { trouble info " [format %2d $n]: $p $desc" ; incr n }
107 trouble info ""
108 exit 0
109 }
110
111 proc PrintVersion {} {
112 global argv0
113 set v [package require vc::fossil::import::cvs]
114 trouble info "$argv0 v$v"
115 exit 0
116 }
117
118 proc Usage {{text {}}} {
119 global argv0
120 if {$text ne ""} {set text \n$text}
121 trouble fatal "Usage: $argv0 $usage$text"
122 # Not reached
123 return
124 }
125
126 # # ## ### ##### ######## #############
127 ## Internal methods, command line processing
128
129 typevariable usage "?option ?value?...? cvs-repository-path"
130 typevariable nocvs " The cvs-repository-path is missing."
131 typevariable badoption " Bad option "
132 typevariable gethelp " Use --help to get help."
133
134 proc IsOption {av _ ov} {
@@ -97,32 +145,31 @@
145 set v [lindex $arguments 0]
146 set arguments [lrange $arguments 1 end]
147 return $v
148 }
149
150 # # ## ### ##### ######## #############
151 ## Internal methods, state validation
152
153 proc Validate {} {
154 return
155 }
156
 
 
 
 
 
 
 
 
157 # # ## ### ##### ######## #############
158 ## Configuration
159
160 pragma -hasinstances no ; # singleton
161 pragma -hastypeinfo no ; # no introspection
162 pragma -hastypedestroy no ; # immortal
163
164 # # ## ### ##### ######## #############
165 }
166
167 namespace eval ::vc::fossil::import::cvs::option {
168 namespace import ::vc::tools::trouble
169 }
170
171 # # ## ### ##### ######## ############# #####################
172 ## Ready
173
174 package provide vc::fossil::import::cvs::option 1.0
175 return
176
177 DDED tools/cvs2fossil/lib/log.tcl
--- a/tools/cvs2fossil/lib/log.tcl
+++ b/tools/cvs2fossil/lib/log.tcl
@@ -0,0 +1,69 @@
1
+#$text"## -*- tcl -*-
2
+# # ## ### ##### ######## ############# #####################
3
+## Copyright (c) 2007
4
+## Copyright (c) 2007-2008 Andreas Kupries.
5
+#
6
+# This software is licensed as described in the file LICENSE, which
7
+# you should have received as part of this distribution.
8
+#
9
+# This software consists of voluntary contributions made by many
10
+# individuals. For exact contribution history, see the revision
11
+# history and logs, available at http://fossil-scm.hwaci.com/fossil
12
+# # ## ### ##### ######## ############# #####################
13
+
14
+## Utility package, basic user feedback
15
+
16
+# # ## ### ##### ######## ############# #####################
17
+## Requirements
18
+
19
+package require Tcl 8.4 ; # Required runti; # OO system.
20
+## -*- tcl ####### ############# #####################
21
+## Copyright (c) 2007
22
+## Copyright (c) 2007-2008 Andreas Kupries.
23
+#
24
+# This software is licensed as described in the file LICENSE, which
25
+# you should have received as part of this distribution.
26
+#
27
+# This software consists of voluntary contributions made by many
28
+# individuals. For exact contribution history, see the revision
29
+# history and logs, available at http://fossil-scm.hwaci.com/fossil
30
+# # ## ### ##### ######## ############# #####################
31
+
32
+## Utility package,$text# ### ##### ######## #######################
33
+## Requirements
34
+
35
+package require Tcl 8.4 ; # Required runti; # OO system.
36
+## -*- tcl -*-
37
+# # ## ### ##### ######## ############# #####################
38
+## Copyright (c) 2007-2008 Andreas Kupries.
39
+#
40
+# This software is licensed as described in the file LICENSE, whicis software consists of voluntary contribupvar 1 mysysfmte by many
41
+# individuals. For exact contribution history, see the revis ### ##### #######
42
+
43
+## Utility package, basic user feedback
44
+
45
+# # ## ### ##### ######## ############# #####################
46
+## Requirements
47
+
48
+package require Tcl 8.4 ; # Required runtime
49
+package require snit ; # OO system.
50
+package require vc::tools::mem ; # Memory tracking.
51
+
52
+# # ## ### ##### ######## ############# ##################### # # ## ### ##### ######## #############
53
+ ## Public API, Methods
54
+
55
+ # Write the message 'text' to log, for the named 'system'. The
56
+ # message is written if and only if the message verbosity is less
57
+ # or equal the chosen verbosity. A message of verbosity 0 cannot
58
+ # be blocked.
59
+
60
+ typemethod write {verbosity system text} {
61
+ if {$verbosity > $myloglevel} return
62
+ uplevel #0 [linsert $mylogcmd end write [System $system] \
63
+ [uplevel 1 [list ::subst $text]]]
64
+ return
65
+ }
66
+
67
+ # Similar to write, especially in the handling of the verbosity,
68
+ # to drive progress displays. It signals thaputs "l {[^ ]} $m { } b
69
+ puts "$m$system system
--- a/tools/cvs2fossil/lib/log.tcl
+++ b/tools/cvs2fossil/lib/log.tcl
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/tools/cvs2fossil/lib/log.tcl
+++ b/tools/cvs2fossil/lib/log.tcl
@@ -0,0 +1,69 @@
1 #$text"## -*- tcl -*-
2 # # ## ### ##### ######## ############# #####################
3 ## Copyright (c) 2007
4 ## Copyright (c) 2007-2008 Andreas Kupries.
5 #
6 # This software is licensed as described in the file LICENSE, which
7 # you should have received as part of this distribution.
8 #
9 # This software consists of voluntary contributions made by many
10 # individuals. For exact contribution history, see the revision
11 # history and logs, available at http://fossil-scm.hwaci.com/fossil
12 # # ## ### ##### ######## ############# #####################
13
14 ## Utility package, basic user feedback
15
16 # # ## ### ##### ######## ############# #####################
17 ## Requirements
18
19 package require Tcl 8.4 ; # Required runti; # OO system.
20 ## -*- tcl ####### ############# #####################
21 ## Copyright (c) 2007
22 ## Copyright (c) 2007-2008 Andreas Kupries.
23 #
24 # This software is licensed as described in the file LICENSE, which
25 # you should have received as part of this distribution.
26 #
27 # This software consists of voluntary contributions made by many
28 # individuals. For exact contribution history, see the revision
29 # history and logs, available at http://fossil-scm.hwaci.com/fossil
30 # # ## ### ##### ######## ############# #####################
31
32 ## Utility package,$text# ### ##### ######## #######################
33 ## Requirements
34
35 package require Tcl 8.4 ; # Required runti; # OO system.
36 ## -*- tcl -*-
37 # # ## ### ##### ######## ############# #####################
38 ## Copyright (c) 2007-2008 Andreas Kupries.
39 #
40 # This software is licensed as described in the file LICENSE, whicis software consists of voluntary contribupvar 1 mysysfmte by many
41 # individuals. For exact contribution history, see the revis ### ##### #######
42
43 ## Utility package, basic user feedback
44
45 # # ## ### ##### ######## ############# #####################
46 ## Requirements
47
48 package require Tcl 8.4 ; # Required runtime
49 package require snit ; # OO system.
50 package require vc::tools::mem ; # Memory tracking.
51
52 # # ## ### ##### ######## ############# ##################### # # ## ### ##### ######## #############
53 ## Public API, Methods
54
55 # Write the message 'text' to log, for the named 'system'. The
56 # message is written if and only if the message verbosity is less
57 # or equal the chosen verbosity. A message of verbosity 0 cannot
58 # be blocked.
59
60 typemethod write {verbosity system text} {
61 if {$verbosity > $myloglevel} return
62 uplevel #0 [linsert $mylogcmd end write [System $system] \
63 [uplevel 1 [list ::subst $text]]]
64 return
65 }
66
67 # Similar to write, especially in the handling of the verbosity,
68 # to drive progress displays. It signals thaputs "l {[^ ]} $m { } b
69 puts "$m$system system
--- tools/cvs2fossil/lib/pkgIndex.tcl
+++ tools/cvs2fossil/lib/pkgIndex.tcl
@@ -3,5 +3,7 @@
33
## Index of the local packages required by cvs2fossil
44
# # ## ### ##### ######## ############# #####################
55
if {![package vsatisfies [package require Tcl] 8.4]} return
66
package ifneeded vc::fossil::import::cvs 1.0 [list source [file join $dir cvs2fossil.tcl]]
77
package ifneeded vc::fossil::import::cvs::option 1.0 [list source [file join $dir c2f_option.tcl]]
8
+package ifneeded vc::tools::trouble 1.0 [list source [file join $dir trouble.tcl]]
9
+package ifneeded vc::tools::log 1.0 [list source [file join $dir log.tcl]]
810
911
ADDED tools/cvs2fossil/lib/trouble.tcl
--- tools/cvs2fossil/lib/pkgIndex.tcl
+++ tools/cvs2fossil/lib/pkgIndex.tcl
@@ -3,5 +3,7 @@
3 ## Index of the local packages required by cvs2fossil
4 # # ## ### ##### ######## ############# #####################
5 if {![package vsatisfies [package require Tcl] 8.4]} return
6 package ifneeded vc::fossil::import::cvs 1.0 [list source [file join $dir cvs2fossil.tcl]]
7 package ifneeded vc::fossil::import::cvs::option 1.0 [list source [file join $dir c2f_option.tcl]]
 
 
8
9 DDED tools/cvs2fossil/lib/trouble.tcl
--- tools/cvs2fossil/lib/pkgIndex.tcl
+++ tools/cvs2fossil/lib/pkgIndex.tcl
@@ -3,5 +3,7 @@
3 ## Index of the local packages required by cvs2fossil
4 # # ## ### ##### ######## ############# #####################
5 if {![package vsatisfies [package require Tcl] 8.4]} return
6 package ifneeded vc::fossil::import::cvs 1.0 [list source [file join $dir cvs2fossil.tcl]]
7 package ifneeded vc::fossil::import::cvs::option 1.0 [list source [file join $dir c2f_option.tcl]]
8 package ifneeded vc::tools::trouble 1.0 [list source [file join $dir trouble.tcl]]
9 package ifneeded vc::tools::log 1.0 [list source [file join $dir log.tcl]]
10
11 DDED tools/cvs2fossil/lib/trouble.tcl
--- a/tools/cvs2fossil/lib/trouble.tcl
+++ b/tools/cvs2fossil/lib/trouble.tcl
@@ -0,0 +1,2 @@
1
+## -*- tcl -*-
2
+# # #
--- a/tools/cvs2fossil/lib/trouble.tcl
+++ b/tools/cvs2fossil/lib/trouble.tcl
@@ -0,0 +1,2 @@
 
 
--- a/tools/cvs2fossil/lib/trouble.tcl
+++ b/tools/cvs2fossil/lib/trouble.tcl
@@ -0,0 +1,2 @@
1 ## -*- tcl -*-
2 # # #

Keyboard Shortcuts

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