home *** CD-ROM | disk | FTP | other *** search
/ PC World 1998 October / PCWorld_1998-10_cd.bin / software / prehled / komix / DATA.Z / ccsysvdbob.tcl < prev    next >
Encoding:
Text File  |  1997-11-20  |  16.5 KB  |  655 lines

  1. #---------------------------------------------------------------------------
  2. #
  3. #      (c)     Cayenne Software Inc.    1997
  4. #
  5. #      File:           @(#)ccsysvdbob.tcl    /main/titanic/14
  6. #      Author:         <generated>
  7. #      Description:
  8. #---------------------------------------------------------------------------
  9. # SccsId = @(#)ccsysvdbob.tcl    /main/titanic/14   20 Nov 1997 Copyright 1997 Cayenne Software Inc.
  10.  
  11. # Start user added include file section
  12. require_module_file "newccfiled.tcl" clearcase
  13. require_module_file "ccsetconfi.tcl" clearcase
  14. require_module_file "cccreatebr.tcl" clearcase
  15. require_module_file "ccdestroyb.tcl" clearcase
  16. require_module_file "ccunchecko.tcl" clearcase
  17. require_module_file "cccheckout.tcl" clearcase
  18. require_module_file "cccheckind.tcl" clearcase
  19. require_module_file "ccnewbranch.tcl" clearcase
  20. require_module_file "ccremovebr.tcl" clearcase
  21. require_module_file "ccchangeco.tcl" clearcase
  22. require_module_file "vssysdialo.tcl" vcm
  23. require_module_file "yesnodialo.tcl" vcm
  24. require platform.tcl
  25. global ClearCaseVersion
  26. set ClearCaseVersion ""
  27. # End user added include file section
  28.  
  29. require_module_file "ccsystem.tcl" clearcase
  30. require_module_file "vssysvdbob.tcl" vcm
  31.  
  32. # This class represents a system with ClearCase files in the browser.
  33.  
  34. Class CCSysVDbObj : {CCSystem VSSysVDbObj} {
  35.     constructor
  36.     method destructor
  37.     method promoter
  38.     method promoteFile
  39.     method path
  40.     method localFileVersions
  41.     method copy
  42.     method addCCFile
  43.     method vsFiles
  44.     method fileList
  45.     method checkOutFiles
  46.     method checkInFiles
  47.     method checkInDirectories
  48.     method unCheckOutFiles
  49.     method createBranch
  50.     method destroyBranch
  51.     method createBranchType
  52.     method destroyBranchType
  53.     method listCheckOuts
  54.     method unreserveFiles
  55.     method reserveFiles
  56.     method changeFileComment
  57.     method showView
  58.     method changeView
  59.     method showConfigSpec
  60.     method changeConfigSpec
  61.     method setConfigSpec
  62.     method configClearmake
  63.     method runClearmake
  64.     method startClearCase
  65.     method initializeVCMVars
  66.  
  67.     # Used to hold information about files in this system:
  68.     # path to Status, Version and Rule. Used for performance reasons.
  69.     #
  70.     attribute ccFileInfoDict
  71. }
  72.  
  73. global CCSysVDbObj::triedViewStart
  74. set CCSysVDbObj::triedViewStart 0
  75.  
  76.  
  77. constructor CCSysVDbObj {class this name i_name} {
  78.     set this [CCSystem::constructor $class $this $name]
  79.     set this [VSSysVDbObj::constructor $class $this $i_name]
  80.     # Start constructor user section
  81.     # End constructor user section
  82.     return $this
  83. }
  84.  
  85. method CCSysVDbObj::destructor {this} {
  86.     # Start destructor user section
  87.     # End destructor user section
  88.     $this CCSystem::destructor
  89.     $this VSSysVDbObj::destructor
  90. }
  91.  
  92.  
  93. # Reuse associations of VSSysVDbObj.
  94. #
  95. proc CCSysVDbObj::associations {} {
  96.     return [VSSysVDbObj::associations]
  97. }
  98.  
  99.  
  100. # Reuse childTypes of VSSysVDbObj.
  101. #
  102. proc CCSysVDbObj::childTypes {assoc} {
  103.     return [VSSysVDbObj::childTypes $assoc]
  104. }
  105.  
  106.  
  107. # Reuse controlledLists of VSSysVDbObj.
  108. #
  109. proc CCSysVDbObj::controlledLists {} {
  110.     return [VSSysVDbObj::controlledLists]
  111. }
  112.  
  113.  
  114. # Reuse info properties of VSSysVDbObj.
  115. #
  116. proc CCSysVDbObj::infoProperties {} {
  117.     return [VSSysVDbObj::infoProperties]
  118. }
  119.  
  120. method CCSysVDbObj::promoter {this} {
  121.     $this ccFileInfoDict [Dictionary new]
  122.     # determine view
  123.     set view [m4_var get M4_ccase_view]
  124.     if { $view == "" } {
  125.     set view [CCCommand::getWorkingView]
  126.     if { $view != "" } {
  127.         m4_var set M4_ccase_view $view
  128.     }
  129.     } else {
  130.     # start view if necessary, make sure to try only once
  131.     if { ![CCCommand::viewIsActive $view] } {
  132.         global CCSysVDbObj::triedViewStart
  133.         if { !${CCSysVDbObj::triedViewStart} } {
  134.         set CCSysVDbObj::triedViewStart 1
  135.         wmtkmessage "Starting view $view..."
  136.         CCCommand::startView $view
  137.         wmtkmessage ""
  138.         }
  139.     }
  140.     }
  141.  
  142.     $this VSSysVDbObj::promoter
  143. }
  144.  
  145.  
  146. # Promotes file to a CCFileUiObj.
  147. #
  148. method CCSysVDbObj::promoteFile {this file} {
  149.     CCFileUiObj promote $file
  150. }
  151.  
  152.  
  153. # Redefine to call path of CCSystem.
  154. #
  155. method CCSysVDbObj::path {this} {
  156.     return [$this CCSystem::path]
  157. }
  158.  
  159.  
  160. # Resolve ambiguity: call localFileVersions of CCSystem.
  161. #
  162. method CCSysVDbObj::localFileVersions {this} {
  163.     return [$this CCSystem::localFileVersions]
  164. }
  165.  
  166.  
  167. # Call copy of VSSysVdbObj.
  168. #
  169. method CCSysVDbObj::copy {this args} {
  170.     eval $this VSSysVDbObj::copy $args
  171. }
  172.  
  173.  
  174. # Pop up dialog for specifying a new ClearCase file.
  175. #
  176. method CCSysVDbObj::addCCFile {this} {
  177.     set box .main.newCCFile
  178.     if { ![isCommand $box] } {
  179.     NewCCFileDialog new $box
  180.     }
  181.     $box popUp
  182. }
  183.  
  184.  
  185. # Redefinition to perform system initialization and cache updates.
  186. #
  187. method CCSysVDbObj::vsFiles {this} {
  188.     # read custom files for this system
  189.     if { ![$this initializedCustomization] } {
  190.     $this initializeCustomization
  191.     }
  192.     eval [[ClientContext::global] getCustomFileContents u_vcm tcl tcl]
  193.     $this initializeVCMVars
  194.  
  195.     # sanity check for view
  196.     if { [m4_var get M4_ccase_view] == "" } {
  197.     wmtkwarning "No view set or specified in M4_ccase_view\nPlease use Change View in the ClearCase menu to select a view"
  198.     return
  199.     } 
  200.  
  201.     set files [$this CCSystem::vsFiles]
  202.     $this updateFileInfo $files
  203.     return $files
  204. }
  205.  
  206.  
  207. # Returns a list of ClearCase controlled files in the
  208. # directories specified by pathList and
  209. # fills ccFileInfoDict with additional info about the files.
  210. #
  211. method CCSysVDbObj::fileList {this pathList} {
  212.     # refresh ccFileInfoDict
  213.     foreach name [[$this ccFileInfoDict] names]  {
  214.     [$this ccFileInfoDict] unset $name
  215.     }
  216.  
  217.     CCCommand::longListing $pathList [$this ccFileInfoDict]
  218.     set fileList {}
  219.     foreach fileName [[$this ccFileInfoDict] names] {
  220.     lappend fileList $fileName
  221.     }
  222.  
  223.     return $fileList
  224. }
  225.  
  226.  
  227. # Pops up checkout dialog to specify comments and checks out the selected files.
  228. # Reserved indicates the type of checkout requested.
  229. #
  230. method CCSysVDbObj::checkOutFiles {this reserved} {
  231.     if { ![isCommand .main.checkout] } {
  232.     CCCheckOutDialog new .main.checkout
  233.     }
  234.  
  235.     .main.checkout reserved $reserved
  236.     .main.checkout popUp
  237. }
  238.  
  239.  
  240. # Pops up dialog to specify comments for selected files. A check button
  241. # allows reuse of the checkout comments.
  242. #
  243. method CCSysVDbObj::checkInFiles {this} {
  244.     if [isCommand .main.checkin] {
  245.     set newSelection [.main selectedObjSet]
  246.     set oldSelection [.main.checkin selectedFiles]
  247.     if { [llength $oldSelection] != [llength $newSelection] } {
  248.         .main.checkin.col delete
  249.         .main.checkin delete
  250.     }
  251.     }
  252.  
  253.     if { ![isCommand .main.checkin] } {
  254.     CCCheckInDialog new .main.checkin
  255.     }
  256.  
  257.     .main.checkin popUp
  258. }
  259.  
  260.  
  261. # Collects directories in system path that
  262. # are checked out, lists them for confirmation
  263. # and checks them in.
  264. #
  265. method CCSysVDbObj::checkInDirectories {this} {
  266.     # get paths
  267.     set pathList {}
  268.     foreach file [$this CCSystem::vsFiles] {
  269.     set filePath [path_name directory [$file path]]
  270.     set existsInList 0
  271.     foreach path $pathList {
  272.         if { [file split $path] == [file split $filePath] } {
  273.         set existsInList 1
  274.         }
  275.     }
  276.     if !$existsInList {
  277.         lappend pathList $filePath
  278.     }
  279.     }
  280.  
  281.     # get checked out directories
  282.     set checkedOutList {}
  283.     while { [llength $pathList] > 0 } {
  284.     set newPaths {}
  285.     foreach path $pathList {
  286.         if [CCCommand::isCheckedOut $path] {
  287.         lappend newPaths [path_name directory $path]
  288.         lappend checkedOutList $path
  289.         }
  290.     }
  291.     set pathList $newPaths
  292.     }
  293.  
  294.     if { ![llength $checkedOutList] } {
  295.     wmtkinfo "The directories of this system are checked in"
  296.     return
  297.     }
  298.     
  299.     if { ![isCommand .main.checkindirectories] } {
  300.     require_module_file "ccdircheck.tcl" clearcase
  301.     CCDirCheckInDialog new .main.checkindirectories
  302.     }
  303.  
  304.     .main.checkindirectories directories $checkedOutList
  305.     .main.checkindirectories popUp
  306. }
  307.  
  308.  
  309. # Pops up dialog to ask whether a private copies must be kept and 
  310. # removes the checkouts of the files.
  311. #
  312. method CCSysVDbObj::unCheckOutFiles {this} {
  313.     if { ![isCommand .main.uncheckout] } {
  314.     CCUncheckOutDialog new .main.uncheckout
  315.     }
  316.  
  317.     .main.uncheckout popUp
  318. }
  319.  
  320.  
  321. # Pops up a dialog that allows selection of a branch and specification of a comment.
  322. #
  323. method CCSysVDbObj::createBranch {this} {
  324.     set branches [CCCommand::getBranchTypes [$this path]]
  325.     if { $branches == "" } {
  326.     vsCommandHandler error "There are no branches to select from"
  327.     return
  328.     }
  329.  
  330.     if { ![isCommand .main.createbranch] } {
  331.     CCCreateBranchDialog new .main.createbranch
  332.     }
  333.  
  334.     .main.createbranch branches $branches
  335.     .main.createbranch popUp
  336. }
  337.  
  338.  
  339. # Pops up confirmation dialog and removes branch if requested.
  340. #
  341. method CCSysVDbObj::destroyBranch {this} {
  342.     set selectedFile [lindex [.main selectedObjSet] 0]
  343.     set extendedPath "[$selectedFile path]\@\@[$selectedFile getInfo Version]"
  344.     # strip version number to get branch name
  345.     regsub {[\\\/][0-9]+} $extendedPath "" branch
  346.  
  347.     if { ![isCommand .main.destroybranch] } {
  348.     CCDestroyBranchDialog new .main.destroybranch
  349.     }
  350.  
  351.     set warning [CCCommand::getRemoveBranchWarning $branch]
  352.     if { $warning == "" } {
  353.     return
  354.     }
  355.  
  356.     .main.destroybranch message $warning
  357.     .main.destroybranch branch $branch
  358.     .main.destroybranch popUp
  359. }
  360.  
  361.  
  362. # Pops up dialog to specify branch name and creation comments.
  363. # Branch is created in vob indicated by system path.
  364. #
  365. method CCSysVDbObj::createBranchType {this} {
  366.     if { ![isCommand .main.createbranchtype] } {
  367.     CCNewBranchDialog new .main.createbranchtype
  368.     }
  369.  
  370.     .main.createbranchtype vobPath [$this path]
  371.     .main.createbranchtype popUp
  372. }
  373.  
  374.  
  375. # Pops up list of branches and destroy selected branches.
  376. #
  377. method CCSysVDbObj::destroyBranchType {this} {
  378.     set branches [CCCommand::getBranchTypes [$this path]]
  379.     if { $branches == "" } {
  380.     vsCommandHandler error "There are no branches to select from"
  381.     return
  382.     }
  383.  
  384.     if { ![isCommand .main.destroybranchtype] } {
  385.     CCRemoveBranchTypeDialog new .main.destroybranchtype
  386.     }
  387.  
  388.     .main.destroybranchtype vobPath [$this path]
  389.     .main.destroybranchtype branches $branches
  390.     .main.destroybranchtype popUp
  391. }
  392.  
  393.  
  394. # Pops up an information dialog with the checkouts of all selected files.
  395. #
  396. method CCSysVDbObj::listCheckOuts {this} {
  397.     set selectedFilePath [[lindex [.main selectedObjSet] 0] path]
  398.     set checkOutCommand [CCCommand::listCheckout $selectedFilePath]
  399.     if { ![vsCommandHandler executeSilent $checkOutCommand] } {
  400.     return
  401.     }
  402.  
  403.     set checkOuts "[$checkOutCommand output]"
  404.     if { $checkOuts == "" } {
  405.     set checkOuts "None"
  406.     }
  407.  
  408.     set message "Checkouts of $selectedFilePath:\n\n$checkOuts"
  409.     wmtkinfo "$message"
  410. }
  411.  
  412.  
  413. # Changes the checkout status of the files from reserved to unreserved.
  414. #
  415. method CCSysVDbObj::unreserveFiles {this} {
  416.     if { ![isCommand .main.unreserve] } {
  417.     VSSysDialog new .main.unreserve
  418.     .main.unreserve vsMethod { $file unreserve }
  419.     }
  420.  
  421.     .main.unreserve selectedFiles [.main selectedObjSet]
  422.     .main.unreserve processFiles
  423. }
  424.  
  425.  
  426. # Changes the checkout status of the files from unreserved to reserved.
  427. #
  428. method CCSysVDbObj::reserveFiles {this} {
  429.     if { ![isCommand .main.reserve] } {
  430.     VSSysDialog new .main.reserve
  431.     .main.reserve vsMethod { $file reserve }
  432.     }
  433.  
  434.     .main.reserve selectedFiles [.main selectedObjSet]
  435.     .main.reserve processFiles
  436. }
  437.  
  438.  
  439. # Pops up a dialog with the old comment of the file and allows edit.
  440. #
  441. method CCSysVDbObj::changeFileComment {this} {
  442.     if { ![isCommand .main.changecomment] } {
  443.     CCChangeCommentDialog new .main.changecomment
  444.     }
  445.  
  446.     .main.changecomment popUp
  447. }
  448.  
  449.  
  450. # Show the current view in an information dialog.
  451. #
  452. method CCSysVDbObj::showView {this} {
  453.     set view [m4_var get M4_ccase_view]
  454.     if { $view == "" } {
  455.     set view "None"
  456.     }
  457.  
  458.     InfoDialog new .main.viewinfo \
  459.         -title "Current view" \
  460.         -message "$view" \
  461.         -okPressed { %this delete }
  462.  
  463.     .main.viewinfo delHelpButton
  464.     .main.viewinfo popUp
  465. }
  466.  
  467.  
  468. # Shows a list with active views and allows selection of a view or specification of a different one.
  469. # Sets the view if possible.
  470. #
  471. method CCSysVDbObj::changeView {this} {
  472.     set views [CCCommand::getActiveViews]
  473.     set currentView [m4_var get M4_ccase_view]
  474.     $this updatePath
  475.     interface TemplateDialog .main.activeviews {
  476.     title "Change View"
  477.     modal 1
  478.     DropDwnComboBox viewlist { 
  479.     }
  480.     }
  481.  
  482.     .main.activeviews.viewlist config \
  483.         -entrySet $views \
  484.         -text $currentView
  485.  
  486.     .main.activeviews okPressed {
  487.     set selectedView [string trim [%this.viewlist text]]
  488.     # check if specified view was one of the active views
  489.     set viewOk 0
  490.     if { [lsearch [%this.viewlist entrySet] $selectedView] != -1 } {
  491.         set viewOk 1
  492.     } else {
  493.         # specified view was not active, try to start it
  494.         if [CCCommand::startView $selectedView] {
  495.         set viewOk 1
  496.         }
  497.     }
  498.  
  499.     if { $viewOk } {
  500.         m4_var set M4_ccase_view $selectedView
  501.         .main updateView
  502.     }
  503.     %this delete
  504.     }
  505.  
  506.     .main.activeviews delHelpButton
  507.     .main.activeviews popUp
  508. }
  509.  
  510.  
  511. # Shows the config spec of the current view.
  512. #
  513. method CCSysVDbObj::showConfigSpec {this} {
  514.     set view [m4_var get M4_ccase_view]
  515.     if { $view == "" } {
  516.     vsCommandHandler error "No view specified"
  517.     return
  518.     }
  519.  
  520.     set configSpec [CCCommand::getConfigSpec $view]
  521.     # error handling is done by getConfigSpec so return if
  522.     # the config spec is empty
  523.     if { $configSpec == "" } {
  524.     return
  525.     }
  526.  
  527.     InfoDialog new .main.configspec \
  528.         -title "Config spec" \
  529.         -message $configSpec \
  530.         -okPressed { %this delete }
  531.  
  532.     .main.configspec delHelpButton
  533.     .main.configspec popUp
  534. }
  535.  
  536.  
  537. # Allows edit of the config spec of the current view and sets it after confirmation.
  538. #
  539. method CCSysVDbObj::changeConfigSpec {this} {
  540.     set view [m4_var get M4_ccase_view]
  541.     if { $view== "" } {
  542.     vsCommandHandler error "No view specified"
  543.     return
  544.     }
  545.  
  546.     # get config spec, copy to temporary file and start editor
  547.     set currentConfigSpec [CCCommand::getConfigSpec $view]
  548.     set tmpFile [args_file {}]
  549.     BasicFS::writeFile $tmpFile $currentConfigSpec
  550.     .main startM4Command editor "$tmpFile" \
  551.         "$this setConfigSpec [list $tmpFile]" "$tmpFile"
  552. }
  553.  
  554.  
  555. # Sets the config spec of the current view to the
  556. # the specified file.
  557. #
  558. method CCSysVDbObj::setConfigSpec {this configSpecFile} {
  559.     # callback from config spec editor
  560.     set view [m4_var get M4_ccase_view]
  561.  
  562.     # this dialog asks confirmation and sets config spec
  563.     CCSetConfigSpecDialog new .main.setconfigspec \
  564.         -view $view \
  565.         -file $configSpecFile
  566.  
  567.     .main.setconfigspec popUp
  568. }
  569.  
  570.  
  571. # Sets the options for running clearmake.
  572. #
  573. method CCSysVDbObj::configClearmake {this} {
  574.     if $win95 {
  575.     set makeCommand "Omake"
  576.     } else {
  577.     set makeCommand "Clearmake"
  578.     }
  579.  
  580.     interface EntryDialog .main.configclearmake {
  581.     modal 1
  582.     }
  583.  
  584.     .main.configclearmake config \
  585.     -title "Configure $makeCommand" \
  586.     -message "Default $makeCommand options:"
  587.     .main.configclearmake entry [m4_var get M4_cmake_options]
  588.     .main.configclearmake okPressed {
  589.     set options [%this entry]
  590.     m4_var set M4_cmake_options $options
  591.     }
  592.  
  593.     .main.configclearmake delHelpButton
  594.     .main.configclearmake popUp
  595.     
  596. }
  597.  
  598.  
  599. # Run the clearcase make command in an mtool.
  600. # Clearmake for Unix and Omake for Windows.
  601. #
  602. method CCSysVDbObj::runClearmake {this} {
  603.     if $win95 {
  604.     set makeCommand "omake"
  605.     } else {
  606.     set makeCommand "clearmake"
  607.     }
  608.     set message "Starting $makeCommand"
  609.     
  610.     # get options
  611.     set options [m4_var get M4_cmake_options]
  612.     if { $options != "" } {
  613.     append makeCommand " $options"
  614.     }
  615.  
  616.     set dir [$this makeFilePath]
  617.     .main startCommand mtool $makeCommand "" $message {0 0} 0 [list $dir]
  618. }
  619.  
  620.  
  621. # Starts the graphical clearcase environment in the system path.
  622. #
  623. method CCSysVDbObj::startClearCase {this} {
  624.     set fileArg "\-file [quoteIf [$this path]]"
  625.     if $win95 {
  626.         global ClearCaseVersion
  627.         if { $ClearCaseVersion == "" } {
  628.             set ClearCaseVersion [CCCommand::getClearCaseVersion]
  629.         }
  630.         regsub -all {\.} $ClearCaseVersion "" version
  631.         set version [string range $version 0 1]
  632.         if { $version >= "31" } {
  633.             set command "cleardetails"
  634.         set fileArg "[quoteIf [$this path]]"
  635.         } else {
  636.             set command "wclearcase"
  637.         }
  638.     } else {
  639.     set command "xclearcase"
  640.     }
  641.  
  642.     set command "$command $fileArg"
  643.     system "$command &"
  644. }
  645.  
  646.  
  647. # Not needed for ClearCase.
  648. #
  649. method CCSysVDbObj::initializeVCMVars {this} {
  650.     #empty
  651. }
  652.  
  653. # Do not delete this line -- regeneration end marker
  654.  
  655.