Thanks very much, Lars-Christian !!
I managed to get your script to work with WinCVS.
There seems to be a bug in the internal WinCVS command used in the original
script.
So here for all of you the WinCVS version (which i enhanced for
multiselected files):
#!CVSGUI1.0 --selection --name "Locked Files"
proc report_locks {name} {
global cvs
global cvscfg
global cwd
upvar linenum linenum
set linenum 1
set commandline "cvs -l log $name"
catch {eval "exec $commandline"} view_this
set filelist ""
set found "f"
set view_lines [split $view_this "\n"]
foreach line $view_lines {
if {[string match "Working file: *" $line]} {
regsub "Working file: " $line "" filename
lappend filelist $filename
set locklist($filename) ""
}
if {[string match "*locked by*" $line]} {
lappend locklist($filename) $line
set found "t"
}
}
incr linenum 2
if { $found == "t" } {
foreach filename $filelist {
if { [llength $locklist($filename)] > 0 } {
cvsout [format "\n %s:\n" $filename]
incr linenum
foreach rev $locklist($filename) {
cvsout [format " %s\n" $rev]
incr linenum
}
}
}
} else {
incr linenum 2
}
}
set selList [cvsbrowser get]
set selSize [llength $selList]
cvsout "\nLocked files:\n"
cvsout "--------------------\n"
for {set i 0} {$i < $selSize} {incr i} {
set file [lindex $selList $i]
report_locks $file
}
cvsout "\n--------------------\n"
cvsout "Checking for locks finished\n\n"
Cheers, Hans
-----Original Message-----
From: Lars-Christian Schulze [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 21, 2000 1:03 PM
To: Hans Schmid
Cc: Info-Cvs
Subject: Re: Please help: WinCVS: Tcl script looking for locked files
On Wed, 21 Jun 2000, Hans Schmid wrote:
> Hi all,
>
> I am looking for a Tcl script to check, if files are locked by somebody
> (using strict locking)
> I modified the SelectionTest.tcl script coming with WinCVS 1.1b14 to show
> the $fileInfo(locked) files
>
> Unfortunately the following statement seems always to return 1 (file
locked)
> even on unlocked files
>
> cvsout "--> Locked : " $fileInfo(locked) "\n" --> always 1, even
> for not locked files
>
> Is this a known bug or do I miss something obvious.
>
> Here the script I am using:
>
> [ script deleted ...]
Dear Hans,
I don't use WinCVS and therefore I do not understand all details of
your script I do not know the interface between WinCVS and the Tcl
scripts. I assume that the informations about files an directories are
provided by WinCVS via 'browsit'. Therefore I could only guess that the
misbehaviour might be a WinCVS bug.
But I wrote a similar script for TkCVS a few weeks ago, which I appended
below. It calls the 'cvs log' command directly and catches the output in
'view_this'.
Then the output is scanned in two steps. First all filenames are stored in
'filelist'. The corresponding locked revisions are stored in the array
'locklist(...)'.
In the second step the result is formated for output. In TkCVS the result
is displayed using a special "viewer" which opens its own window for
displaying text. I think this could be replaced by 'cvsout' command to
make the result appear in the WinCVS console window. The script will
also show if several revisions of a file are locked and by whom.
Maybe this helps you.
Lars
-------------------------------------------------------------------
aerodata Flugmesstechnik GmbH Email [EMAIL PROTECTED]
Lars-Christian Schulze WWW www.aerodata.de
Hermann-Blenk-Str. 36 Voice +49 531 2359-188
D-38108 Braunschweig Fax +49 531 2359-158
---------- Extract from cvs.tcl, part of TkCVS, version 6.3 ------
proc report_locks {} {
global cvs
global cvscfg
global cwd
upvar linenum linenum
gen_log:log T "ENTER"
if {! [winfo exists .viewer]} {
viewer_setup
} else {
.viewer.text configure -state normal
.viewer.text delete 1.0 end
}
set linenum 1
set commandline "$cvs -d $cvscfg(cvsroot) -l log"
gen_log:log C "$commandline"
catch {eval "exec $commandline"} view_this
set filelist ""
set found "f"
set view_lines [split $view_this "\n"]
foreach line $view_lines {
if {[string match "Working file: *" $line]} {
regsub "Working file: " $line "" filename
lappend filelist $filename
set locklist($filename) ""
}
if {[string match "*locked by*" $line]} {
lappend locklist($filename) $line
set found "t"
}
}
.viewer.text insert end "\nLocked files:\n"
.viewer.text insert end "--------------------\n"
incr linenum 2
if { $found == "t" } {
foreach filename $filelist {
if { [llength $locklist($filename)] > 0 } {
.viewer.text insert end [format "\n %s:\n" $filename]
incr linenum
foreach rev $locklist($filename) {
.viewer.text insert end [format " %s\n" $rev]
incr linenum
}
}
}
} else {
.viewer.text insert end "\n $cwd:"
.viewer.text insert end "\n No files locked in and under THIS
directory."
incr linenum 2
}
.viewer.text configure -state disabled
wm deiconify .viewer
raise .viewer
gen_log:log T "LEAVE"
}
---------------------- End of Extract -------------------------------------