Reputation: 202
I am trying to commit a file in svn through a tcl script. I am running following command in tcl script
catch {exec svn commit -m'SDR' 'C:\abc\def\a.txt'} results
This is returning following error
svn: E020024: Error resolving case of 'C:\abc\def\a.txt'
I have tried everything that I can. Posting here with the hope of getting it solve. Thanks in advance.
Upvotes: 0
Views: 378
Reputation: 137587
The problem is that '
characters mean nothing at all to Tcl, unlike with the shell you're more used to using. Fortunately, that's often best addressed by just putting those values — without the '
characters — in Tcl variables and just using them. Formally, Tcl uses {
…}
where shells use '
…'
, but anything that makes the right string will do in practice.
Also, Tcl's very keen on converting \
to /
in filenames; we need to take a little care there too because we're handing the filename off to a subprocess (and file nativename
is exactly the care we need).
# I'm going to factor these two out into variables; that sort of thing that makes sense
set message "SDR"
set file [file join C:/ abc def a.txt]
catch {exec svn commit -m $message [file nativename $file]} results
Of course, in practice many applications have a notion of a working area that they do their file operations within. It might be the current working directory, it might be somewhere else (it really depends on the app), but it's often best to put the name of it in a variable of its own. Then you can use names within that scope much more easily:
set workingArea [file join C:/ abc]
set message "SDR"
set file [file join $workingArea def/a.txt]
catch {exec svn commit -m $message [file nativename $file]} results
And I'd actually wrap some of that up in a procedure if it was my own code (this uses lmap
, which was introduced in Tcl 8.6):
proc svnCommit {message args} {
global workingArea
set code [catch {
exec svn commit -m $message {*}[lmap f $args {
file nativename [file join $workingArea $f]
}]
} results]
return [list $code $results]
}
lassign [svnCommit "SDR" def/a.txt] code results
Upvotes: 2
Reputation: 996
Using the file join command solves the issue on my machine:
catch {exec svn commit -m'SDR' [file join C:\\ abc def a.txt]} results
Upvotes: 0