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).
Commit
b7fc4d9d047d993a345ef54bdf50e0b5ecae58a7
Parent
011fb38dda2194b…
2 files changed
+8
-3
+60
-10
+8
-3
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -587,10 +587,12 @@ | ||
| 587 | 587 | Blob cksum, cksum2; /* Before and after commit checksums */ |
| 588 | 588 | Blob cksum1b; /* Checksum recorded in the manifest */ |
| 589 | 589 | const char* parent; /* loop variable when collecting parent references */ |
| 590 | 590 | int i, mid; /* Another loop index, and id of new manifest */ |
| 591 | 591 | Stmt q; /* sql statement to query table of files */ |
| 592 | + char* zMidUuid; /* Uuid for the newly generated manifest */ | |
| 593 | + | |
| 592 | 594 | |
| 593 | 595 | #define USAGE ("DATE COMMENT ?-p|-parent PARENT_RID...? ?-f|-file (FILE_RID PATH)...?") |
| 594 | 596 | |
| 595 | 597 | /* |
| 596 | 598 | ** Validate and process arguments, collect information. |
| @@ -805,18 +807,21 @@ | ||
| 805 | 807 | ** At last commit all changes, after getting rid of the temp |
| 806 | 808 | ** holder for the files, and release allocated memory. |
| 807 | 809 | */ |
| 808 | 810 | |
| 809 | 811 | db_multi_exec("DROP TABLE __im"); |
| 812 | + zMidUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", mid); | |
| 810 | 813 | db_end_transaction(0); |
| 811 | 814 | free(zParents); |
| 812 | 815 | |
| 813 | 816 | /* |
| 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. | |
| 816 | 819 | */ |
| 817 | 820 | |
| 818 | - printf("inserted as record %d\n", mid); | |
| 821 | + | |
| 822 | + printf("inserted as record %d, %s\n", mid, zMidUuid); | |
| 823 | + free(zMidUuid); | |
| 819 | 824 | return; |
| 820 | 825 | |
| 821 | 826 | #undef USAGE |
| 822 | 827 | } |
| 823 | 828 |
| --- 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 |
+60
-10
| --- tools/cvs2fossil/lib/c2f_fossil.tcl | ||
| +++ tools/cvs2fossil/lib/c2f_fossil.tcl | ||
| @@ -28,23 +28,40 @@ | ||
| 28 | 28 | snit::type ::vc::fossil::import::cvs::fossil { |
| 29 | 29 | # # ## ### ##### ######## ############# |
| 30 | 30 | ## Public API |
| 31 | 31 | |
| 32 | 32 | constructor {} { |
| 33 | + return | |
| 34 | + } | |
| 35 | + | |
| 36 | + method initialize {} { | |
| 33 | 37 | set myrepository [fileutil::tempfile cvs2fossil_repo_] |
| 34 | 38 | set myworkspace [fileutil::tempfile cvs2fossil_wspc_] |
| 35 | 39 | ::file delete $myworkspace |
| 36 | 40 | ::file mkdir $myworkspace |
| 37 | 41 | |
| 38 | 42 | Do new [::file nativename $myrepository] |
| 39 | 43 | $self InWorkspace ; Do open [::file nativename $myrepository] |
| 40 | 44 | $self RestorePwd |
| 41 | 45 | |
| 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} | |
| 44 | 57 | return |
| 45 | 58 | } |
| 59 | + | |
| 60 | + method space {} { | |
| 61 | + return [list $myrepository $myworkspace] | |
| 62 | + } | |
| 46 | 63 | |
| 47 | 64 | # # ## ### ##### ######## ############# |
| 48 | 65 | ## |
| 49 | 66 | |
| 50 | 67 | method root {} { |
| @@ -97,12 +114,10 @@ | ||
| 97 | 114 | log write 3 fossil Done. |
| 98 | 115 | return [array get id] |
| 99 | 116 | } |
| 100 | 117 | |
| 101 | 118 | method importrevision {label user message date parent revisions} { |
| 102 | - # TODO = Write the actual import, and up the log level. | |
| 103 | - | |
| 104 | 119 | # Massage the commit message to remember the old user name |
| 105 | 120 | # which did the commit in CVS. |
| 106 | 121 | |
| 107 | 122 | set message "By $user:\n$message" |
| 108 | 123 | |
| @@ -123,22 +138,56 @@ | ||
| 123 | 138 | $self InWorkspace |
| 124 | 139 | set res [eval $cmd] |
| 125 | 140 | $self RestorePwd |
| 126 | 141 | |
| 127 | 142 | integrity assert { |
| 128 | - [regexp {^inserted as record \d+$} $res] | |
| 143 | + [regexp {^inserted as record \d+, [0-9a-fA-F]+$} $res] | |
| 129 | 144 | } {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 | |
| 131 | 178 | |
| 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} | |
| 135 | 180 | |
| 136 | - return $uuid | |
| 181 | + $self InWorkspace | |
| 182 | + Do tag delete sym-$name $uuid | |
| 183 | + $self RestorePwd | |
| 184 | + return | |
| 137 | 185 | } |
| 138 | 186 | |
| 139 | 187 | method finalize {destination} { |
| 188 | + log write 2 fossil {Finalize, rebuilding repository} | |
| 140 | 189 | Do rebuild [::file nativename $myrepository] |
| 141 | 190 | |
| 142 | 191 | ::file rename -force $myrepository $destination |
| 143 | 192 | ::file delete -force $myworkspace |
| 144 | 193 | $self destroy |
| @@ -190,10 +239,11 @@ | ||
| 190 | 239 | # # ## ### ##### ######## ############# |
| 191 | 240 | ## Internal methods |
| 192 | 241 | |
| 193 | 242 | proc Do {args} { |
| 194 | 243 | # 8.5: exec $myfossilcmd {*}$args |
| 244 | + log write 14 fossil {Doing '$args'} | |
| 195 | 245 | return [eval [linsert $args 0 exec $myfossilcmd]] |
| 196 | 246 | } |
| 197 | 247 | |
| 198 | 248 | method InWorkspace {} { set mypwd [pwd] ; cd $myworkspace ; return } |
| 199 | 249 | method RestorePwd {} { cd $mypwd ; set mypwd {} ; return } |
| 200 | 250 |
| --- 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 |