📄 workdir.tcl
字号:
gen_log:log T "ENTER ($w)"
set items [$w.lbx curselection]
foreach item $items {
set itemstring [$w.lbx get $item]
set dir [lindex $itemstring 0]
gen_log:log D "$item \"$itemstring\""
gen_log:log D " directory \"$dir\""
unset bookmarks($dir)
$w.lbx delete $item
.workdir.menubar.goto delete $itemstring
}
gen_log:log T "LEAVE"
}
proc change_dir {new_dir} {
global cwd
gen_log:log T "ENTER ($new_dir)"
if {![file exists $new_dir]} {
set cwd [pwd]
cvsfail "Directory $new_dir doesn\'t exist!" .workdir
return
}
set cwd $new_dir
setup_dir
gen_log:log T "LEAVE"
}
proc setup_dir { } {
#
# Call this when entering a directory. It puts all of the file names
# in the listbox, and reads the CVS or directory.
#
global cwd
global module_dir
global incvs
global insvn
global inrcs
global cvscfg
global current_tagname
global cvsglb
gen_log:log T "ENTER"
if { ! [winfo exists .workdir.main] } {
workdir_setup
return
} else {
DirCanvas:deltree .workdir.main
}
if {![file isdirectory $cwd]} {
gen_log:log D "$cwd is not a directory"
gen_log:log T "LEAVE -- $cwd is not a directory"
return
}
cd $cwd
gen_log:log F "CD [pwd]"
set module_dir ""
set current_tagname ""
::picklist::used directory [pwd]
foreach {incvs insvn inrcs} [cvsroot_check [pwd]] { break }
gen_log:log D "incvs $incvs inrcs $inrcs insvn $insvn"
.workdir.top.bmodbrowse configure -image Modules
.workdir.top.lmodule configure -text "Path"
.workdir.top.ltagname configure -text "Tag"
# Start with the revision-control menus disabled
.workdir.menubar entryconfigure "CVS" -state normal
.workdir.menubar entryconfigure "SVN" -state normal
.workdir.menubar entryconfigure "RCS" -state normal
.workdir.menubar.reports entryconfigure 0 -state disabled
.workdir.menubar.reports entryconfigure 1 -state disabled
.workdir.menubar.reports entryconfigure 2 -state disabled
.workdir.menubar.reports entryconfigure 3 -state disabled
# Start with the revision-control buttons disabled and the
.workdir.bottom.buttons.dirfuncs.bcheckdir configure -state disabled
foreach widget [grid slaves .workdir.bottom.buttons.cvsfuncs ] {
$widget configure -state disabled
}
foreach widget [grid slaves .workdir.bottom.buttons.cvsfuncs ] {
$widget configure -state disabled
}
foreach widget [grid slaves .workdir.bottom.buttons.oddfuncs ] {
$widget configure -state disabled
}
# Now enable them depending on where we are
if {$inrcs} {
# Top
.workdir.top.lcvsroot configure -text "RCS *,v"
.workdir.top.tcvsroot configure -textvariable cvscfg(rcsdir)
# Buttons
.workdir.bottom.buttons.dirfuncs.bcheckdir configure -state normal \
-command { rcs_check }
.workdir.bottom.buttons.cvsfuncs.bdiff configure -state normal
.workdir.bottom.buttons.cvsfuncs.blogfile configure -state normal \
-command { rcs_branches [workdir_list_files] }
.workdir.bottom.buttons.cvsfuncs.bfilelog configure -state normal \
-command { rcs_log [workdir_list_files] }
.workdir.bottom.buttons.cvsfuncs.bupdate configure -state normal \
-command { rcs_checkout [workdir_list_files] }
.workdir.bottom.buttons.cvsfuncs.bcheckin configure -state normal \
-command { rcs_checkin [workdir_list_files] }
.workdir.bottom.buttons.cvsfuncs.brevert configure -state normal \
-command { rcs_revert [workdir_list_files] }
.workdir.bottom.buttons.oddfuncs.block configure -state normal \
-command { rcs_lock lock [workdir_list_files] }
.workdir.bottom.buttons.oddfuncs.bunlock configure -state normal \
-command { rcs_lock unlock [workdir_list_files] }
# Menus
.workdir.menubar entryconfigure "CVS" -state disabled
.workdir.menubar entryconfigure "SVN" -state disabled
.workdir.menubar entryconfigure "RCS" -state normal
# Reports Menu
# Check Directory (log & rdiff)
.workdir.menubar.reports entryconfigure 0 -state normal \
-command { rcs_check }
.workdir.menubar.reports entryconfigure 1 -state disabled
# Log (rlog)
.workdir.menubar.reports entryconfigure 2 -state normal \
-command { rcs_log [workdir_list_files] }
.workdir.menubar.reports entryconfigure 3 -state disabled
} elseif {$insvn} {
# Top
.workdir.top.bmodbrowse configure -image Modules_svn \
-command {modbrowse_run svn}
.workdir.top.lmodule configure -text "Path"
.workdir.top.ltagname configure -text "Tag"
.workdir.top.lcvsroot configure -text "SVN URL"
.workdir.top.tcvsroot configure -textvariable cvscfg(url)
# Buttons
.workdir.bottom.buttons.dirfuncs.bcheckdir configure -state normal \
-command { svn_check [workdir_list_files] }
.workdir.bottom.buttons.cvsfuncs.bjoin configure -state normal \
-command { svn_branches . }
.workdir.bottom.buttons.cvsfuncs.bdiff configure -state normal
.workdir.bottom.buttons.cvsfuncs.blogfile configure -state normal \
-command { svn_branches [workdir_list_files] }
.workdir.bottom.buttons.cvsfuncs.bfilelog configure -state normal \
-command { svn_log [workdir_list_files] }
.workdir.bottom.buttons.cvsfuncs.bannotate configure -state normal \
-command { svn_annotate BASE [workdir_list_files] }
.workdir.bottom.buttons.cvsfuncs.bconflict configure -state normal \
-command { svn_merge_conflict [workdir_list_files] }
.workdir.bottom.buttons.cvsfuncs.badd_files configure -state normal
.workdir.bottom.buttons.cvsfuncs.bremove configure -state normal
.workdir.bottom.buttons.cvsfuncs.bupdate configure -state normal \
-command { svn_update [workdir_list_files] }
.workdir.bottom.buttons.cvsfuncs.bupdateopts configure -state normal \
-command { svn_update_options }
.workdir.bottom.buttons.cvsfuncs.bcheckin configure -state normal \
-command svn_commit_dialog
.workdir.bottom.buttons.cvsfuncs.brevert configure -state normal \
-command { svn_revert [workdir_list_files] }
.workdir.bottom.buttons.cvsfuncs.btag configure -state normal
.workdir.bottom.buttons.cvsfuncs.bbranchtag configure -state normal
# Menus
.workdir.menubar entryconfigure "CVS" -state disabled
.workdir.menubar entryconfigure "SVN" -state normal
.workdir.menubar entryconfigure "RCS" -state disabled
# Reports Menu
# Check Directory (svn status)
.workdir.menubar.reports entryconfigure 0 -state normal \
-command { svn_check {} 0 }
# Status (svn status <filelist>)
.workdir.menubar.reports entryconfigure 1 -state normal \
-command { svn_check [workdir_list_files] 1}
# Log (svn log)
.workdir.menubar.reports entryconfigure 2 -state normal \
-command { svn_log [workdir_list_files] }
# Annotate/Blame (svn blame)
.workdir.menubar.reports entryconfigure 3 -state normal \
-command { svn_annotate BASE [workdir_list_files] }
} elseif {$incvs} {
# Top
.workdir.top.bmodbrowse configure -image Modules_cvs \
-command {modbrowse_run cvs}
.workdir.top.lmodule configure -text "Module"
.workdir.top.ltagname configure -text "Tag"
.workdir.top.lcvsroot configure -text "CVSROOT"
.workdir.top.tcvsroot configure -textvariable cvscfg(cvsroot)
# Buttons
.workdir.bottom.buttons.dirfuncs.bcheckdir configure -state normal \
-command { cvs_check [workdir_list_files] }
.workdir.bottom.buttons.cvsfuncs.bjoin configure -state normal \
-command cvs_joincanvas
.workdir.bottom.buttons.cvsfuncs.bdiff configure -state normal
.workdir.bottom.buttons.cvsfuncs.bconflict configure -state normal \
-command { cvs_merge_conflict [workdir_list_files] }
.workdir.bottom.buttons.cvsfuncs.bfilelog configure -state normal \
-command { cvs_log [workdir_list_files] }
.workdir.bottom.buttons.cvsfuncs.bannotate configure -state normal \
-command { cvs_annotate $current_tagname [workdir_list_files] }
.workdir.bottom.buttons.cvsfuncs.badd_files configure -state normal
.workdir.bottom.buttons.cvsfuncs.bremove configure -state normal
.workdir.bottom.buttons.cvsfuncs.bupdate configure -state normal \
-command { \
cvs_update {BASE} {Normal} {Remove} {No} { } [workdir_list_files] }
.workdir.bottom.buttons.cvsfuncs.bupdateopts configure -state normal \
-command { update_run }
.workdir.bottom.buttons.cvsfuncs.bcheckin configure -state normal \
-command cvs_commit_dialog
.workdir.bottom.buttons.cvsfuncs.brevert configure -state normal \
-command {cvs_revert [workdir_list_files] }
.workdir.bottom.buttons.cvsfuncs.btag configure -state normal
.workdir.bottom.buttons.cvsfuncs.bbranchtag configure -state normal
.workdir.bottom.buttons.cvsfuncs.blogfile configure -state normal \
-command { cvs_branches [workdir_list_files] }
.workdir.bottom.buttons.cvsfuncs.bfilelog configure -state normal \
-command { cvs_log [workdir_list_files] }
if {$cvscfg(econtrol)} {
.workdir.bottom.buttons.oddfuncs.bcvsedit_files configure -state normal
.workdir.bottom.buttons.oddfuncs.bunedit_files configure -state normal
}
if {$cvscfg(cvslock)} {
.workdir.bottom.buttons.oddfuncs.block configure -state normal \
-command { cvs_lock lock [workdir_list_files] }
.workdir.bottom.buttons.oddfuncs.bunlock configure -state normal \
-command { cvs_lock unlock [workdir_list_files] }
}
# Menus
.workdir.menubar entryconfigure "CVS" -state normal
.workdir.menubar entryconfigure "SVN" -state disabled
.workdir.menubar entryconfigure "RCS" -state disabled
# Reports Menu
# Check Directory (cvs -n -q update)
.workdir.menubar.reports entryconfigure 0 -state normal \
-command { cvs_check {} }
# Status (cvs -Q status)
.workdir.menubar.reports entryconfigure 1 -state normal \
-command { cvs_status [workdir_list_files] }
# Log (cvs log)
.workdir.menubar.reports entryconfigure 2 -state normal \
-command { cvs_log [workdir_list_files] }
# Annotate/Blame (cvs annotate)
.workdir.menubar.reports entryconfigure 3 -state normal \
-command { cvs_annotate $current_tagname [workdir_list_files] }
}
DirCanvas:create .workdir.main \
-relief flat -bd 0 -highlightthickness 0 \
-width 100 -height 350
set cvsglb(current_selection) {}
set cvscfg(ignore_file_filter) $cvsglb(default_ignore_filter)
if { [ file exists ".cvsignore" ] } {
set fileId [ open ".cvsignore" "r" ]
while { [ eof $fileId ] == 0 } {
gets $fileId line
append cvscfg(ignore_file_filter) " $line"
}
close $fileId
} else {
if {$insvn} {
set cmd(svnpropget) [exec::new "svn propget svn:ignore"]
set contents [split [$cmd(svnpropget)\::output] "\n"]
foreach line $contents {
append cvscfg(ignore_file_filter) " $line"
}
}
}
set filelist [ getFiles ]
directory_list $filelist
gen_log:log T "LEAVE"
}
proc directory_list { filenames } {
global module_dir
global incvs
global insvn
global inrcs
global cvs
global cwd
global cvscfg
global cvsglb
global cmd
global Filelist
gen_log:log T "ENTER ($filenames)"
if {[info exists Filelist]} {
unset Filelist
}
busy_start .workdir.main
#gen_log:log F "processing files in the local directory"
set cwd [pwd]
set my_cwd $cwd
# If we have commands running they were for a different directory
# and won't be needed now. (i.e. this is a recursive invocation
# triggered by a button click)
if {[info exists cmd(cvs_status)]} {
catch {$cmd(cvs_status)\::abort}
catch {unset cmd(cvs_status)}
}
if {[info exists cmd(cvs_editors)]} {
catch {$cmd(cvs_editors)\::abort}
catch {unset cmd(cvs_editors)}
}
# Select from those files only the ones we want (e.g., no CVS dirs)
foreach i $filenames {
if { $i == "." || $i == ".."} {
gen_log:log D "SKIPPING $i"
continue
}
if {[file isdirectory $i]} {
if {[isCmDirectory $i]} {
# Read the bookkeeping files but don't list the directory
if {$i == "CVS" || $i == ".svn" || $i == "RCS"} {
continue
}
}
if {[file exists [file join $i "CVS"]]} {
set Filelist($i:status) "<directory:CVS>"
} elseif {[file exists [file join $i ".svn"]]} {
set Filelist($i:status) "<directory:SVN>"
} elseif {[file exists [file join $i "RCS"]]} {
set Filelist($i:status) "<directory:RCS>"
} else {
set Filelist($i:status) "<directory>"
}
} else {
if {$incvs} {
set Filelist($i:status) "Not managed by CVS"
} else {
set Filelist($i:status) "<file>"
}
}
set Filelist($i:wrev) ""
set Filelist($i:stickytag) ""
set Filelist($i:option) ""
if {[string match "<direc*" $Filelist($i:status)]} {
set Filelist($i:date) ""
} else {
# Prepending ./ to the filename prevents tilde expansion
catch {set Filelist($i:date) \
[clock format [file mtime ./$i] -format $cvscfg(dateformat)]}
}
}
gen_log:log D "incvs=$incvs insvn=$insvn inrcs=$inrcs"
if {$incvs} {
DirCanvas:headtext .workdir.main "editors"
cvs_workdir_status
}
if {$inrcs} {
DirCanvas:headtext .workdir.main "locked by"
rcs_workdir_status
}
if {$insvn} {
DirCanvas:headtext .workdir.main "author"
svn_workdir_status
}
gen_log:log D "Sending all files to the canvas"
foreach i [array names Filelist *:status] {
regsub {:status$} $i "" j
# If it's locally removed or missing, it may not have
# gotten a date especially on a remote client.
if {! [info exists Filelist($j:date)]} {
set Filelist($j:date) ""
}
DirCanvas:newitem .workdir.main "$j"
}
busy_done .workdir.main
gen_log:log T "LEAVE"
}
proc workdir_cleanup {} {
global cvscfg
gen_log:log T "ENTER"
set rmitem ""
set list [ split $cvscfg(clean_these) " " ]
foreach pattern $list {
gen_log:log D "pattern $pattern"
if { $pattern != "" } {
set items [lsort [glob -nocomplain $pattern]]
gen_log:log D "$items"
if {[llength $items] != 0} {
append rmitem " [concat $items]"
}
}
}
if {$rmitem != ""} {
if { [ are_you_sure "You are about to delete:\n" $rmitem] == 1 } {
gen_log:log F "DELETE $rmitem"
eval file delete -force -- $rmitem
}
} else {
gen_log:log F "No files to delete"
cvsok "Nothing matched $cvscfg(clean_these)" .workdir
return
}
setup_dir
gen_log:log T "LEAVE"
}
proc workdir_delete_file {args} {
global cvscfg
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -