Fossil SCM
Importer extended to allow capture of exact fossil commit command
Commit
492531e3a86fcc4fb8ac3c56b2efddd2ad244aa4
Parent
7003caa9828fac6…
2 files changed
+10
-1
+25
-5
+10
-1
| --- tools/import-cvs.tcl | ||
| +++ tools/import-cvs.tcl | ||
| @@ -89,18 +89,25 @@ | ||
| 89 | 89 | |
| 90 | 90 | |
| 91 | 91 | # ----------------------------------------------------------------------------- |
| 92 | 92 | |
| 93 | 93 | proc commandline {} { |
| 94 | - global argv cvs fossil nosign log | |
| 94 | + global argv cvs fossil nosign log debugcommit | |
| 95 | 95 | |
| 96 | 96 | set nosign 0 |
| 97 | + set debugcommit 0 | |
| 98 | + | |
| 97 | 99 | while {[string match "-*" [set opt [lindex $argv 0]]]} { |
| 98 | 100 | if {$opt eq "--nosign"} { |
| 99 | 101 | set nosign 1 |
| 100 | 102 | set argv [lrange $argv 1 end] |
| 101 | 103 | continue |
| 104 | + } | |
| 105 | + if {$opt eq "--debugcommit"} { | |
| 106 | + set debugcommit 1 | |
| 107 | + set argv [lrange $argv 1 end] | |
| 108 | + continue | |
| 102 | 109 | } |
| 103 | 110 | usage |
| 104 | 111 | } |
| 105 | 112 | if {[llength $argv] != 2} usage |
| 106 | 113 | foreach {cvs fossil} $argv break |
| @@ -114,10 +121,12 @@ | ||
| 114 | 121 | } elseif {[file exists $fossil]} { |
| 115 | 122 | usage "Fossil destination repository exists already." |
| 116 | 123 | } |
| 117 | 124 | |
| 118 | 125 | set log [open ${fossil}.log w] |
| 126 | + | |
| 127 | + fossil::debugcommit $debugcommit | |
| 119 | 128 | return |
| 120 | 129 | } |
| 121 | 130 | |
| 122 | 131 | proc usage {{text {}}} { |
| 123 | 132 | global argv0 |
| 124 | 133 |
| --- tools/import-cvs.tcl | |
| +++ tools/import-cvs.tcl | |
| @@ -89,18 +89,25 @@ | |
| 89 | |
| 90 | |
| 91 | # ----------------------------------------------------------------------------- |
| 92 | |
| 93 | proc commandline {} { |
| 94 | global argv cvs fossil nosign log |
| 95 | |
| 96 | set nosign 0 |
| 97 | while {[string match "-*" [set opt [lindex $argv 0]]]} { |
| 98 | if {$opt eq "--nosign"} { |
| 99 | set nosign 1 |
| 100 | set argv [lrange $argv 1 end] |
| 101 | continue |
| 102 | } |
| 103 | usage |
| 104 | } |
| 105 | if {[llength $argv] != 2} usage |
| 106 | foreach {cvs fossil} $argv break |
| @@ -114,10 +121,12 @@ | |
| 114 | } elseif {[file exists $fossil]} { |
| 115 | usage "Fossil destination repository exists already." |
| 116 | } |
| 117 | |
| 118 | set log [open ${fossil}.log w] |
| 119 | return |
| 120 | } |
| 121 | |
| 122 | proc usage {{text {}}} { |
| 123 | global argv0 |
| 124 |
| --- tools/import-cvs.tcl | |
| +++ tools/import-cvs.tcl | |
| @@ -89,18 +89,25 @@ | |
| 89 | |
| 90 | |
| 91 | # ----------------------------------------------------------------------------- |
| 92 | |
| 93 | proc commandline {} { |
| 94 | global argv cvs fossil nosign log debugcommit |
| 95 | |
| 96 | set nosign 0 |
| 97 | set debugcommit 0 |
| 98 | |
| 99 | while {[string match "-*" [set opt [lindex $argv 0]]]} { |
| 100 | if {$opt eq "--nosign"} { |
| 101 | set nosign 1 |
| 102 | set argv [lrange $argv 1 end] |
| 103 | continue |
| 104 | } |
| 105 | if {$opt eq "--debugcommit"} { |
| 106 | set debugcommit 1 |
| 107 | set argv [lrange $argv 1 end] |
| 108 | continue |
| 109 | } |
| 110 | usage |
| 111 | } |
| 112 | if {[llength $argv] != 2} usage |
| 113 | foreach {cvs fossil} $argv break |
| @@ -114,10 +121,12 @@ | |
| 121 | } elseif {[file exists $fossil]} { |
| 122 | usage "Fossil destination repository exists already." |
| 123 | } |
| 124 | |
| 125 | set log [open ${fossil}.log w] |
| 126 | |
| 127 | fossil::debugcommit $debugcommit |
| 128 | return |
| 129 | } |
| 130 | |
| 131 | proc usage {{text {}}} { |
| 132 | global argv0 |
| 133 |
+25
-5
| --- tools/lib/fossil.tcl | ||
| +++ tools/lib/fossil.tcl | ||
| @@ -45,16 +45,30 @@ | ||
| 45 | 45 | # Repository file |
| 46 | 46 | variable fr {} |
| 47 | 47 | |
| 48 | 48 | # Fossil application |
| 49 | 49 | variable fossil [auto_execok fossil] |
| 50 | + | |
| 51 | + # Debug the commit command (write a Tcl script containing the | |
| 52 | + # exact command used). And the file the data goes to. | |
| 53 | + variable debugcommit 0 | |
| 54 | + variable dcfile {} | |
| 50 | 55 | } |
| 51 | 56 | |
| 57 | +proc ::fossil::debugcommit {flag} { | |
| 58 | + variable debugcommit $flag | |
| 59 | + if {$debugcommit} { | |
| 60 | + variable dcfile [file normalize cvs2fossil_commit.tcl] | |
| 61 | + } | |
| 62 | + return | |
| 63 | +} | |
| 52 | 64 | |
| 53 | 65 | proc ::fossil::commit {appname nosign meta ignore} { |
| 54 | 66 | variable fossil |
| 55 | 67 | variable lastuuid |
| 68 | + variable debugcommit | |
| 69 | + variable dcfile | |
| 56 | 70 | |
| 57 | 71 | # Commit the current state of the workspace. Scan for new and |
| 58 | 72 | # removed files and issue the appropriate fossil add/rm commands |
| 59 | 73 | # before actually comitting. |
| 60 | 74 | |
| @@ -96,17 +110,23 @@ | ||
| 96 | 110 | |
| 97 | 111 | set message [join [list \ |
| 98 | 112 | "-- Originally by $user @ $tstamp" \ |
| 99 | 113 | "-- Imported by $appname" \ |
| 100 | 114 | $message] \n] |
| 115 | + | |
| 116 | + if {$nosign} { | |
| 117 | + set cmd [list exec $fossil commit -m $message --nosign] | |
| 118 | + } else { | |
| 119 | + set cmd [list exec $fossil commit -m $message] | |
| 120 | + } | |
| 121 | + | |
| 122 | + if {$debugcommit} { | |
| 123 | + fileutil::writeFile $dcfile "\#!tclsh\n$cmd\n" | |
| 124 | + } | |
| 101 | 125 | |
| 102 | 126 | if {[catch { |
| 103 | - if {$nosign} { | |
| 104 | - exec $fossil commit -m $message --nosign | |
| 105 | - } else { | |
| 106 | - exec $fossil commit -m $message | |
| 107 | - } | |
| 127 | + eval $cmd | |
| 108 | 128 | } line]} { |
| 109 | 129 | if {![string match "*nothing has changed*" $line]} { |
| 110 | 130 | return -code error $line |
| 111 | 131 | } |
| 112 | 132 | |
| 113 | 133 |
| --- tools/lib/fossil.tcl | |
| +++ tools/lib/fossil.tcl | |
| @@ -45,16 +45,30 @@ | |
| 45 | # Repository file |
| 46 | variable fr {} |
| 47 | |
| 48 | # Fossil application |
| 49 | variable fossil [auto_execok fossil] |
| 50 | } |
| 51 | |
| 52 | |
| 53 | proc ::fossil::commit {appname nosign meta ignore} { |
| 54 | variable fossil |
| 55 | variable lastuuid |
| 56 | |
| 57 | # Commit the current state of the workspace. Scan for new and |
| 58 | # removed files and issue the appropriate fossil add/rm commands |
| 59 | # before actually comitting. |
| 60 | |
| @@ -96,17 +110,23 @@ | |
| 96 | |
| 97 | set message [join [list \ |
| 98 | "-- Originally by $user @ $tstamp" \ |
| 99 | "-- Imported by $appname" \ |
| 100 | $message] \n] |
| 101 | |
| 102 | if {[catch { |
| 103 | if {$nosign} { |
| 104 | exec $fossil commit -m $message --nosign |
| 105 | } else { |
| 106 | exec $fossil commit -m $message |
| 107 | } |
| 108 | } line]} { |
| 109 | if {![string match "*nothing has changed*" $line]} { |
| 110 | return -code error $line |
| 111 | } |
| 112 | |
| 113 |
| --- tools/lib/fossil.tcl | |
| +++ tools/lib/fossil.tcl | |
| @@ -45,16 +45,30 @@ | |
| 45 | # Repository file |
| 46 | variable fr {} |
| 47 | |
| 48 | # Fossil application |
| 49 | variable fossil [auto_execok fossil] |
| 50 | |
| 51 | # Debug the commit command (write a Tcl script containing the |
| 52 | # exact command used). And the file the data goes to. |
| 53 | variable debugcommit 0 |
| 54 | variable dcfile {} |
| 55 | } |
| 56 | |
| 57 | proc ::fossil::debugcommit {flag} { |
| 58 | variable debugcommit $flag |
| 59 | if {$debugcommit} { |
| 60 | variable dcfile [file normalize cvs2fossil_commit.tcl] |
| 61 | } |
| 62 | return |
| 63 | } |
| 64 | |
| 65 | proc ::fossil::commit {appname nosign meta ignore} { |
| 66 | variable fossil |
| 67 | variable lastuuid |
| 68 | variable debugcommit |
| 69 | variable dcfile |
| 70 | |
| 71 | # Commit the current state of the workspace. Scan for new and |
| 72 | # removed files and issue the appropriate fossil add/rm commands |
| 73 | # before actually comitting. |
| 74 | |
| @@ -96,17 +110,23 @@ | |
| 110 | |
| 111 | set message [join [list \ |
| 112 | "-- Originally by $user @ $tstamp" \ |
| 113 | "-- Imported by $appname" \ |
| 114 | $message] \n] |
| 115 | |
| 116 | if {$nosign} { |
| 117 | set cmd [list exec $fossil commit -m $message --nosign] |
| 118 | } else { |
| 119 | set cmd [list exec $fossil commit -m $message] |
| 120 | } |
| 121 | |
| 122 | if {$debugcommit} { |
| 123 | fileutil::writeFile $dcfile "\#!tclsh\n$cmd\n" |
| 124 | } |
| 125 | |
| 126 | if {[catch { |
| 127 | eval $cmd |
| 128 | } line]} { |
| 129 | if {![string match "*nothing has changed*" $line]} { |
| 130 | return -code error $line |
| 131 | } |
| 132 | |
| 133 |