Fossil SCM

Extended test-import-manifest to return not only the record-id, but the hash uuid as well. Extended the fossil accessor class with methods for regular and branch tagging. Split the initialization from construction (needed for when we split the import pass into three), and a method to set/retrieve the accessor's configuration (persistence across passes).

aku 2008-03-05 03:35 trunk
Commit b7fc4d9d047d993a345ef54bdf50e0b5ecae58a7
+8 -3
--- src/checkin.c
+++ src/checkin.c
@@ -587,10 +587,12 @@
587587
Blob cksum, cksum2; /* Before and after commit checksums */
588588
Blob cksum1b; /* Checksum recorded in the manifest */
589589
const char* parent; /* loop variable when collecting parent references */
590590
int i, mid; /* Another loop index, and id of new manifest */
591591
Stmt q; /* sql statement to query table of files */
592
+ char* zMidUuid; /* Uuid for the newly generated manifest */
593
+
592594
593595
#define USAGE ("DATE COMMENT ?-p|-parent PARENT_RID...? ?-f|-file (FILE_RID PATH)...?")
594596
595597
/*
596598
** Validate and process arguments, collect information.
@@ -805,18 +807,21 @@
805807
** At last commit all changes, after getting rid of the temp
806808
** holder for the files, and release allocated memory.
807809
*/
808810
809811
db_multi_exec("DROP TABLE __im");
812
+ zMidUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", mid);
810813
db_end_transaction(0);
811814
free(zParents);
812815
813816
/*
814
- ** At the very last inform the caller about the id of the new
815
- ** manifest.
817
+ ** At the very last inform the caller about the id and uuid of the
818
+ ** new manifest.
816819
*/
817820
818
- printf("inserted as record %d\n", mid);
821
+
822
+ printf("inserted as record %d, %s\n", mid, zMidUuid);
823
+ free(zMidUuid);
819824
return;
820825
821826
#undef USAGE
822827
}
823828
--- src/checkin.c
+++ src/checkin.c
@@ -587,10 +587,12 @@
587 Blob cksum, cksum2; /* Before and after commit checksums */
588 Blob cksum1b; /* Checksum recorded in the manifest */
589 const char* parent; /* loop variable when collecting parent references */
590 int i, mid; /* Another loop index, and id of new manifest */
591 Stmt q; /* sql statement to query table of files */
 
 
592
593 #define USAGE ("DATE COMMENT ?-p|-parent PARENT_RID...? ?-f|-file (FILE_RID PATH)...?")
594
595 /*
596 ** Validate and process arguments, collect information.
@@ -805,18 +807,21 @@
805 ** At last commit all changes, after getting rid of the temp
806 ** holder for the files, and release allocated memory.
807 */
808
809 db_multi_exec("DROP TABLE __im");
 
810 db_end_transaction(0);
811 free(zParents);
812
813 /*
814 ** At the very last inform the caller about the id of the new
815 ** manifest.
816 */
817
818 printf("inserted as record %d\n", mid);
 
 
819 return;
820
821 #undef USAGE
822 }
823
--- src/checkin.c
+++ src/checkin.c
@@ -587,10 +587,12 @@
587 Blob cksum, cksum2; /* Before and after commit checksums */
588 Blob cksum1b; /* Checksum recorded in the manifest */
589 const char* parent; /* loop variable when collecting parent references */
590 int i, mid; /* Another loop index, and id of new manifest */
591 Stmt q; /* sql statement to query table of files */
592 char* zMidUuid; /* Uuid for the newly generated manifest */
593
594
595 #define USAGE ("DATE COMMENT ?-p|-parent PARENT_RID...? ?-f|-file (FILE_RID PATH)...?")
596
597 /*
598 ** Validate and process arguments, collect information.
@@ -805,18 +807,21 @@
807 ** At last commit all changes, after getting rid of the temp
808 ** holder for the files, and release allocated memory.
809 */
810
811 db_multi_exec("DROP TABLE __im");
812 zMidUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", mid);
813 db_end_transaction(0);
814 free(zParents);
815
816 /*
817 ** At the very last inform the caller about the id and uuid of the
818 ** new manifest.
819 */
820
821
822 printf("inserted as record %d, %s\n", mid, zMidUuid);
823 free(zMidUuid);
824 return;
825
826 #undef USAGE
827 }
828
--- tools/cvs2fossil/lib/c2f_fossil.tcl
+++ tools/cvs2fossil/lib/c2f_fossil.tcl
@@ -28,23 +28,40 @@
2828
snit::type ::vc::fossil::import::cvs::fossil {
2929
# # ## ### ##### ######## #############
3030
## Public API
3131
3232
constructor {} {
33
+ return
34
+ }
35
+
36
+ method initialize {} {
3337
set myrepository [fileutil::tempfile cvs2fossil_repo_]
3438
set myworkspace [fileutil::tempfile cvs2fossil_wspc_]
3539
::file delete $myworkspace
3640
::file mkdir $myworkspace
3741
3842
Do new [::file nativename $myrepository]
3943
$self InWorkspace ; Do open [::file nativename $myrepository]
4044
$self RestorePwd
4145
42
- log write 8 fossil {scratch repository $myrepository}
43
- log write 8 fossil {scratch workspace $myworkspace}
46
+ log write 8 fossil {Scratch repository created @ $myrepository}
47
+ log write 8 fossil {Scratch workspace created @ $myworkspace }
48
+ return
49
+ }
50
+
51
+ method load {r w} {
52
+ set myrepository $r
53
+ set myworkspace $w
54
+
55
+ log write 8 fossil {Scratch repository found @ $myrepository}
56
+ log write 8 fossil {Scratch workspace found @ $myworkspace}
4457
return
4558
}
59
+
60
+ method space {} {
61
+ return [list $myrepository $myworkspace]
62
+ }
4663
4764
# # ## ### ##### ######## #############
4865
##
4966
5067
method root {} {
@@ -97,12 +114,10 @@
97114
log write 3 fossil Done.
98115
return [array get id]
99116
}
100117
101118
method importrevision {label user message date parent revisions} {
102
- # TODO = Write the actual import, and up the log level.
103
-
104119
# Massage the commit message to remember the old user name
105120
# which did the commit in CVS.
106121
107122
set message "By $user:\n$message"
108123
@@ -123,22 +138,56 @@
123138
$self InWorkspace
124139
set res [eval $cmd]
125140
$self RestorePwd
126141
127142
integrity assert {
128
- [regexp {^inserted as record \d+$} $res]
143
+ [regexp {^inserted as record \d+, [0-9a-fA-F]+$} $res]
129144
} {Unable to process unexpected fossil output '$res'}
130
- set uuid [lindex $res 3]
145
+ set rid [string trim [lindex $res 3] ,]
146
+ set uuid [lindex $res 4]
147
+
148
+ log write 2 fossil {== $rid ($uuid)}
149
+
150
+ return [list $rid $uuid]
151
+ }
152
+
153
+ method tag {uuid name} {
154
+ log write 2 fossil {Tag '$name' @ $uuid}
155
+
156
+ $self InWorkspace
157
+ Do tag add sym-$name $uuid
158
+ $self RestorePwd
159
+ return
160
+ }
161
+
162
+ method branchmark {uuid name} {
163
+ # We do not mark the trunk
164
+ if {$name eq ":trunk:"} return
165
+
166
+ log write 2 fossil {Begin branch '$name' @ $uuid}
167
+
168
+ $self InWorkspace
169
+ Do tag branch sym-$name $uuid
170
+ $self RestorePwd
171
+ return
172
+ }
173
+
174
+ method branchcancel {uuid name} {
175
+ # The trunk is unmarked, thus cancellation is not needed
176
+ # either.
177
+ if {$name eq ":trunk:"} return
131178
132
- log write 2 fossil {== $uuid}
133
- log write 2 fossil { }
134
- log write 2 fossil { }
179
+ log write 2 fossil {Cancel branch '$name' @ $uuid}
135180
136
- return $uuid
181
+ $self InWorkspace
182
+ Do tag delete sym-$name $uuid
183
+ $self RestorePwd
184
+ return
137185
}
138186
139187
method finalize {destination} {
188
+ log write 2 fossil {Finalize, rebuilding repository}
140189
Do rebuild [::file nativename $myrepository]
141190
142191
::file rename -force $myrepository $destination
143192
::file delete -force $myworkspace
144193
$self destroy
@@ -190,10 +239,11 @@
190239
# # ## ### ##### ######## #############
191240
## Internal methods
192241
193242
proc Do {args} {
194243
# 8.5: exec $myfossilcmd {*}$args
244
+ log write 14 fossil {Doing '$args'}
195245
return [eval [linsert $args 0 exec $myfossilcmd]]
196246
}
197247
198248
method InWorkspace {} { set mypwd [pwd] ; cd $myworkspace ; return }
199249
method RestorePwd {} { cd $mypwd ; set mypwd {} ; return }
200250
--- tools/cvs2fossil/lib/c2f_fossil.tcl
+++ tools/cvs2fossil/lib/c2f_fossil.tcl
@@ -28,23 +28,40 @@
28 snit::type ::vc::fossil::import::cvs::fossil {
29 # # ## ### ##### ######## #############
30 ## Public API
31
32 constructor {} {
 
 
 
 
33 set myrepository [fileutil::tempfile cvs2fossil_repo_]
34 set myworkspace [fileutil::tempfile cvs2fossil_wspc_]
35 ::file delete $myworkspace
36 ::file mkdir $myworkspace
37
38 Do new [::file nativename $myrepository]
39 $self InWorkspace ; Do open [::file nativename $myrepository]
40 $self RestorePwd
41
42 log write 8 fossil {scratch repository $myrepository}
43 log write 8 fossil {scratch workspace $myworkspace}
 
 
 
 
 
 
 
 
 
44 return
45 }
 
 
 
 
46
47 # # ## ### ##### ######## #############
48 ##
49
50 method root {} {
@@ -97,12 +114,10 @@
97 log write 3 fossil Done.
98 return [array get id]
99 }
100
101 method importrevision {label user message date parent revisions} {
102 # TODO = Write the actual import, and up the log level.
103
104 # Massage the commit message to remember the old user name
105 # which did the commit in CVS.
106
107 set message "By $user:\n$message"
108
@@ -123,22 +138,56 @@
123 $self InWorkspace
124 set res [eval $cmd]
125 $self RestorePwd
126
127 integrity assert {
128 [regexp {^inserted as record \d+$} $res]
129 } {Unable to process unexpected fossil output '$res'}
130 set uuid [lindex $res 3]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
132 log write 2 fossil {== $uuid}
133 log write 2 fossil { }
134 log write 2 fossil { }
135
136 return $uuid
 
 
 
137 }
138
139 method finalize {destination} {
 
140 Do rebuild [::file nativename $myrepository]
141
142 ::file rename -force $myrepository $destination
143 ::file delete -force $myworkspace
144 $self destroy
@@ -190,10 +239,11 @@
190 # # ## ### ##### ######## #############
191 ## Internal methods
192
193 proc Do {args} {
194 # 8.5: exec $myfossilcmd {*}$args
 
195 return [eval [linsert $args 0 exec $myfossilcmd]]
196 }
197
198 method InWorkspace {} { set mypwd [pwd] ; cd $myworkspace ; return }
199 method RestorePwd {} { cd $mypwd ; set mypwd {} ; return }
200
--- tools/cvs2fossil/lib/c2f_fossil.tcl
+++ tools/cvs2fossil/lib/c2f_fossil.tcl
@@ -28,23 +28,40 @@
28 snit::type ::vc::fossil::import::cvs::fossil {
29 # # ## ### ##### ######## #############
30 ## Public API
31
32 constructor {} {
33 return
34 }
35
36 method initialize {} {
37 set myrepository [fileutil::tempfile cvs2fossil_repo_]
38 set myworkspace [fileutil::tempfile cvs2fossil_wspc_]
39 ::file delete $myworkspace
40 ::file mkdir $myworkspace
41
42 Do new [::file nativename $myrepository]
43 $self InWorkspace ; Do open [::file nativename $myrepository]
44 $self RestorePwd
45
46 log write 8 fossil {Scratch repository created @ $myrepository}
47 log write 8 fossil {Scratch workspace created @ $myworkspace }
48 return
49 }
50
51 method load {r w} {
52 set myrepository $r
53 set myworkspace $w
54
55 log write 8 fossil {Scratch repository found @ $myrepository}
56 log write 8 fossil {Scratch workspace found @ $myworkspace}
57 return
58 }
59
60 method space {} {
61 return [list $myrepository $myworkspace]
62 }
63
64 # # ## ### ##### ######## #############
65 ##
66
67 method root {} {
@@ -97,12 +114,10 @@
114 log write 3 fossil Done.
115 return [array get id]
116 }
117
118 method importrevision {label user message date parent revisions} {
 
 
119 # Massage the commit message to remember the old user name
120 # which did the commit in CVS.
121
122 set message "By $user:\n$message"
123
@@ -123,22 +138,56 @@
138 $self InWorkspace
139 set res [eval $cmd]
140 $self RestorePwd
141
142 integrity assert {
143 [regexp {^inserted as record \d+, [0-9a-fA-F]+$} $res]
144 } {Unable to process unexpected fossil output '$res'}
145 set rid [string trim [lindex $res 3] ,]
146 set uuid [lindex $res 4]
147
148 log write 2 fossil {== $rid ($uuid)}
149
150 return [list $rid $uuid]
151 }
152
153 method tag {uuid name} {
154 log write 2 fossil {Tag '$name' @ $uuid}
155
156 $self InWorkspace
157 Do tag add sym-$name $uuid
158 $self RestorePwd
159 return
160 }
161
162 method branchmark {uuid name} {
163 # We do not mark the trunk
164 if {$name eq ":trunk:"} return
165
166 log write 2 fossil {Begin branch '$name' @ $uuid}
167
168 $self InWorkspace
169 Do tag branch sym-$name $uuid
170 $self RestorePwd
171 return
172 }
173
174 method branchcancel {uuid name} {
175 # The trunk is unmarked, thus cancellation is not needed
176 # either.
177 if {$name eq ":trunk:"} return
178
179 log write 2 fossil {Cancel branch '$name' @ $uuid}
 
 
180
181 $self InWorkspace
182 Do tag delete sym-$name $uuid
183 $self RestorePwd
184 return
185 }
186
187 method finalize {destination} {
188 log write 2 fossil {Finalize, rebuilding repository}
189 Do rebuild [::file nativename $myrepository]
190
191 ::file rename -force $myrepository $destination
192 ::file delete -force $myworkspace
193 $self destroy
@@ -190,10 +239,11 @@
239 # # ## ### ##### ######## #############
240 ## Internal methods
241
242 proc Do {args} {
243 # 8.5: exec $myfossilcmd {*}$args
244 log write 14 fossil {Doing '$args'}
245 return [eval [linsert $args 0 exec $myfossilcmd]]
246 }
247
248 method InWorkspace {} { set mypwd [pwd] ; cd $myworkspace ; return }
249 method RestorePwd {} { cd $mypwd ; set mypwd {} ; return }
250

Keyboard Shortcuts

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