;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; File: CDS_P4Triggers.il ; Description: Main Trigger Code for CDSP4 ; Author: Shiv Sikand ; Created: Jul 21 23:10 00 ; Modified: ; Language: Skill ; MainFun: N/A ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright (c) 2000, Perforce Software, All rights reserved. ; ; This software was originally developed by Silicon Graphics, Inc (SGI). ; ; Redistribution and use in source and binary forms, with or ; without modification, are permitted provided that the following ; conditions are met: ; ; Redistributions of source code must retain the above copyright notice, ; this list of conditions and the following disclaimer. ; ; Redistributions in binary form must reproduce the above copyright ; notice, this list of conditions and the following disclaimer in the ; documentation and/or other materials provided with the distribution. ; ; Neither name of Perforce Software nor SGI nor the names of its ; contributors may be used to endorse or promote products derived from ; this software without specific prior written permission. ; ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ; ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR ; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ; EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, ; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR ; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. procedure(CDS_P4SetupP4() ;_Dec 17 01 sikand 0 let(( p4VerFull p4Ver ) p4VerFull="$Id: //depot/tools/skill/dm/CdsP4Core/CDS_P4Triggers.il#3 $" p4Ver=head(parseString(cadr(parseString(p4VerFull "#")) " ")) printf("P4 Interface-ver #%s.\n" p4Ver) CDS_P4CheckLocalConfig() ;; set up the server printf("Starting p4skillserver\n"); CDS_P4ServerId = ipcBeginProcess("p4skillserver") sleep(5) unless( ipcIsAliveProcess(CDS_P4ServerId) error("STOP: Fatal DM System failed to initialize !!!") ) printf("p4skillserver is alive\n"); ;; trigger registration ddRegTrigger("PostCreateLib" 'CDS_P4PostCreateLib) ddRegTrigger("PreDeleteObj" 'CDS_P4PreDeleteObj) ddRegTrigger("PostDeleteObj" 'CDS_P4DeleteObj) ddRegTrigger("PostCreateObj" 'CDS_P4PostCreateObj) ddRegTrigger("PreCheckout" 'CDS_P4PreCheckout) ddRegTrigger("PreCheckin" 'CDS_P4PreCheckin) ddRegTrigger("PostCheckin" 'CDS_P4PostCheckin) ;;ddRegTrigger("FirstAccessLib" 'CDS_P4FirstAccess 1) t ) ; ** let ** ) ; ** procedure CDS_P4SetupP4 ** procedure(CDS_P4SetGlobals() ;_Sep 3 02 sikand 0 ;; get the hostname let((client root branch status) ;; no user servicable parts here CDS_IPCBufferProcess("uname -n") CDS_P4Host = car(parseString(CDS_IPCBuffer "\n")) CDS_P4CurrentClient = "unknown" CDS_P4GroupCheckin = makeTable("CDS_P4GroupCheckin") CDS_P4WindowEditTable = makeTable("CDS_P4WindowEditTable" nil) CDS_P4Lib = nil CDS_P4LibDeleteList = nil CDS_P4LibMode = nil CDS_P4LibClient = nil CDS_P4DelList = nil CDS_P4MultiSelect = nil CDS_P4UserFileName = sprintf(nil "%s.%d" getLogin() ipcGetPid()) CDS_P4User = getLogin() CDS_P4LogFile=simplifyFilename(strcat(getWorkingDir() "/p4.log." CDS_P4User)) ;; set up the log file for all the user visible transactions if( isFile(CDS_P4UserFileName) CDS_IPCCommand(strcat("mv " CDS_P4LogFile " " CDS_P4LogFile ".bak")) ) CDS_P4Port = outfile(strcat(getWorkingDir() "/p4.log." CDS_P4User) "w") if( branch = getShellEnvVar(CDS_P4ProjectBranchEnvVar) then CDS_P4CurrentBranch = branch ;; need the branch root client = strcat(branch "_client") status = CDS_IPCBufferProcess(strcat("p4 -c " client " client -o | grep \\^Root")) unless( status == 0 error("Could not run P4 command...\n") ) root = cadr(parseString(CDS_IPCBuffer)) CDS_P4MasterClientFile = strcat(root CDS_P4MasterClientRelLocation) else unless(CDS_Project error("CDS_Project is undefined, aborting!") ) CDS_P4MasterClientFile = strcat(getShellEnvVar(CDS_P4ProjectEnvVar) CDS_P4MasterClientRelLocation) CDS_P4CurrentBranch=strcat(CDS_Project "_" CDS_ProjectRev) ) ; ** if branch ** ;; read the cds.lib file and build the cds.p4clients file CDS_P4BuildClientNames() ;; build the permissions CDS_P4Permissions(?quiet t) ) ; ** let ** ) ; ** procedure CDS_P4SetGlobals ** procedure(CDS_P4FirstAccess(libid) ;_Dec 9 99 sikand 239 ; trigger for first access of a lib prog(() ;; is it a Perforce controlled object when( ddGetObjDMSys(libid) != "p4" return() ) ;; clean up empty dirs CDS_P4CleanEmpty(libid) ;;find . -type d -print | sort -r | xargs rmdir ) ; ** prog ** ) ; ** procedure CDS_P4FirstAccess ** procedure(CDS_P4CleanEmpty(libid) ;_Jun 29 01 sikand 0 ; clean up empty dirs let(( cmd status) printf("Cleaning up library catalog for %s in background id: " libid~>name) cmd = sprintf(nil "cd %s ; find . -type d -print | sort -r | xargs rmdir > /dev/null 2>&1" libid~>writePath) status = CDS_IPCNoWaitCommand(cmd) t ) ; ** let ** ) ; ** procedure CDS_P4CleanEmpty ** procedure(CDS_P4SyncLib(libid) ;_Nov 14 01 sikand 604 ; Synchronize libraries every session ; libid ddid of library ; Returns t/nil prog(( status client) ;; is it a Perforce controlled object when( ddGetObjDMSys(libid) != "p4" warn("%s not a DM controlled library\n" libid~>name) return() ) when(client = CDS_P4GetClient(libid) CDS_P4CurrentClient = client printf("Syncing library %s, please wait..." libid~>name) ;; frpintf(CDS_P4Port "Syncing library %s\n" libid~>name) status = CDS_P4IPCCommand("-o /dev/null sync") unless( zerop(status) CDS_P4Error("P4 Interface" strcat("Failed to sync library " libid~>name " with depot")) return(nil) ) printf("done\n") return(t) ) ; ** when client ** ) ; ** prog ** ) ; ** procedure CDS_P4SyncLib ** procedure(CDS_P4Error(message1 message2) ;_Jun 17 99 sikand 0 when( hiGraphicMode() hiGetAttention() ) ;;drain(CDS_P4Port) error("ERROR: %s : %s\n",message1 message2) nil ) ; ** procedure CDS_P4Error ** procedure(CDS_P4RevisionLib(formid) ;_Mar 18 03 jdao 1051 ; revision an existing library prog(( command ddid client root libType chip user status p4clients p4cnames errormessage libname bagId cfilen cfile libflist viewspec dspec libff fport fileoport lin filename cellflist cellff dmobj viewflist thiscell maxcells custom viewff userdata blockname binfo) thiscell = 0 ddid = formid->appData client = formid->clientNameField->value root = formid->clientRootField->value libType = formid->libType->value chip = formid->chipOption->value custom= formid->customField->value blockname = formid->blockNameField->value when( custom == "" custom = nil ) user = CDS_P4User userdata = "" /* Set the dm type */ /* Create a p4 client unless it already exists */ CDS_P4CurrentClient=client /* Read the p4 client */ libname = ddid~>name binfo = getShellEnvVar(CDS_P4ProjectBranchEnvVar) when( blockname == "" && libType != "Bulk" ;; store all bulk libraries flat in generated tree CDS_ErrorDialogBox("P4 Revision Lib" "Please choose a block hierarchy!") error("Revision lib aborted due to empty block name") ) printf("Registering library with p4, please wait\n") ;; define the View spec when( libType == "Bulk" userdata = "bulk" if( binfo then sprintf(viewspec "//depot/%s/cadence/generated/%s/... //%s/..." binfo libname client) else sprintf(viewspec "//depot/%s/%s/cadence/generated/%s/%s/... //%s/..." CDS_Project CDS_ProjectRev libname client) ) ; ** if binfo ** ;; save the type in the library bagId = dbOpenBag(ddid "a") unless( bagId error("Property bag error -- check permissions!\n") ) bagId~>p4type= "Bulk" bagId~>p4CheckinType = "Bulk" dbSaveBag(bagId) dbCloseBag(bagId "a") CDS_P4SetClient(ddid~>lib client "User") ) ; ** when libType ** when( libType == "Reference" ;;sprintf(client "%s:%s%s%s" libname CDS_Project "_" CDS_ProjectRev) if( custom then sprintf(viewspec "%s //%s/..." custom client) else if( binfo then sprintf(viewspec "//depot/%s/cadence/reference/%s/%s/... //%s/..." binfo blockname libname client) else sprintf(viewspec "//depot/%s/%s/cadence/reference/%s/%s/... //%s/..." CDS_Project CDS_ProjectRev blockname libname client) ) ; ** if binfo ** ) ; ** if custom ** bagId = dbOpenBag(ddid "a") unless( bagId error("Property bag error -- check permissions!\n") ) bagId~>p4type= "Reference" dbSaveBag(bagId) dbCloseBag(bagId "a") ;; save the client name in the library CDS_P4SetClient(ddid~>lib client "Reference") ) ; ** when libType ** when( libType == "Design" ;;sprintf(client "%s:%s%s%s" libname CDS_Project "_" CDS_ProjectRev) if( custom then sprintf(viewspec "%s //%s/..." custom client) else if( binfo then sprintf(viewspec "//depot/%s/cadence/%s/%s/... //%s/..." binfo blockname libname client) else sprintf(viewspec "//depot/%s/%s/cadence/%s/%s/... //%s/..." CDS_Project CDS_ProjectRev blockname libname client) ) ; ** if binfo ** ) ; ** if custom ** bagId = dbOpenBag(ddid "a") unless( bagId error("Property bag error -- check permissions!\n") ) bagId~>p4type= "Design" dbSaveBag(bagId) dbCloseBag(bagId "a") CDS_P4SetClient(ddid~>lib client "Design") ) ; ** when libType ** ;;libpath = CDS_NFSSimplify(ddid~>writePath) if( binfo then sprintf(dspec "Description: %s %s cds library" binfo userdata) else sprintf(dspec "Description: %s %s %s cds library" CDS_Project CDS_ProjectRev userdata) ) ;; Create the client spec in a temp file cfilen = strcat("/tmp/cspec." CDS_P4UserFileName) cfile = outfile(cfilen) println(client) println(root) println(viewspec) println(dspec) if( libType == "Bulk" then fprintf(cfile "Client:%s\nRoot:%s \nOptions:\t allwrite\nView:%s\n%s\n" client CDS_NFSSimplify(root) viewspec dspec) else fprintf(cfile "Client:%s\nRoot:%s \nView:%s\n%s\n" client CDS_NFSSimplify(root) viewspec dspec) ) ; ** if libType ** close(cfile) fprintf(CDS_P4Port "\nBuilding client %s\n" client) status = CDS_P4IPCCommand(strcat("-i " cfilen " client -i")) when( zerop(status) ;; get the list of files in the library and add them ;; add and submit the library files only libflist = setof(x ddid~>files~>writePath ! (rexMatchp("%" x) || rexMatchp("\\.cd-" x))) libflist = foreach( mapcan x libflist list(CDS_NFSSimplify(x)) ) ;; frpintf(CDS_P4Port "\nSubmit request for add lib %s" ddid~>name) libff = outfile(strcat("/tmp/libf." CDS_P4UserFileName)) fport = outfile(strcat("/tmp/cl." CDS_P4UserFileName)) fprintf( fport "\nChange: new\n\nDescription: \tcds:Add lib\n\n\n\nFiles:\n\t") foreach( libf libflist ;; reject empty files and the cdsinfo.tag unless( rexMatchp(libf "cdsinfo.tag") ;; write the list of files to a file fprintf(libff "%s\n" libf) ) ) ; ** foreach libf ** close(libff) ;; add the files sprintf(command "-x /tmp/libf.%s add" CDS_P4UserFileName) status = CDS_P4IPCCommand(command) when( rexMatchp("can't add existing" CDS_IPCBuffer) error(CDS_IPCBuffer) ) when( zerop(status) ;; get the depot name of the files so we can ;; build the change list for the submit sprintf(command "-o /tmp/p4open.%s -x /tmp/libf.%s opened" CDS_P4UserFileName CDS_P4UserFileName) status = CDS_P4IPCCommand(command) when( zerop(status) ;; read in the open list and build a cl fileoport = infile(strcat("/tmp/p4open." CDS_P4UserFileName)) while( gets(lin fileoport) filename = car(parseString(lin)) unless( rexMatchp("cdsinfo.tag" filename) fprintf(fport "%s\n\t" filename) ) ) ; ** while gets ** fprintf(fport "\n") close(fport) close(fileoport) ;; submit the change list that we have just created status = CDS_P4Submit(strcat("Library add " ddid~>name) strcat("/tmp/cl." CDS_P4UserFileName) ddid) ;; now submit the rest of the files in the library ;; on a cell by cell basis when( zerop(status) maxcells = length(ddid~>cells) foreach( cell ddid~>cells ;; submit the cell files cellflist = setof(x cell~>files~>writePath ! (rexMatchp("%" x) || rexMatchp("\\.cd-" x))) cellflist = foreach( mapcan x cellflist list(CDS_NFSSimplify(x)) ) if( cellflist then cellff = outfile(strcat("/tmp/cellf." CDS_P4UserFileName)) fport = outfile(strcat("/tmp/cl." CDS_P4UserFileName) "w") fprintf( fport "\nChange: new\n\nDescription: \tcds:Add lib (cell %s)\n\n\n\nFiles:\n\t" cell~>name) foreach( cellf cellflist ;; write the list of files to a file fprintf(cellff "%s\n" cellf) ) ;; add the cell files close(cellff) sprintf(command "-x /tmp/cellf.%s add" CDS_P4UserFileName) status = CDS_P4IPCCommand(command) when( zerop(status) ;; submit the files ;; get the depot name of the files so we can ;; build the change list for the submit sprintf(command "-o /tmp/p4open.%s -x /tmp/cellf.%s opened" CDS_P4UserFileName CDS_P4UserFileName) status = CDS_P4IPCCommand(command) when( zerop(status) ;; read in the open list and build a cl fileoport = infile(strcat("/tmp/p4open." CDS_P4UserFileName)) while( gets(lin fileoport) filename = car(parseString(lin)) fprintf(fport "%s\n\t" filename) ) fprintf(fport "\n") close(fport) close(fileoport) ;; submit the change list that we have just created status = CDS_P4Submit(strcat("Library cell files add: " ddid~>name) strcat("/tmp/cl." CDS_P4UserFileName) ddid) ) ; ** when zerop ** ) ; ** when zerop ** ) ; ** if cellflist ** foreach( view cell~>views ;; submit the cell files viewflist = setof(x view~>files~>writePath !(rexMatchp("%" x) || rexMatchp("\\.cd-" x))) viewflist = foreach( mapcan x viewflist list(CDS_NFSSimplify(x)) ) if( viewflist then viewff = outfile(strcat("/tmp/viewf." CDS_P4UserFileName)) fport = outfile(strcat("/tmp/cl." CDS_P4UserFileName) "w") fprintf( fport "\nChange: new\n\nDescription: \tcds:Add lib (cell %s, view %s)\n\n\n\nFiles:\n\t" cell~>name view~>name) foreach( viewf viewflist ;; write the list of files to a file fprintf(viewff "%s\n" viewf) ) ;; add the view files close(viewff) sprintf(command "-x /tmp/viewf.%s add" CDS_P4UserFileName) status = CDS_P4IPCCommand(command) when( zerop(status) ;; submit the files ;; get the depot name of the files so we can ;; build the change list for the submit sprintf(command "-o /tmp/p4open.%s -x /tmp/viewf.%s opened" CDS_P4UserFileName CDS_P4UserFileName) status = CDS_P4IPCCommand(command) when( zerop(status) ;; read in the open list and build a cl fileoport = infile(strcat("/tmp/p4open." CDS_P4UserFileName)) while( gets(lin fileoport) filename = car(parseString(lin)) fprintf(fport "%s\n\t" filename) ) fprintf(fport "\n") close(fport) close(fileoport) ;; submit the change list that we have just created status = CDS_P4Submit(strcat("Library view files add: " ddid~>name) strcat("/tmp/cl." CDS_P4UserFileName) ddid) ) ; ** when zerop ** ) ; ** when zerop ** ) ; ** if viewflist ** printf("Revisioned cell %s, view %s\n" cell~>name view~>name) ) ; ** foreach view ** thiscell++ printf("Revisioned cell %d of %d: %s\n" thiscell maxcells cell~>name) ) ; ** foreach cell ** when( zerop(status) ;; set the DM system status = CDS_ddSetLibDMSys(ddid "p4") if( !status then ;; permissions on this file were probably ;; screwed printf("Trying to fix permissions for cdsinfo.tag file\n") dmobj = ddGetObj(ddid~>name "" "" "cdsinfo.tag") status = CDS_IPCCommand(strcat("chmod a+rwx " dmobj~>writePath)) unless( zerop(status) CDS_P4Error("P4 Interface" "Giving up, please fix dm.tag manually!") ) ) ; ** if status ** ;; checkin the file dmobj = ddGetObj(ddid~>name "" "" "cdsinfo.tag") ddCheckin(dmobj "p4 dm") ;; rebuild the clients files CDS_P4BuildClientNames() printf("Library %s successfully revisioned\n" ddid~>name) return(t) ) ; ** when zerop ** ) ; ** when zerop ** ) ; ** when zerop ** ) ; ** when zerop ** ) ; ** when zerop ** CDS_P4Error("P4 add library" "Failed to initialize library") return() ) ; ** prog ** ) ; ** procedure CDS_P4RevisionLib ** procedure(CDS_P4MakeLocalCopy(ddid newroot @optional csuffix) ;_Jun 17 99 sikand 1734 ; Clone a user/design library ; ddid lib id ; Returns t/nil prog(( command type status client newPath oclient p4clients p4cnames errormessage) ;; are you the owner ? when( ddid~>owner == CDS_P4User && hiGraphicMode() unless(CDS_WarnDialogBox("Make local client" "You are already the owner..are you sure ?") return() ) ) ;; is it a Perforce controlled object when( ddGetObjDMSys(ddid) != "p4" CDS_P4Error("P4 Interface" strcat("Library " ddid~>name " is not under p4 DM control!")) return() ) ;; get the library type type = ddid~>p4type ;;oclient = ddid~>p4client oclient = CDS_P4GetClient(ddid) unless( newroot CDS_P4Error("P4 Interface" "Root directory was not specified!") return() ) unless( isDir(newroot) CDS_P4Error("P4 Interface" "Root directory does not exist!") return() ) newroot = CDS_NFSSimplify(newroot) when( type == "User" || type == "Design" || type == "Reference" ;; create a local client printf("Creating local workarea for library %s\n", ddid~>name) if( csuffix then sprintf(client "copy:%s:%s:%s" ddid~>name CDS_P4User csuffix) else sprintf(client "copy:%s:%s" ddid~>name CDS_P4User) ) printf("New client name is %s\n" client) ;; need to get the view mapping for this client ;; and map it to our new client CDS_P4CurrentClient=client ;; need to setup the root of the new client ;; to the user specified area ;; client may already exist ;; frpintf(CDS_P4Port "\nRequesting client list\n") status = CDS_P4IPCBufferProcess("clients") unless( zerop(status) println("p4 client failed, abort\n") return() ) when( CDS_IPCBuffer p4clients = parseString(CDS_IPCBuffer "\n") ) when( p4clients p4cnames = foreach( mapcan x p4clients list(cadr(parseString(x))) ) ) if( member(client p4cnames) then errormessage = strcat("Abort: " client " already exists") CDS_P4Error("Library creation p4 registration" errormessage) return() ) newPath = strcat(CDS_NFSSimplify(newroot) "/" ddid~>name) ;;| p4 client -i | p4 sync" newroot client) sprintf(command "p4 -d %s -c %s client -o -t %s | p4 -c %s client -i" newPath client oclient client) status = CDS_IPCCommand(command) unless( zerop(status) CDS_P4Error("P4 Interface" "Client creation error!") return() ) status = CDS_P4IPCCommand("sync") unless( zerop(status) CDS_P4Error("P4 Interface" "Client sync error, please check p4.log...") return() ) printf("Client sucessfully synced\n") ;; modify the cds.lib file printf("Updating cds.lib file\n") CDS_P4SwapCdsLib(ddid~>name newPath) ;; save the client name CDS_P4SetClient(ddid client "ignore") ;; refresh lbb return(t) ) ; ** when type ** ) ; ** prog ** ) ; ** procedure CDS_P4MakeLocalCopy ** procedure(CDS_P4SwapCdsLib(libname newPath @optional delete) ;_Nov 5 99 sikand 0 ; change path references in a cds.lib file let(( lin file ofile newmap mapped matched) file = infile("./cds.lib") ofile = outfile("cds.lib.p4") while( gets(lin file) newmap = lin matched = nil ;; match define lines in the cds.lib file rexCompile("\\(DEFINE \\)\\([A-Z0-9_a-z:\\- ]+\\).") when( rexExecute(lin) when( rexSubstitute("\\2") == libname newmap = strcat(rexSubstitute("\\1") libname " " newPath "\n") mapped = t matched = t ) ) ; ** when rexExecute ** unless( matched && delete fprintf(ofile "%s" newmap) ) ) ; ** while gets ** close(ofile) close(file) ;; swap out the files unless( mapped warn("Failed to update cds.lib file, is the library defined as an INCLUDE ?") CDS_P4Error("P4 Interface" strcat("Please update your cds.lib file manually to DEFINE " libname " " newPath)) ) ; ** unless mapped ** sh("mv cds.lib cds.lib.bak ; mv cds.lib.p4 cds.lib") ;; refresh the library list ;; update the lib list ddSetForcedLib("cds.lib") unless(ddUpdateLibList() CDS_P4Error("P4 Interface" "Update lib list failed...") ) ;; rebuild the cds.p4client file ;; unless(CDS_P4Refresh() ;; CDS_P4Error("P4 Interface" "Failed to refresh") ;; ) ) ; ** let ** ) ; ** procedure CDS_P4SwapCdsLib ** procedure( CDS_P4PostCreateLib(libname dmfile ddid @optional dmsys libType) ;_Oct 14 00 sikand 0 prog(( status user client file formLibType bagId p4clients p4cnames viewspec dspec cmd errormessage libpath cfilen cfile chip type userdata block ) CDS_P4DelList = nil userdata = "" if( !dmsys then if( boundp('CDS_lbbAskForLibNameForm) then when(CDS_lbbAskForLibNameForm->dmOption->value != "p4" return(t) ) else return(t) ) ; ** if boundp ** else if( dmsys != "p4" then CDS_ddSetLibDMSys(ddGetObj(libname) "none") return(t) ) ) ; ** if dmsys ** user = CDS_P4User printf("Registering library with p4, please wait\n") /* Create a p4 client unless it already exists */ ;; Set the p4 client name when( boundp('CDS_lbbAskForLibNameForm) formLibType = CDS_lbbAskForLibNameForm->libType->value chip = CDS_lbbAskForLibNameForm->chipOption->value ) when( !formLibType && !libType println("No type defined, aborting") return() ) ;; define the View spec if( libType == "User" || formLibType== "User" then userdata = "user " ;; define the client sprintf(client "%s:%s" libname user) ;; build the view spec sprintf(viewspec "//depot/misc/cdslibs/%s/%s/... //%s/..." user libname client) else error("User is the only supported lib type for P4") ) ; ** if libType ** CDS_P4CurrentClient=client /* Read the p4 client */ ;; don't log it ;; frpintf(CDS_P4Port "\nRequesting client list\n") status = CDS_P4IPCBufferProcess("clients") unless( zerop(status) println("p4 client failed, abort\n") return() ) when( CDS_IPCBuffer p4clients = parseString(CDS_IPCBuffer "\n") ) when( p4clients p4cnames = foreach( mapcan x p4clients list(cadr(parseString(x))) ) ) if( member(client p4cnames) then errormessage = strcat("Abort: " client " already exists") CDS_P4Error("Library creation p4 registration" errormessage) return() ) libpath = CDS_NFSSimplify(ddid~>writePath) sprintf(dspec "Description: %s %s %s cds library" CDS_Project CDS_ProjectRev userdata) ;; Create the client spec in a temp file cfilen = strcat("/tmp/cspec." CDS_P4UserFileName) cfile = outfile(cfilen) fprintf(cfile "Client:%s\nRoot:%s \nView:%s\n%s\n" client libpath viewspec dspec) close(cfile) ;; frpintf(CDS_P4Port "\nBuilding client %s\n" client) status = CDS_P4IPCCommand(strcat("-i " cfilen " client -i")) if( status != 0 then return() else dmfile = strcat(dmfile "/cdsinfo.tag") type = libType || formLibType CDS_P4SetClient(ddid~>lib client type) CDS_ddSetLibDMSys(ddid "p4") if( isFile(dmfile) then file = CDS_NFSSimplify(dmfile) sprintf(cmd "add -t text %s" file) status = CDS_P4IPCCommand(cmd) ;; now submit all the changes if( zerop(status) then status = CDS_P4ClSubmitFile("Add" "library" file ddid) ) else status = 0 ) ; ** if isFile ** when( zerop(status) ;; now do the property bags! bagId = dbOpenBag(ddid "a") unless( bagId error("Property bag error -- check permissions!\n") ) bagId~>p4type= ( libType || formLibType ) when( bagId~>p4type != "User" bagId~>chip = chip ) dbSaveBag(bagId) dbCloseBag(bagId "a") return(t) ) ; ** when zerop ** CDS_P4Error("P4 add library" "Failed to initialize library") return() ) ; ** if status ** ) ; ** prog ** ) ; ** procedure CDS_P4PostCreateLib ** procedure(CDS_P4PostCreateObj(ddid cellpath ddtype childid) ;_Nov 13 01 sikand 445 prog((cmd status client file tagfile master p4type) when( ddGetObjDMSys(ddid) != "p4" return(t) ) client = CDS_P4GetClient(ddid~>lib) CDS_P4CurrentClient=client ;; allow lib file checkins for bulk libraries unless( ddtype == "ddLibFileType" when( ddid~>lib~>p4CheckinType == "Bulk" return(t) ) ) when( ddtype == "ddLibFileType" || ddtype == "ddCellFileType" || ddtype == "ddViewFileType" ;; force autocheckin library properties ;; system overrides this -- user must do it in graphical ;; system when( ddtype == "ddLibFileType" ddAutoCheckin(childid nil) ) file = CDS_NFSSimplify(childid~>writePath) ;; handle the master.tag file as atomic ;; with it's contents when( ddtype == "ddViewFileType" ;;println("in pco") when( member(childid~>view~>name CDS_P4ViewsUnManaged) return(t) ) when( member(childid~>cell~>name CDS_P4CellsUnManaged) return(t) ) master = CDS_P4GetMaster(childid) if( !master then printf("Failed to get master for %s\n" childid~>name) else when( rexMatchp(master file) rexCompile(master) tagfile = rexReplace(file "master.tag" 1) sprintf(cmd "add -t text %s" tagfile) status = CDS_P4IPCBufferProcess(cmd) unless( zerop(status) return() ) ) ; ** when rexMatchp ** ) ; ** if master ** ) ; ** when ddtype ** ;; we need some typing rules here methinks ;; typing rules are now moved to p4 typemap sprintf(cmd "add %s" file) ;; frpintf(CDS_P4Port "\nAdd of %s\n" file) status = CDS_P4IPCBufferProcess(cmd) when( zerop(status) ;; don't submit the prop.xx file since it's a co-managed ;; object if( (rexMatchp("prop.xx" file) || rexMatchp("pc.db" file)) && ddtype != "ddCellFileType" then return(t) else ;; submit the add ;; unless it's not the master when( master unless( rexMatchp(master file) return(t) ) ) ;status = CDS_P4ClSubmitFile("Add" "" file childid) ;when( zerop(status) return(t) ;) ) ; ** if rexMatchp ** ) ; ** when zerop ** return() ) ; ** when ddtype ** return(t) ) ; ** prog ** ) ; ** procedure CDS_P4PostCreateObj ** procedure(CDS_P4PreCheckout(ddl switches @optional version version_override) ;_Nov 13 01 sikand 490 prog((cmd rfiles client file status master xt table mlist status y x skip) foreach( x ddl if( ddGetObjDMSys(x) == "p4" then skip = nil else skip = t ) unless( skip client = CDS_P4GetClient(x~>lib) CDS_P4CurrentClient=client ;; do a bulk mode special here if( x~>lib~>p4CheckinType == "Bulk" then warn("Bulk mode detect") sprintf(cmd "-o /dev/null edit //...") status = CDS_P4IPCCommand(cmd) return(t) ) ; ** if x ** when( CDS_P4RefLibControl if( x~>lib~>p4type == "Reference" then ;; we need to implement access control ;; check the p4 group name for this library unless( CDS_P4CheckProtect(x~>lib~>name CDS_P4User) return(nil) ) ) ; ** if x ** ) ; ** when CDS_P4RefLibControl ** ;;table = CDS_P4Fstat(x~>writePath) ;;when( table~>haveRev != table~>headRev ;;warn("Checkout of older revision in progress") ;;) rfiles = "" file = CDS_NFSSimplify(x~>readPath) ;; if it's a master file, get the atomic files ;;println("in preco") ;;println(x~>writePath) if( (x~>type == 'ddLibFileType || x~>type == 'ddCellFileType) then if(version_override then status=CDS_P4AnyCheckouts(x t) else status=CDS_P4AnyCheckouts(x) ) when( status return() ) else ;;unless( (x~>type == 'ddLibFileType || x~>type == 'ddCellFileType) if( x~>type == 'ddCellType then xxglobalerr=x error("Aborting on celltype pre-checkout, ask Shiv to look at this ASAP\n") else if(x~>type=='ddViewType then ;; set x to be the master ddid ;; so that we can get auto checkouts for ddViewType y=ddGetObj(x~>lib~>name x~>cell~>name x~>name "*") master=y~>name x=y else if(x~>type=='ddViewFileType then master=ddGetObj(x~>lib~>name x~>cell~>name x~>view~>name "*")~>name ) ) ; ** if x ** ) ; ** if x ** ;; can't get a checkout for ddLibType ;; ONLY do the following for master objects if(version_override then ;; suppress out of sync error checking since ;; that is exactly what we want in this case status=CDS_P4AnyCheckouts(x t) else status=CDS_P4AnyCheckouts(x) ) ; ** if version_override ** when( status return() ) unless(master error("Fatal error: Failed to get a master !") xxxdebug=x ) if( rexMatchp(master x~>name) then xt= CDS_NFSSimplify(x~>writePath) when( rexMatchp("%" xt) || rexMatchp("\\.cd-" xt) return(nil) ) if( version then ;;printf("Getting atomic files for version %s %s\n" version x~>name) rfiles = CDS_P4GetAtomicFiles(x ?version version) else ;;printf("Getting atomic files for %s\n" x~>name) rfiles = CDS_P4GetAtomicFiles(x) ) ; ** if version ** unless( rfiles ;;drain(CDS_P4Port) warn("FATAL: Couldn't get atomic list") return() ) sprintf(cmd "edit %s" rfiles) ;;fprintf(stdout "\nCO: file(s) %s\n" rfiles) status = CDS_P4IPCCommand(cmd) unless( zerop(status) CDS_P4Error("P4 Interface" "Checkout failed") return() ) ;;return(t) ) ; ** if rexMatchp ** ) ; ** if x ** CDS_P4CurrentClient=client sprintf(cmd "-o /dev/null edit %s" file) status = CDS_P4IPCCommand(cmd) unless( zerop(status) return() ) ) ; ** unless skip ** when( rexMatchp("no permission for operation on file" CDS_IPCBuffer) warn("You probably do not have read or write access to this library") warn("Check permissions using p4 protect") return() ) ) ; ** foreach x ** return(t) ) ; ** prog ** ) ; ** procedure CDS_P4PreCheckout ** procedure(CDS_P4PreCheckin(ddl description switches) ;_Jun 29 01 sikand 0 ; Pre checkin trigger prog(( wlist wtable wmatch window cellview modechanged) ;; bail early if need be foreach( x ddl when( ddGetObjDMSys(x) != "p4" return(t) ) ) wtable = CDS_P4BuildWindowTable() foreach( x ddl modechanged = nil ;; clear any old entries CDS_P4WindowEditTable[x] = nil window = wtable[x] when( window ;; preserve edit ;; preserve read ;; close when( CDS_P4CheckinMode == "Preserve Edit" || CDS_P4CheckinMode == "Preserve Read" ;; make sure it's saved ;; flick to read only cellview = window~>cellView when( cellview~>mode == "a" when( cellview~>modifiedButNotSaved dbSave(cellview) ) geChangeEditMode("r" window) modechanged = t ;; stash it in the table so we can flick ;; it's mode back to edit after checkin ) ; ** when cellview ** ) ; ** when CDS_P4CheckinMode ** when( CDS_P4CheckinMode == "Preserve Edit" && modechanged CDS_P4WindowEditTable[x] = list(window "edit") ) when( CDS_P4CheckinMode == "Preserve Edit" && !modechanged CDS_P4WindowEditTable[x] = list(window "read") ) when( CDS_P4CheckinMode == "Close" CDS_P4WindowEditTable[x] = list(window "close") ) when( CDS_P4CheckinMode == "Preserve Read" CDS_P4WindowEditTable[x] = list(window "read") ) ) ; ** when window ** ) ; ** foreach x ** return(t) ) ; ** prog ** ) ; ** procedure CDS_P4PreCheckin ** procedure(CDS_P4BuildWindowTable() ;_Oct 14 00 sikand 0 let(( wtable files cdbfile) wtable = makeTable("P4WindowTable" nil) foreach( w cdr(hiGetWindowList()) when( w~>topCellView ;; need to key on dd of cdb files files = w~>topCellView~>view~>files cdbfile = car(setof(x files rexMatchp("cdb" x~>name))) wtable[cdbfile] = w ) ; ** when w ** ) ; ** foreach w ** wtable ) ; ** let ** ) ; ** procedure CDS_P4BuildWindowTable ** procedure(CDS_P4PostCheckin(ddl description switches ) ;_Jan 17 03 sikand 1682 prog(( message file client status action actioninfo window fdata wname fdatav wnamev check tmpfile cmd2 status name) foreach( x ddl when( ddGetObjDMSys(x) != "p4" return(t) ) name="" when(x~>type == 'ddViewFileType name=strcat("(" x~>cell~>name ") ") ) client = CDS_P4GetClient(x~>lib) CDS_P4CurrentClient=client file = CDS_NFSSimplify(x~>writePath) ;; make sure that the object is not already a p4 object ;; before trying to do anything else status = CDS_P4Fstat(file) ;; if table is nil, it's an unrevisioned object ;; so we can try force mode to revision it when( status~>? ;; object is a p4 object ;; is it opened unless( status~>action == "add" || status~>action == "edit" hiGetAttention() error("Cell is not opened, aborting request!\n") ) ) ; ** when status ** when( rexMatchp("%" file) || rexMatchp("\\.cd-" file) || rexMatchp("\\.bck" file) warn(strcat("Skipping checkin for backup object " x~>name "...")) return(t) ) message = "" ;; ask for a checkin message ? when( hiGraphicMode() && !description message = CDS_P4CheckinMessage(x) ) if( description then description = strcat(name description message) else description = strcat(name message) ) action = "Checkin" when( switches == "c" action = "Cancel Checkout" ) when( switches == "f" action = "Force" ) ;; trap bulk mode errors if( x~>lib~>p4CheckinType == "Bulk" && ( x~>type == 'ddViewFileType ) then error("Bulk Mode should not generate a check(in/out) event, is 'allwrite' set in the client ?\n") ) ; ** if x ** if( description != "" then status = CDS_P4ClSubmitFile(action description file x) else status = CDS_P4ClSubmitFile(action "" file x) ) ; ** if description ** unless( zerop(status) return() ) ;; flick the mode bit if necessary actioninfo = CDS_P4WindowEditTable[x] when( actioninfo window = car(actioninfo) action = cadr(actioninfo) when( action == "close" ;; may already be closed when( windowp(window) hiCloseWindow(window) ) ) ; ** when action ** when( action == "edit" printf("Window mode request for re-checkout\n") geChangeEditMode("a" window) ) when( action == "read" ;; update the window banner wname = hiGetWindowName(window) fdata = CDS_P4Fstat(x~>writePath) fdatav = fdata~>headRev ;; strip off the old version ;; and slap on a new one wnamev = strcat(substring(wname 1 nindex(wname "#")) fdatav) hiSetWindowName(window wnamev) ) ; ** when action ** ) ; ** when actioninfo ** ) ; ** foreach x ** return(t) ) ; ** prog ** ) ; ** procedure CDS_P4PostCheckin ** procedure(CDS_sssFlatten(alist) ;_Feb 21 96 sikand 0 foreach( mapcan element alist if( listp(element) then CDS_sssFlatten(copy(element)) else ncons(element) ) ; ** if listp ** ) ; ** foreach mapcan ** ) ; ** procedure CDS_sssFlatten ** procedure(CDS_P4PreDeleteObj(ddid) ;_Jun 29 01 sikand 357 ; pre delete ;; check for checkouts prog(( client user cddid retstatus file) when( ddGetObjDMSys(ddid) != "p4" return(t) ) file = ddid ~> writePath when( rexMatchp("%" file) || rexMatchp("\\.cd-" file) || rexMatchp("\\.bck" file) return(t) ) ;;printf("Pre Delete request: %s %s %s\n" ddid~>name ddid~>type ddid~>writePath) client = CDS_P4GetClient(ddid~>lib) CDS_P4CurrentClient=client user = CDS_P4User when( ddid~>type == 'ddLibType CDS_P4DelList = cons(ddid CDS_P4DelList) ) ; when( ddid~>type == 'ddLibType ; xt = CDS_NFSSimplify(ddid~>writePath) ; sprintf(cmd "find %s -type f > /tmp/findlog.%s" xt user) ; status = CDS_IPCBufferProcess(cmd) ; unless( status ; return() ; ) ; status = CDS_P4IPCBufferProcess(strcat("-x /tmp/findlog." user " opened -a")) ; when( status ; when( rexMatchp("default change" CDS_IPCBuffer) ; if( hiGraphicMode() then ; CDS_ErrorDialogBox("P4 Interface" "Library has checkouts !!") ; else ; printf("Library has checkouts!!!\n") ; ) ; return() ; ) ; ** when rexMatchp ** ; ) ; ** when status ** ; ) ; ** when ddid ** ; when( ddid~>type == 'ddCellType ; ;; check the master ; foreach( view ddid~>cell~>views ; cddid = ddGetObj(ddid~>lib~>name ddid~>cell~>name view~>name "*") ; retstatus = CDS_P4AnyCheckouts(cddid) ; when( retstatus ; return() ; ) ; ) ; ** foreach view ** ; ) ; ** when ddid ** ; when( ddid~>type == 'ddViewType ; when(cddid = ddGetObj(ddid~>lib~>name ddid~>cell~>name ddid~>name "*") ; retstatus = CDS_P4AnyCheckouts(cddid) ; when( retstatus ; return() ; ) ; ) ; ** when cddid ** ; ) ; ** when ddid ** when( ddid~>type == 'ddViewFileType || ddid~>type == 'ddCellFileType || ddid~>type == 'ddLibFileType when( ddid unless( rexMatchp("master.tag" ddid~>name) || rexMatchp("pc.db" ddid~>name) retstatus = CDS_P4AnyCheckouts(ddid) when( retstatus return() ) ) ; ** unless rexMatchp ** ) ; ** when ddid ** ) ; ** when ddid ** return(t) ) ; ** prog ** ) ; ** procedure CDS_P4PreDeleteObj ** procedure(CDS_P4DeleteObj(ddid @optional done) ;_Oct 14 00 sikand 0 ; pre trigger for object deletion ; objectid ddid prog(( cmd client user xt status cddid retstatus dontsub file ) ;;printf("Delete request: %s %s \n" ddid~>name ddid~>writePath) ;; xxx=ddid ;;println(done) ;; because GDM has already blown away the tagfile by now unless( member(ddid~>lib CDS_P4DelList) when( ddGetObjDMSys(ddid) != "p4" return(t) ) ) client = CDS_P4GetClient(ddid~>lib) CDS_P4CurrentClient=client user = CDS_P4User when( ddid~>type == 'ddCellType sprintf(cmd "deleteCellorView.pl %s %s %s cell 1>>%s 2>&1" ddid~>name client CDS_NFSSimplify(ddid~>writePath) CDS_P4LogFile ) ;; frpintf(CDS_P4Port "Script running..\n") ;;println(cmd) status = CDS_IPCCommand(cmd) when( zerop(status) ;printf("Cell delete done...please ignore next message\n") return(t) ) printf("Cell delete failed...\n") return(nil) ) ; ** when ddid ** when( ddid~>type == 'ddLibFileType || ddid~>type == 'ddCellFileType || ddid~>type == 'ddViewFileType sprintf(cmd "deleteCellorView.pl %s %s %s file 1>>%s 2>&1" ddid~>name client CDS_NFSSimplify(ddid~>writePath) CDS_P4LogFile ) ;; frpintf(CDS_P4Port "Script running..\n") ;;println(cmd) status = CDS_IPCCommand(cmd) when( zerop(status) return(t) ) printf("File delete failed...\n") return(nil) ) ; ** when ddid ** when( ddid~>type == 'ddViewType sprintf(cmd "deleteCellorView.pl %s %s %s view 1>>%s 2>&1" ddid~>lib~>name client CDS_NFSSimplify(ddid~>writePath) CDS_P4LogFile ) ;; frpintf(CDS_P4Port "Script running..\n") ;;println(cmd) status = CDS_IPCCommand(cmd) when( zerop(status) ;printf("Cellview delete done...please ignore next message\n") return(t) ) printf("Cellview delete failed...\n") return(nil) ) ; ** when ddid ** dontsub = nil when(ddid~>type == 'ddLibType sprintf(cmd "deleteLib.pl %s %s >> %s" ddid~>name client CDS_P4LogFile ) status = CDS_IPCCommand(cmd) when( zerop(status) ;;CDS_P4SwapCdsLib(ddid~>name "" t) sprintf(cmd "rm -rf %s" ddid~>writePath) status = CDS_IPCCommand(cmd) when( zerop(status) CDS_P4DelList = nil printf("Library delete done...\n") return(t) ) ) ; ** when zerop ** printf("Library delete failed...\n") CDS_P4DelList = nil return(nil) ) ; ** when ddid ** ;; physically delete unmanaged objects directly ;; except the p4client file since we need it when( ddid~>type == 'ddViewFileType when( rexMatchp(".__ver[0-9]+" ddid~>cell~>name) dontsub = t ) ) when( rexMatchp("%" ddid~>name) || rexMatchp("\\.cd-" ddid~>name) ;; just delete it ;;sprintf(cmd "rm %s" CDS_NFSSimplify(ddid~>writePath)) ;;CDS_IPCCommand(cmd) dontsub = t ) ; ** when rexMatchp ** ;; don't screw with files marked dontsub unless( dontsub file = CDS_NFSSimplify(ddid~>writePath) ;; if it was opened (add or edit) revert it fprintf(CDS_P4Port "In delete...\n") status = CDS_P4IPCBufferProcess(strcat("opened " file)) if( rexMatchp("default change" CDS_IPCBuffer) then ;; frpintf(CDS_P4Port "Reverting file %s\n",file) status = CDS_P4IPCBufferProcess(strcat("revert " file)) unless( zerop(status) CDS_P4Error("P4 Interface" "Revert failed") CDS_P4LibMode = nil ) ;; abandoned files don't need deleting ;; but everything else does if( rexMatchp("was add, abandoned" CDS_IPCBuffer) then ;printf("File %s abandoned..\n" file); return(t) else ;; frpintf(CDS_P4Port "Deleting file %s\n" file) status = CDS_P4IPCBufferProcess(strcat("delete " file)) ;; now check for file not on client when( rexMatchp("not on client" CDS_IPCBuffer) ;;warn(strcat("File " ddid~>name " not on client..")) ;; delete it anyway when( isFile(CDS_NFSSimplify(ddid~>writePath)) sprintf(cmd "rm %s" CDS_NFSSimplify(ddid~>writePath)) CDS_IPCCommand(cmd) ) dontsub = t ) ; ** when rexMatchp ** when( status != 0 error("P4 Interface" "Failed to delete %s\n" file) ) ) ; ** if rexMatchp ** ) ; ** if rexMatchp ** ) ; ** unless dontsub ** ;; What about LibFiles ????? ;; :::::: if( dontsub then return(t) else status = CDS_P4ClSubmitFile("Delete" "" file ddid) when( zerop(status) return(t) ) ) ; ** if dontsub ** warn("Delete failed!") warn(CDS_IPCBuffer) return() ) ; ** prog ** ) ; ** procedure CDS_P4DeleteObj ** procedure(CDS_P4ClSubmitFile(description message file ddid @optional append) ;_Aug 20 01 sikand 5520 ; build the change list for this file and submit it ; but only after diffing it with what's in the depot ; but we also need to add in the co-managed files ; pc.db prop.xx master.tag prog((cmd user ofile cldes client status openedstate depotfile revert action cancel master rfiles continue cofiles codepotname masterfile view ov mddid mvname mvid addview astatus delete) ;;printf("\nSubmit request for %s (%s)\n" file description) user = CDS_P4User ofile = strcat("/tmp/p4cl." CDS_P4UserFileName) if( append then cldes = outfile(ofile "a") else cldes = outfile(ofile "w") ) client = CDS_P4GetClient(ddid~>lib) CDS_P4CurrentClient=client when( rexMatchp("%" file) || rexMatchp("\\.cd-" file) close(cldes) return(0) ) ;; we need the p4 file name for the change list ;; frpintf(CDS_P4Port "\nGetting depot name for %s\n" file) status = CDS_P4IPCBufferProcess(strcat("opened " file)) openedstate = CDS_IPCBuffer ;;when( zerop(status) when( rexMatchp("file(s) not opened on this client" CDS_IPCBuffer) ;; we are using force in a very special way here ;; where force means checkin in a file that hasn't ;; been added for non-triggered adds like ihdl when( (ddid~>type == 'ddLibFileType || ddid~>type == 'ddCellFileType) && description == "Force" CDS_P4PostCreateObj(ddid~>lib ddid~>writePath symbolToString(ddid~>type) ddid) ddCheckin(ddid message) close(cldes) return(0) ) ; ** when ddid ** when( ddid~>type == 'ddViewFileType && description == "Force" foreach( id ddid~>view~>files CDS_P4FixPerm(id~>writePath) when( ! rexMatchp("master.tag" id~>name) printf("Revisioning file %s...\n" id~>writePath) CDS_P4PostCreateObj(id~>lib id~>writePath symbolToString(id~>type) id) ) ) ; ** foreach id ** ddCheckin(ddid message) close(cldes) return(0) ) ; ** when ddid ** unless( description == "Delete" CDS_P4Error("P4 Interface" strcat("File " file " is not opened, submit is cancelled !")) ) close(cldes) return(0) ) ; ** when rexMatchp ** depotfile = car(parseString(CDS_IPCBuffer)) ;;) ; ** when zerop ** if( description == "Force" then description = "Checkin" ) unless( (description == "Add") || (description == "Delete") ;; check to see if it's a cancel if( description == "Cancel Checkout" then if( hiGraphicMode() && !CDS_P4MultiSelect then action = CDS_WarnDialogBox("P4 Interface" strcat("Cancel checkout for\n" ddid~>writePath " ?")) unless( action error("Cancel checkout aborted!\n") ) revert = action else ;printf("Cancelling checkout for %s\n",ddid~>name) revert = t ) ; ** if hiGraphicMode ** else ;; is it different ? ;; no point diffing etc for an add object..... unless( rexMatchp("add default change" CDS_IPCBuffer) sprintf(cmd "diff -sa %s" file) ;; frpintf(CDS_P4Port "\nRunning p4 diff -sa %s\n" file) status = CDS_P4IPCBufferProcess(cmd) ;; this is a hack to disable 'diff' ;;CDS_IPCBuffer= "diff" if( zerop(status) then if( !CDS_IPCBuffer || CDS_IPCBuffer == "" then if( ddid~>view~>name then if( hiGraphicMode() && !CDS_P4MultiSelect then revert = CDS_WarnDialogBox("P4 Interface" strcat("Design " ddid~>cell~>name " " ddid~>view~>name " was not modified, force checkin ?")) when( !revert close(cldes) ;;return() ) else ;; we could have some switches here to ;; ddCheckin printf("Cancelling checkin for non-edited object %s %s\n", ddid~>cell~>name ddid~>view~>name) revert = nil ) ; ** if hiGraphicMode ** else if( hiGraphicMode() && !CDS_P4MultiSelect then revert = CDS_WarnDialogBox("P4 Interface" strcat("Design object " ddid~>name " was not modified, force checkin ?")) when( !revert close(cldes) ;;return() ) else printf("Cancelling checkin for non-modified object %s\n",ddid~>name) revert = nil ) ; ** if hiGraphicMode ** ) ; ** if ddid ** ;; reverse the polarity revert = !revert ;; may be in append mode and don't want to lose ;; an edited object when( append && revert if( hiGraphicMode() then action = CDS_WarnDialogBox("P4 Interface" "Cancel checkouts for all views ?") else action = nil ) revert = action cancel = !action ) ; ** when append ** else when( rexMatchp("file(s) not opened on this client" CDS_IPCBuffer) CDS_P4Error("P4 Interface" "File is not opened, submit cancelled!") close(cldes) return() ) ) ; ** if CDS_IPCBuffer ** else CDS_P4Error("P4 Interface" "diff failed!") close(cldes) return(status) ) ; ** if zerop ** ) ; ** unless rexMatchp ** ) ; ** if description ** if( revert then ;; just revert the file back to it's original state ;; also revert the co-masters and derived objects ;;println("in pclsr") ;; there is a chance here that there is no master for ;; cell and lib files so don't look for them ;println(openedstate) ;; add objects are not on the client if( rexMatchp("- add " openedstate) then delete = t ;; get the added files from the dd type rather than ;; the atomic list if( ddid~>type == 'ddViewFileType then file = "" foreach( mapcar x ddid~>view~>files file = strcat(CDS_NFSSimplify(x~>writePath) " " file) ) ) ; ** if ddid ** else unless( ddid~>type == 'ddLibFileType || ddid~>type == 'ddCellFileType ;println("Got a revert for an edit cell, checking master") master = CDS_P4GetMaster(ddid) ;println(master) ;println(ddid~>name) when( rexMatchp(master ddid~>name) ;println("getting atomics") rfiles = CDS_P4GetAtomicFiles(ddid) ;println(rfiles) unless( rfiles printf("Failed to get atomic file list...\n") close(cldes) return(1) ) ) ; ** when rexMatchp ** when( rfiles file = rfiles ) ) ; ** unless ddid ** ) ; ** if rexMatchp ** printf("Cancelling checkout for %s\n", ddid~>writePath) continue = t when( continue ;; frpintf(CDS_P4Port "\nCI: revert %s\n" file) status = CDS_P4IPCCommand(strcat("revert " file)) ) ;; physically delete newly added files that have been ;; marked for cancel checkout when( delete sprintf(cmd "rm -rf %s" file) status = CDS_IPCCommand(cmd) ) ;; we should check the status bit really close(cldes) return(t) ) ; ** if revert ** ) ; ** unless description ** when( cancel && append ;; don't add this linked view to the changelist close(cldes) return() ) ;; skip the descriptions when in append mode if( append then fprintf(cldes "\t") else fprintf(cldes "\nChange: new\n\nDescription: \tcds:%s %s\n\n\n\nFiles:\n\t" description message) ) fprintf(cldes "%s\n" depotfile) ;; check for master object and check in co-managed/derived ;; files ;;println("in plcsa") unless( ddid~>type == 'ddLibFileType || ddid~>type == 'ddCellFileType master = CDS_P4GetMaster(ddid) ) when( master ;; should really handle all file types through ;; the data registry ;; check the master, and do a table lookup ;; on pattern and get the co-managed files ;; read the registry files once per session ;; and store in a global table when( rexMatchp(master file) && ( description == "Checkin" || description == "Add" ) ;; get the file list from the ddid~>view ;; contstruct a list of those that are writable ;; meaning that they have been added or edited ;; need to reject % backup files cofiles = setof(x ddid~>view~>files (isWritable(x~>writePath) && ! rexMatchp("%" x~>writePath) || rexMatchp("\\.cd-" x~>writePath)) ) ;; print them into the changelist rexCompile(master) foreach( filen cofiles when( filen~>name != master ;; make sure that they exist on the client status = CDS_P4IPCBufferProcess(strcat("opened " CDS_NFSSimplify(filen~>writePath))) unless( status == 0 CDS_P4Error("P4 Interface" "p4 opened failed!") ) ;; we should check to make sure that it ;; was added since verilogin could have created ;; a new prop.xx file that wasn't there before ;; for example when( rexMatchp("not opened on this client" CDS_IPCBuffer) ;; add it printf("adding file %s\n" filen~>name) CDS_P4PostCreateObj(filen~>view filen~>writePath symbolToString(filen~>type) filen) ) ;; don't do the master.tag or the master unless( rexMatchp("master.tag" filen~>name) || rexMatchp(master filen~>name) codepotname = rexReplace(depotfile filen~>name 1) ;printf("adding %s to cl\n" codepotname) fprintf(cldes "\t%s\n" codepotname) ) ) ; ** when filen ** ) ; ** foreach filen ** ;; do the master.tag file ;; only if it matches the file name rexCompile(master) when( master == ddid~>name masterfile = rexReplace(depotfile "master.tag" 1) fprintf(cldes "\t%s\n" masterfile) ) ) ; ** when rexMatchp ** ) ; ** when master ** when( cldes close(cldes) ) ;; check for other cellviews of the same cell that may be open for edit ;; and do an atomic checkin ;; avoid looping by checking append status bit when( description == "Checkin" && !append view = ddid~>view~>name ;; get the other views when( CDS_P4AtomicViews ov = setof(x ddid~>cell~>views x~>name != view) when( ov foreach( v ov ;; see if it needs checkin mvid = ddGetObj(v~>lib~>name v~>cell~>name v~>name "*.cdb") ;; but it could already be on the master checkin ;; list unless( ddNeedCheckout(mvid) ;; it does ;; bring up user form if( hiGraphicMode() && CDS_P4GroupCheckin[mvid] == 'unbound then addview = CDS_WarnDialogBox("P4 Interface" strcat("Atomically checkin view " v~>name " ?")) else printf("Atomically checking in view %s\n", v~>name) addview = t ) ; ** if hiGraphicMode ** when( addview astatus = CDS_P4ClSubmitFile(description "" CDS_NFSSimplify(mvid~>readPath) mvid t) ) ) ; ** unless ddNeedCheckout ** ) ; ** foreach v ** ) ; ** when ov ** ) ; ** when CDS_P4AtomicViews ** ) ; ** when description ** ;; submit only on first loop unless( append && !revert && !astatus status = CDS_P4Submit(file ofile ddid) return(status) ) return() ) ; ** prog ** ) ; ** procedure CDS_P4ClSubmitFile ** procedure(CDS_P4ResolveCB(form) ;_Nov 5 99 sikand 123 prog(( ddid client action p4action cfile cflist lin cmd status xdfile) ddid = car(form->appData) ;;cnum = cadr(form->appData) action = form->mergeAction->value if( action == "Accept your version" then p4action = "-ay" else p4action = "-at" ) client = CDS_P4GetClient(ddid~>lib) CDS_P4CurrentClient=client ;; schedule the resolve ;; on a per file basis ;; otherwise the default change list will be used!!!! cflist = nil ;; read in the p4cl.user file to get the file names cfile = infile(strcat("/tmp/p4cl." CDS_P4UserFileName)) while( gets(lin cfile) when( rexMatchp("//depot" lin) cflist = cons(lin cflist) ) ) close(cfile) foreach( dfile cflist ;; strip the revision identifier rexCompile("#[0-9]+") xdfile= rexReplace(dfile "" 1) ;; strip the tab ;; strip the cr xdfile = substring(xdfile 2 strlen(xdfile)-2) ;; do resolve on a file by file basis ;; frpintf(CDS_P4Port "Resolving file %s as %s\n" dfile p4action) ;;drain(CDS_P4Port) sprintf(cmd "resolve %s %s" p4action xdfile) status = CDS_P4IPCCommand(cmd) unless( zerop(status) CDS_P4Error("P4 Interface" "Resolve failed!") ) ) ; ** foreach dfile ** return(status) ) ; ** prog ** ) ; ** procedure CDS_P4ResolveCB ** procedure(CDS_P4Submit(infile ofile ddid) ;_May 4 00 sikand 0 prog(( status cmd changenum client mergeAction mergeForm form title info) sprintf(cmd "-i %s submit -i" ofile) ;; frpintf(CDS_P4Port "\nSubmitting %s\n" infile) ;;drain(CDS_P4Port) status = CDS_P4IPCBufferProcess(cmd) if( rexMatchp("Can't include file(s)" CDS_IPCBuffer) error("Can't submit, possibly due to cancel of last submit, please get help!") ) if(( rexMatchp("Out of date files" CDS_IPCBuffer) || rexMatchp("Merges still pending" CDS_IPCBuffer) ) then ;; need to get the submit change number ;;changenum = cadr(parseString(CDS_IPCBuffer)) rexCompile(".submit -c \\([0-9]+\\).") unless(rexExecute(CDS_IPCBuffer) CDS_P4Error("P4 Interface" "Regxp match fail for changenum...see a developer") ) changenum = rexSubstitute("\\1") ;; we got a merge on our hands ;; that we need to deal with ;; set the client before we do anything client = CDS_P4GetClient(ddid~>lib) CDS_P4CurrentClient=client ;; let's do a resolve if( hiGraphicMode() then ;; need to give the user the choice of accept your ;; or accept theirs mergeAction = hiCreateRadioField(?name 'mergeAction ?choices list("Accept your version" "Accept head of tree version") ?prompt "Resolve action" ?defValue "Accept your version" ) info = index(ddid~>writePath ddid~>lib~>name) if( info then title = strcat("Resolve conflict for " info) else CDS_P4Error("P4 Interface" "Couldn't find lib in cell path!!!") ) hiCreateAppForm(?name 'mergeForm ?fields list(list(mergeAction 0:10 10:10 0)) ?formTitle title ?callback 'CDS_P4ResolveCB() ?initialSize 400:500 ) form = symeval('mergeForm) form->appData = list(ddid changenum) status = hiDisplayForm('mergeForm) unless( status error("Submit cancelled") ) sprintf(cmd "submit -c %s" changenum) ;; frpintf(CDS_P4Port "\nSubmitting change %s\n" changenum) ;;drain(CDS_P4Port) status = CDS_P4IPCCommand(cmd) if( zerop(status) then printf("Checkin succeeded...\n") else CDS_P4Error("P4 Interface" "Submit failed, check p4.log file!") ) else CDS_P4Error("P4 Interface" "Submit failed, check p4.log file!") ) ; ** if hiGraphicMode ** else when( zerop(status) ;;drain(CDS_P4Port) return(status) ) CDS_P4Error("P4 Interface" "Submit failed, check p4.log file!") ) ; ** if rexMatchp ** ;;drain(CDS_P4Port) return(status) ) ; ** prog ** ) ; ** procedure CDS_P4Submit ** procedure(CDS_P4GetChangeFromVersion(bfile bversion @optional local) ;_May 4 00 sikand 0 ; get the change number of a specific version ; but only if it was add or edit ; if it was integrate, iterate ;; but cross branch integrates look like edits ;; so need to check for a "copy from" record for those too prog(( status changes parse changedata vchangetext bvchanges vparse bvfile bvversion changetype j match matchcount) matchcount=5 status = CDS_P4IPCBufferProcess(strcat("filelog " bfile)) unless( zerop(status) return(nil) ) changes = parseString(CDS_IPCBuffer "\n") for( i 2 length(changes) changedata = nthelem(i changes) when(rexMatchp(strcat("... #" bversion " ") changedata) parse = parseString(changedata) changetype = nthelem(5 parse) when( changetype == "add" || local return(changedata) ) when( changetype == "integrate" || changetype == "branch" || changetype == "edit" || changetype == "delete" ;; let the fun begin j = 0 match = nil while( j j++ vchangetext = nthelem(i+j changes) unless(vchangetext error("No branch from record, integrate -f victim for %s" dfile) ) ;; if we got a new version record stop when( rexMatchp("\\.\\.\\. #" vchangetext) when( changetype == "branch" || changetype == "integrate" error("No branch from record, seek HELP!!!\n") ) return(changedata) ) ; ** when rexMatchp ** when( rexMatchp(" from " vchangetext) j = nil i = length(changes) ) when( rexMatchp(" ignored \\/\\/" vchangetext) ;; not to be confused with 'ignored by' ;; this is quite a subtle case usually ;;... ... ignored //depot/phoenix/rev1/cadence/top/phoenix/rw_row_tile/layout/layout.cdb#8 ; and the filelog on that baby will say ;;... ... ignored by //depot/phoenix_rev1_top_Dec18_2001_rev1.6/cadence/top/phoenix/rw_row_tile/layout/layout.cdb#4 j = nil i = length(changes) matchcount=4 ) ; ** when rexMatchp ** ) ; ** while j ** bvchanges = nthelem(matchcount parseString(vchangetext)) vparse = parseString(bvchanges "#") bvfile= car(vparse) bvversion = car(reverse(vparse)) changedata = CDS_P4GetChangeFromVersion(bvfile bvversion) return(changedata) ) ; ** when changetype ** ) ; ** when rexMatchp ** ) ; ** for i ** ) ; ** prog ** ) ; ** procedure CDS_P4GetChangeFromVersion ** procedure(CDS_P4GetAtomicFiles(ddid @key version lib client withversion) ;_May 15 02 sikand 1374 ; get the atomic checkin or add of the .cdb file ; Returns list of files/nil ;; withversion returns the original list of files if a branch/integrate ;; was present along with their version numbers prog(( vfilecount rfilecount rfiles vfiles file fstable dfile status changes changetext save_changetext checkforbranch ctype branchdata musthavefrom gotfrom stop bchanges parse bfile bversion bfchanges bdepotheader dspec dspecl libname bdepothead filebit filebitlogical changenum desc linedata action rfile rfilelogical rfilelogicallen poplen nbase rname) vfilecount = 0 rfilecount = 0 if( ddIsId(ddid) then ;;client = ddid~>lib~>p4client client = CDS_P4GetClient(ddid~>lib) CDS_P4CurrentClient=client rfiles = "" vfiles = "" file = CDS_NFSSimplify(ddid~>readPath) fstable=CDS_P4Fstat(file) dfile = fstable~>depotFile unless( boundp('dfile) error("This cell is read only and the checkout fails because it was not previously revisioned\npossibly because of a previous error\nTry checking it in first\n") ) lib = ddid~>lib~>name else ;; we send it a filename or a depot spec rfiles = "" vfiles = "" dfile = ddid unless( lib && client error("Please specify lib and client") ) CDS_P4CurrentClient=client file = fstable~>clientFile ) ; ** if ddIsId ** ;; handle add,edit,integrate,branch status = CDS_P4IPCBufferProcess(strcat("filelog " dfile)) when( zerop(status) when( rexMatchp("file(s) not on client" CDS_IPCBuffer) CDS_P4Error("P4 Interface" "File is protected or not on the client...\n") ) changes = parseString(CDS_IPCBuffer "\n") ;; get the files associated with the last edit ;; or the specified version if( version then changetext = car(setof(x changes (rexMatchp(strcat("#" version " change [0-9]+") x) && !rexMatchp("delete on" x)))) else changetext = car(setof(x changes (rexMatchp("change [0-9]+" x) && !rexMatchp("delete on" x)))) ) save_changetext = changetext checkforbranch = parseString(changetext) ctype = nthelem(5 checkforbranch) when( ctype == "branch" || ctype == "integrate" ;; a branch to branch integrate may have a copy from ;; record ;; but a branch or integrate MUST have a from record ;; or we are toast ;; resolves can also generate ... copy from fields ;; but in that case we can ignore branchdata = t ) ; ** when ctype ** when( branchdata for( i 2 length(changes) unless( bfchanges when( rexMatchp(save_changetext nthelem(i changes)) ;;changetype = nthelem(5 parseString(save_changetext)) ;;when( ctype == "branch" || ctype == "integrate" musthavefrom = t ;; looks like this ;; ... ... copy from //depot/foo/lib/netlist.cdb#3,#4 ;; for an integrate or edit ;; ... ... branch from //depot/foo/lib/netlist.cdb#3,#4 ;; for a branch ;; reject the field that says ;; ... ... branch into //depot/branch/foo/lib/netlist.cdb#1 j = 0 while( j && !stop j++ changetext = nthelem(i+j changes) ;; integrate keying bug in p4 ;; record can end here ;; so detect early termination unless( changetext hiGetAttention() error("Invalid branch record for %s, abort\nThis is a known bug, please choose the next available version with a '... ... copy from' record " file) ) when( rexMatchp("\\.\\.\\. \\.\\.\\. branch from " changetext) || rexMatchp("\\.\\.\\. \\.\\.\\. copy from " changetext) j = nil when( musthavefrom gotfrom = t ) ) ; ** when rexMatchp ** ;; if we got a new version record stop when( rexMatchp("\\.\\.\\. #" changetext) j = nil stop = t changetext = save_changetext ;; detect that the parent wasn't obliterated when( musthavefrom && !gotfrom error("Couldn't find branch/copy from record, abort") ) ) ; ** when rexMatchp ** when( rexMatchp("\\.\\.\\. \\.\\.\\. branch from " changetext) || rexMatchp("\\.\\.\\. \\.\\.\\. copy from " changetext) j = nil bchanges = nthelem(5 parseString(changetext)) parse = parseString(bchanges "#") bfile= car(parse) bversion = car(reverse(parse)) ;; exit the loop i = length(changes) bfchanges = list(CDS_P4GetChangeFromVersion(bfile bversion)) ) ; ** when rexMatchp ** when( rexMatchp("\\.\\.\\. \\.\\.\\. ignored " changetext) j = nil bchanges = nthelem(4 parseString(changetext)) parse = parseString(bchanges "#") bfile= car(parse) bversion = car(reverse(parse)) ;; exit the loop i = length(changes) bfchanges = list(CDS_P4GetChangeFromVersion(bfile bversion)) ) ; ** when rexMatchp ** ) ; ** while j ** ) ; ** when rexMatchp ** ) ; ** unless bfchanges ** ) ; ** for i ** if( bfchanges && !stop then bdepotheader = car(changes) CDS_P4IPCBufferProcess("client -o") dspec = parseString(CDS_IPCBuffer) dspecl = nthelem(length(dspec)-1 dspec) libname = cadr(reverse(parseString(dspecl "/"))) ;; pull of the last ... and the / bdepothead = substring(dspecl 1 strlen(dspecl)-3-strlen(libname)-1) filebit = substring(dfile strlen(bdepothead)+strlen(libname)+2 strlen(dfile)) filebitlogical=length(parseString(filebit "/")) changes = bfchanges changetext = car(setof(x changes ( rexMatchp("change [0-9]+ add" x) || rexMatchp("change [0-9]+ edit" x) ))) ) ; ** if bfchanges ** ) ; ** when branchdata ** when( changetext ;; get the change number changenum = nthelem(4 parseString(changetext)) ) if( changenum then ;; parse the change description to get the affected ;; files status = CDS_P4IPCBufferProcess(strcat("describe -s " changenum)) when( zerop(status) desc = parseString(CDS_IPCBuffer "\n") foreach( dline desc when( rexMatchp("^\\.\\.\\." dline) linedata = parseString(dline) action = nthelem(3 linedata) unless( action == "delete" file = nthelem(2 linedata) rexCompile("#[0-9]+") rfile = rexReplace(file "" 1) vfiles = strcat(vfiles " " file) vfilecount++ when( bfchanges ;; strip of the depot header ;; actually, just grab the last filebit ;; characters rfilelogical=parseString(rfile "/") rfilelogicallen=length(rfilelogical) poplen=rfilelogicallen-filebitlogical for(i 1 poplen pop(rfilelogical) ) ;; back into a string nbase="" foreach(el rfilelogical nbase=strcat(nbase "/" el) ) rname = strcat(bdepothead lib nbase) rfile = rname ) ; ** when bfchanges ** rfiles = strcat(rfiles " " rfile) rfilecount++ ) ; ** unless action ** ) ; ** when rexMatchp ** ) ; ** foreach dline ** if( (rfilecount | vfilecount) > 10 then ;; arbitrary count....usually it's 3 or 4, 10 ;; must indicate an error printf("rfcount %d vfcount %d\n" rfilecount vfilecount) error("Abort: File count overflow..") ) ; ** if rfilecount ** when( rfiles != "" && !withversion return(rfiles) ) when( vfiles != "" && withversion return(vfiles) ) return() ) ; ** when zerop ** ) ; ** if changenum ** return() ) ; ** when zerop ** ) ; ** prog ** ) ; ** procedure CDS_P4GetAtomicFiles ** procedure(CDS_P4GetMaster(ddid) ;_Apr 23 02 sikand 0 ; master lookup routine ; ddid dobject ; Returns master prog(( x master) x = ddid ;; we should only get master requests for ViewFileTypes !!! ;; since ddid's should already be filtered for this call when( x~>type == 'ddViewFileType master=ddGetObj(x~>lib~>name x~>cell~>name x~>view~>name "*")~>name return(master) ) warn("Bad getMaster request %s\n" ddid~>??) return(nil) ) ; ** prog ** ) ; ** procedure CDS_P4GetMaster ** procedure(CDS_P4GetMaster2(ddid) ;_Jul 19 00 sikand 0 prog(( lin tagfile tport master) ;; don't look for a master for master.tag files! when( rexMatchp("master.tag" ddid~>writePath) return(nil) ) ;;printf("Master req for %s\n" ddid~>name) rexCompile(ddid~>name) tagfile = rexReplace(ddid~>writePath "master.tag" 1) ;;;; frpintf(CDS_P4Port "Reading master.tag file\n"); tport = infile(tagfile) if( tport then while( gets(lin tport) ;; skip the first line gets(lin tport) master = car(parseString(lin "\n")) ) close(tport) else ;;printf("no master.tag file found for file %s\n", ddid~>writePath) return(nil) ) ; ** if tport ** unless( master printf("Warning: Failed to find a master for %s\n" ddid~>writePath) ) return(master) ) ; ** prog ** ) ; ** procedure CDS_P4GetMaster2 ** procedure(CDS_P4ReadMaster(ddid) ;_Sep 4 98 sikand 0 prog(( lin tagfile tport master) tagfile = ddid~>readPath tport = infile(tagfile) if( tport then while( gets(lin tport) ;; skip the first line gets(lin tport) master = car(parseString(lin "\n")) ) close(tport) else ;;printf("no master.tag file found for file %s\n", ddid~>writePath) return(nil) ) ; ** if tport ** unless( master printf("Warning: Failed to find a master for %s\n" ddid~>writePath) ) return(master) ) ; ** prog ** ) ; ** procedure CDS_P4ReadMaster ** procedure(CDS_P4SetClient(libid client @optional type) ;_Nov 5 99 sikand 0 ; set the client for this library ; client p4 client name ; libid library ddid let(( libname libpath) libname = libid~>name libpath = CDS_NFSSimplify(libid~>writePath) CDS_P4ClientTable[strcat(libname ":" libpath)] = client ;; if it's a design or reference lib, update the system cds.p4client ;; file unless( type type = libid~>p4type ) when( type == "Design" || type == "Reference" CDS_P4BuildMasterClientFile(CDS_P4MasterClientFile) ) ) ; ** let ** ) ; ** procedure CDS_P4SetClient ** procedure(CDS_P4GetClient(libid) ;_Sep 3 02 sikand 907 ; get the local client name let(( client libname libpath) libname = libid~>name when(ddGetObjDMSys(libid)== "p4" libpath = CDS_NFSSimplify(libid~>writePath) unless(client = CDS_P4ClientTable[strcat(libname ":" libpath)] ;; try rebuilding the client names table ;; this can happen if new libs were pushed into the branch ;; and thus the client table is out fof date with the ;; cds.lib file CDS_P4BuildClientNames() ) ; ** unless client ** ;; now try the lookup again unless(client = CDS_P4ClientTable[strcat(libname ":" libpath)] hiGetAttention() warn("Couldn't find client for %s.\nERROR: The DM system has not been initialised correctly.\nMake sure your %s is in sync with your cds.lib file or seek help !!\nFATAL ERROR: DO NOT EDIT ANY CELLS" libid~>name CDS_P4ProjectBranchEnvVar ) ) client ) ; ** when ddGetObjDMSys ** ) ; ** let ** ) ; ** procedure CDS_P4GetClient ** procedure(CDS_P4UnRevLib(lib) ;_Mar 22 00 sikand 735 prog((cmd client status viewspec viewline viewmap oblit) if( ddGetObjDMSys(ddGetObj(lib)) == "p4" then ;; get the view mapping from the client ;; this is so dangerous if certain conditions are met ;; that I am disabling it ;; it can blow away your while depot unless there is better ;; error checking....very scary...I'll come back to it ;; later....a non existent client will return //depot/... ;; as the viewmap...chew on that !!!! return(nil) client = CDS_P4GetClient(ddGetObj(lib)) ;; this command will hang the p4 skillserver anyway ;; 'coz it's an old style call (pre-skillserver) status = CDS_P4IPCBufferProcess(strcat("client -o " client)) unless( zerop(status) println("p4 client -o command failed, abort\n") return() ) viewspec = parseString(CDS_IPCBuffer "\n") viewline = nthelem(length(viewspec) viewspec) viewmap = car(parseString(viewline)) if( hiGraphicMode() then oblit = CDS_WarnDialogBox("P4 Interface" strcat( "Are you sure you want to OBLITERATE " lib "?" )) when( oblit oblit = CDS_WarnDialogBox("P4 Interface" "You're sure your sure ?") ) else oblit = t ) ; ** if hiGraphicMode ** when( oblit status = CDS_P4IPCCommand(strcat("obliterate -y " viewmap)) unless( zerop(status) println("obliterate failed!") return() ) status = CDS_P4IPCCommand(strcat("client -df " client)) unless( zerop(status) println("client delete failed!") return() ) ;; set the permissions sprintf(cmd "chmod -R ug+rw %s\n" ddGetObj(lib)~>writePath) CDS_IPCCommand(cmd) CDS_ddSetLibDMSys(ddGetObj(lib) "none") ) ; ** when oblit ** else CDS_P4Error("P4 Interface" "Library was not managed!") ) ; ** if ddGetObjDMSys ** ) ; ** prog ** ) ; ** procedure CDS_P4UnRevLib ** procedure(CDS_P4AnyCheckouts(ddid @optional version_override) ;_Mar 18 03 jdao 3198 prog(( status validedit editname client xt user cmd branches bdfile prefix postfix bchanges changes mychange headbranch object file dfile branch bname headchange headchangenum maxhead maxheadbranch table cell) user = CDS_P4User maxhead = 0 client = CDS_P4GetClient(ddid~>lib) CDS_P4CurrentClient=client branch = CDS_P4CurrentBranch xt = CDS_NFSSimplify(ddid~>writePath) if( ddid~>type == 'ddViewFileType then object=strcat("/" ddid~>lib~>name "/" ddid~>cell~>name "/") infostring = ddid~>cell~>name else if( ddid~>type == 'ddCellFileType then cell = car(ddid~>??->?) object=strcat("/" ddid~>lib~>name "/" cell~>name "/") infostring = ddid~>cell~>name else if(ddid~>type == 'ddLibFileType then object=strcat(ddid~>lib~>name "/" ddid~>name) infostring = object ) ; ** if ddid ** ) ; ** if ddid ** ) ; ** if ddid ** if(CDS_P4MultiBranchCheckoutOverride then ;warn("Multi Branch Checkout Override is enabled") ;;hiGetAttention() ;; check for multiple user collisions ;; this doesn't work for the shared branch model ;; since the client names are not unique ;;sprintf(cmd "p4 opened -a //depot/%s/... | grep %s | grep %s | grep %s" client object ddid~>name) ;; instead look for all opened files in the current branch ;; rather than in the current client sprintf(cmd "p4 opened -a //depot/%s/... | grep %s | grep %s" branch object ddid~>name) else ;; check for global collisions (full branch space) sprintf(cmd "p4 opened -a //depot/%s*/... | grep %s | grep %s | grep %s" CDS_Project ddid~>lib~>name object ddid~>name) ) ; ** if CDS_P4MultiBranchCheckoutOverride ** ;; not needed any more because of seeding of the opened command ;; ignore opens from another project ;;when( CDS_P4MultiProjectCheckoutOverride ;; cmd = strcat(cmd " | grep " strcat(CDS_Project "_" CDS_ProjectRev)) ;;) ;; also need a way to reject changes from 'decoupled branches' ;; need to store a list of decoupled branches ;; at startup time for performance reasons ;; this is a safe option since it will lockout access if ;; a branch is created after the session has started status=CDS_IPCBufferProcess(cmd) when( CDS_IPCBuffer when(rexMatchp("not opened anywhere" CDS_IPCBuffer) return(nil) ) validedit = strcat(user "@" client) editname = car(reverse(parseString(CDS_IPCBuffer))) when( editname == validedit return(nil) ) if( hiGraphicMode() then CDS_ErrorDialogBox("P4 Interface" strcat(infostring "\nis being edited by\n" editname)) return(t) else printf("Error: Object %s is already being edited by %s\n !" infostring editname) return(t) ) ; ** if hiGraphicMode ** ) ; ** when CDS_IPCBuffer ** ;; end simple collision detect ;; begin out-of-sync state check table = CDS_P4Fstat(ddid~>writePath) unless( table->headAction == "delete" ;; ignore deleted views : jdao 03/18/03 when( (table~>haveRev != table~>headRev) && !version_override when( hiGraphicMode() CDS_ErrorDialogBox("P4 Interface" strcat("Out of sync error.\nCell: " infostring "\nPlease sync the library !")) ) printf("Sync error: Your version of %s is not in sync.\nYou have #%s and the latest is #%s.\n" infostring table~>haveRev table~>headRev) return(t) ) ; ** when table ** ) ; ** unless table ** ;; begin multi branch pending check unless(CDS_P4MultiBranchCheckoutOverride ;; now check branch changes ;; check all the branches ( general solution may optimize ;; later) ;;; need a depot spec file = CDS_NFSSimplify(ddid~>readPath) dfile = table~>depotFile unless( boundp('dfile) ;; no depot file ;; coz it never existed, probably return() ) unless( branch if( member(CDS_P4User CDS_P4Protect["mainline"]) then warn("Mainline editing in progress, branch dependencies will NOT be checked") return() else ;; this user does have permission to do main ;; line edit printf("ERROR: You do not have permission to do mainline edits.\n") return(t) ) ; ** if member ** ) ; ** unless branch ** ;; get a list of all the branches status = CDS_P4IPCBufferProcess("branches") unless( zerop(status) error("branches failed") return(t) ) branches = parseString(CDS_IPCBuffer "\n") if( CDS_P4MultiProjectCheckoutOverride then ;;only check for branches in the same project branches = setof(i branches rexMatchp(strcat(CDS_Project "_") i)) ) rexCompile(strcat("\\(.*\\)\\(" branch "\\)\\(.*\\)")) ;; file is not project/branch sensitive ;; eg private library or other depot spec unless(rexExecute(dfile) return(nil) ) prefix = rexSubstitute("\\1") postfix = rexSubstitute("\\3") foreach(b branches ;; ignore template branches ;; ignore decoupled branches ;; ignore current branch unless( rexMatchp("template" b) || rexMatchp("Decoupled" b) || rexMatchp(branch b) bname=cadr(parseString(b)) bdfile = strcat(prefix bname postfix) ;; get the changes for this file cmd = strcat("changes " bdfile) status = CDS_P4IPCBufferProcess(cmd) unless( zerop(status) error("changes1 failed") return(t) ) bchanges = parseString(CDS_IPCBuffer "\n") foreach( c bchanges ;; reject branch submits and auto integrates unless( rexMatchp("Branch submit" c) || rexMatchp("auto-int" c) ;; get the head change headchange = cadr(parseString(c)) headbranch = nthelem(6 parseString(c)) bchanges = nil ) ; ** unless rexMatchp ** when( headchange headchangenum = evalstring(headchange) when( headchangenum > maxhead maxhead = headchangenum maxheadbranch=headbranch ) ) ; ** when headchange ** ) ; ** foreach c ** ) ; ** unless rexMatchp ** ) ; ** foreach b ** ;; make sure headchange is valid when( maxhead == 0 return() ) ;; get the change number of the current file status = CDS_P4IPCBufferProcess(strcat("changes " dfile)) unless( zerop(status) error("changes2 failed") return(t) ) changes = car(parseString(CDS_IPCBuffer "\n")) mychange = cadr(parseString(changes)) unless( mychange error("changes value invalid") ) ;; convert if( maxhead > evalstring(mychange) then when( hiGraphicMode() CDS_ErrorDialogBox("P4 Interface" sprintf( nil "Cell has pending changes or un-integrated changes in another branch!\n\nLast changed by:\n\n%s Change %d" maxheadbranch maxhead)) ) printf("Cell has pending changes or un-integrated changes in another branch!\n"); printf("Changed by %s, change %d\n" maxheadbranch maxhead) return(t) ) ; ** if maxhead ** ) ; ** unless CDS_P4MultiBranchCheckoutOverride ** return(nil) ) ; ** prog ** ) ; ** procedure CDS_P4AnyCheckouts ** procedure(CDS_P4Fstat(file) ;_Nov 13 01 sikand 0 prog(( rf fstat dtype dtyped fdd status rftable index) if( !rexMatchp("depot" file) then rf = CDS_NFSSimplify(file) else rf = file ) rftable = makeTable("P4Fstat") status = CDS_P4IPCBufferProcess(strcat("fstat " rf)) ;;unless( zerop(status) ;; error("Fstat failed") ;;) fstat = parseString(CDS_IPCBuffer "\n") when( rexMatchp("no such file" CDS_IPCBuffer) return(rftable) ) foreach( fd fstat fdd = parseString(fd) when( fdd if( nthelem(2 fdd) == "..." then index = 3 else index = 2 ) dtype = stringToSymbol(nthelem(index fdd)) dtyped = nthelem(index+1 fdd) rftable[dtype] = dtyped ) ; ** when fdd ** ) ; ** foreach fd ** return(rftable) ) ; ** prog ** ) ; ** procedure CDS_P4Fstat ** procedure(CDS_P4FixPerm(path) ;_May 4 00 sikand 0 let(( cmd status) ;; make file read/write cmd = strcat("chmod a+rw " path) status = CDS_IPCCommand(cmd) unless( status == 0 error("Failed to fix perm for %s\n", path) ) t ) ; ** let ** ) ; ** procedure CDS_P4FixPerm ** procedure(CDS_ddSetLibDMSys(ddid ddtype) ;_Oct 14 00 sikand 0 ; replacement for 4.4.1 ddSetLibDMsys ; ddid library ddid ; Returns t/nil prog((dmobj path file) ;; clear any dmtypes ddClearLibUnmanaged(ddid) dmobj = ddGetObj(ddid~>name "" "" "cdsinfo.tag") if(dmobj then path = dmobj~>writePath else warn("no cdsinfo.tag found, trying to create one") path=strcat(ddid~>writePath "/cdsinfo.tag") ) ; ** if dmobj ** file = outfile(path "a") unless(file warn("failed to write cdsinfo.tag file for %s\n" ddid~>name) return() ) fprintf(file "DMTYPE %s\n" ddtype) close(file) ddSetForcedLib(ddGetForcedLib()) ddUpdateLibList() ;; force a refresh return(t) ) ; ** prog ** ) ; ** procedure CDS_ddSetLibDMSys ** load("CDS_P4Config.il") load("CDS_P4Utils.il") load("CDS_P4IPCFuncs.il") load("CDS_P4NFS.il") CDS_P4SetupP4() CDS_P4SetGlobals()