| | @@ -3,29 +3,31 @@ |
| 3 | 3 | |
| 4 | 4 | # ----------------------------------------------------------------------------- |
| 5 | 5 | # Requirements |
| 6 | 6 | |
| 7 | 7 | package require Tcl 8.4 |
| 8 | | -package require vc::tools::log ; # User feedback |
| 8 | +package require vc::tools::log ; # User feedback |
| 9 | +package require vc::fossil::cmd ; # Access to fossil application. |
| 9 | 10 | |
| 10 | 11 | namespace eval ::vc::fossil::ws { |
| 11 | 12 | vc::tools::log::system fossil |
| 12 | 13 | namespace import ::vc::tools::log::write |
| 14 | + namespace import ::vc::fossil::cmd::do |
| 15 | + namespace import ::vc::fossil::cmd::dova |
| 13 | 16 | } |
| 14 | 17 | |
| 15 | 18 | # ----------------------------------------------------------------------------- |
| 16 | 19 | # API |
| 17 | 20 | |
| 18 | 21 | # Define repository file, and connect to workspace in CWD. |
| 19 | 22 | |
| 20 | 23 | proc ::vc::fossil::ws::new {} { |
| 21 | 24 | variable fr [file normalize [fileutil::tempfile import2_fsl_rp_]] |
| 22 | | - variable fossil |
| 23 | 25 | |
| 24 | 26 | # pwd = workspace |
| 25 | | - exec $fossil new $fr ; # create and |
| 26 | | - exec $fossil open $fr ; # connect |
| 27 | + dova new $fr ; # create and |
| 28 | + dova open $fr ; # connect |
| 27 | 29 | |
| 28 | 30 | write 0 fossil "Repository: $fr" |
| 29 | 31 | |
| 30 | 32 | return $fr |
| 31 | 33 | } |
| | @@ -40,13 +42,10 @@ |
| 40 | 42 | |
| 41 | 43 | namespace eval ::vc::fossil::ws { |
| 42 | 44 | # Repository file |
| 43 | 45 | variable fr {} |
| 44 | 46 | |
| 45 | | - # Fossil application |
| 46 | | - variable fossil [auto_execok fossil] |
| 47 | | - |
| 48 | 47 | # Debug the commit command (write a Tcl script containing the |
| 49 | 48 | # exact command used). And the file the data goes to. |
| 50 | 49 | variable debugcommit 0 |
| 51 | 50 | variable dcfile {} |
| 52 | 51 | } |
| | @@ -58,11 +57,10 @@ |
| 58 | 57 | } |
| 59 | 58 | return |
| 60 | 59 | } |
| 61 | 60 | |
| 62 | 61 | proc ::vc::fossil::ws::commit {break appname nosign meta ignore} { |
| 63 | | - variable fossil |
| 64 | 62 | variable lastuuid |
| 65 | 63 | variable debugcommit |
| 66 | 64 | variable dcfile |
| 67 | 65 | |
| 68 | 66 | # Commit the current state of the workspace. Scan for new and |
| | @@ -75,16 +73,16 @@ |
| 75 | 73 | |
| 76 | 74 | set added 0 |
| 77 | 75 | set removed 0 |
| 78 | 76 | set changed 0 |
| 79 | 77 | |
| 80 | | - foreach line [split [exec $fossil changes] \n] { |
| 78 | + foreach line [split [dova changes] \n] { |
| 81 | 79 | regsub {^\s*EDITED\s*} $line {} path |
| 82 | 80 | if {[IGNORE $ignore $path]} continue |
| 83 | 81 | |
| 84 | 82 | if {![file exists $path]} { |
| 85 | | - exec $fossil rm $path |
| 83 | + dova rm $path |
| 86 | 84 | incr removed |
| 87 | 85 | write 2 fossil "- $path" |
| 88 | 86 | } else { |
| 89 | 87 | incr changed |
| 90 | 88 | write 2 fossil "* $path" |
| | @@ -91,13 +89,13 @@ |
| 91 | 89 | } |
| 92 | 90 | } |
| 93 | 91 | |
| 94 | 92 | # Now look for unregistered added files. |
| 95 | 93 | |
| 96 | | - foreach path [split [exec $fossil extra] \n] { |
| 94 | + foreach path [split [dova extra] \n] { |
| 97 | 95 | if {[IGNORE $ignore $path]} continue |
| 98 | | - exec $fossil add $path |
| 96 | + dova add $path |
| 99 | 97 | incr added |
| 100 | 98 | write 2 fossil "+ $path" |
| 101 | 99 | } |
| 102 | 100 | |
| 103 | 101 | # Now commit, using the provided meta data, and capture the uuid |
| | @@ -108,25 +106,22 @@ |
| 108 | 106 | set message [join [list \ |
| 109 | 107 | "-- Originally by $user @ $tstamp" \ |
| 110 | 108 | "-- Imported by $appname" \ |
| 111 | 109 | $message] \n] |
| 112 | 110 | |
| 113 | | - if {$nosign} { |
| 114 | | - set cmd [list exec $fossil commit -m $message --nosign] |
| 115 | | - } else { |
| 116 | | - set cmd [list exec $fossil commit -m $message] |
| 117 | | - } |
| 111 | + set cmd [list commit -m $message] |
| 112 | + if {$nosign} { lappend cmd --nosign } |
| 118 | 113 | |
| 119 | 114 | if {$debugcommit} { |
| 120 | | - fileutil::writeFile $dcfile "\#!tclsh\n$cmd\n" |
| 115 | + fileutil::writeFile $dcfile "$cmd\n" |
| 121 | 116 | } |
| 122 | 117 | |
| 123 | 118 | # Stop, do not actually commit. |
| 124 | 119 | if {$break} return |
| 125 | 120 | |
| 126 | 121 | if {[catch { |
| 127 | | - eval $cmd |
| 122 | + do $cmd |
| 128 | 123 | } line]} { |
| 129 | 124 | if {![string match "*nothing has changed*" $line]} { |
| 130 | 125 | return -code error $line |
| 131 | 126 | } |
| 132 | 127 | |
| 133 | 128 | |
| 134 | 129 | ADDED tools/lib/fossil_cmd.tcl |