Fossil SCM

Importer extended to allow capture of exact fossil commit command

aku 2007-09-04 22:00 trunk
Commit 492531e3a86fcc4fb8ac3c56b2efddd2ad244aa4
--- tools/import-cvs.tcl
+++ tools/import-cvs.tcl
@@ -89,18 +89,25 @@
8989
9090
9191
# -----------------------------------------------------------------------------
9292
9393
proc commandline {} {
94
- global argv cvs fossil nosign log
94
+ global argv cvs fossil nosign log debugcommit
9595
9696
set nosign 0
97
+ set debugcommit 0
98
+
9799
while {[string match "-*" [set opt [lindex $argv 0]]]} {
98100
if {$opt eq "--nosign"} {
99101
set nosign 1
100102
set argv [lrange $argv 1 end]
101103
continue
104
+ }
105
+ if {$opt eq "--debugcommit"} {
106
+ set debugcommit 1
107
+ set argv [lrange $argv 1 end]
108
+ continue
102109
}
103110
usage
104111
}
105112
if {[llength $argv] != 2} usage
106113
foreach {cvs fossil} $argv break
@@ -114,10 +121,12 @@
114121
} elseif {[file exists $fossil]} {
115122
usage "Fossil destination repository exists already."
116123
}
117124
118125
set log [open ${fossil}.log w]
126
+
127
+ fossil::debugcommit $debugcommit
119128
return
120129
}
121130
122131
proc usage {{text {}}} {
123132
global argv0
124133
--- 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
--- tools/lib/fossil.tcl
+++ tools/lib/fossil.tcl
@@ -45,16 +45,30 @@
4545
# Repository file
4646
variable fr {}
4747
4848
# Fossil application
4949
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 {}
5055
}
5156
57
+proc ::fossil::debugcommit {flag} {
58
+ variable debugcommit $flag
59
+ if {$debugcommit} {
60
+ variable dcfile [file normalize cvs2fossil_commit.tcl]
61
+ }
62
+ return
63
+}
5264
5365
proc ::fossil::commit {appname nosign meta ignore} {
5466
variable fossil
5567
variable lastuuid
68
+ variable debugcommit
69
+ variable dcfile
5670
5771
# Commit the current state of the workspace. Scan for new and
5872
# removed files and issue the appropriate fossil add/rm commands
5973
# before actually comitting.
6074
@@ -96,17 +110,23 @@
96110
97111
set message [join [list \
98112
"-- Originally by $user @ $tstamp" \
99113
"-- Imported by $appname" \
100114
$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
+ }
101125
102126
if {[catch {
103
- if {$nosign} {
104
- exec $fossil commit -m $message --nosign
105
- } else {
106
- exec $fossil commit -m $message
107
- }
127
+ eval $cmd
108128
} line]} {
109129
if {![string match "*nothing has changed*" $line]} {
110130
return -code error $line
111131
}
112132
113133
--- 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

Keyboard Shortcuts

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