; 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 PERFORCE ; OR SGI 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_P4DisplayCo(libname @optional cotable) ;_Nov 13 01 sikand 395 prog(( formSym colistbox optionsbutton form deselbutton clientbutton selmatchbutton client selbutton checkinmode wmode liblist libchoices curlibname selmatchstring) when( ddGetObj(libname)~>p4CheckinType == "Bulk" CDS_ErrorDialogBox("Bulk Mode" "Show Checkouts Disabled for Bulk Mode") return() ) formSym = concat("CDS_P4CO" "Uniq") ;;println(symeval(formSym)) when( ddGetObjDMSys(ddGetObj(libname)) != "p4" warn("Lib %s is unmanaged..skipping\n" libname) return() ) wmode = CDS_P4CheckinMode if(symeval(formSym) == 'unbound || !hiIsForm(symeval(formSym)) then ;; make a global checkout table CDS_P4COTable = makeTable("CDS_P4COTable" nil) curlibname = libname cotable = CDS_P4BuildTable(libname nil) client = CDS_P4GetClient(ddGetObj(libname)) liblist = setof(x ddGetLibList() (ddGetObjDMSys(x) == "p4" && x~>p4CheckinType != "Bulk")) liblist = liblist~>name liblist = cons("All" liblist) libchoices = hiCreateCyclicField(?name 'libchoices ?choices liblist ?prompt "Library" ?value curlibname ?callback "curlibname=form->libchoices->value CDS_P4RefreshCheckouts(curlibname)" ) colistbox = hiCreateListBoxField(?name 'colistbox ?choices sort(cotable~>? 'alphalessp) ?callback "" ?multipleSelect t ) optionsbutton = hiCreateRadioField(?name 'optionsbutton ?choices list("Checkin" "Cancel Checkout") ?prompt "Action" ?value "Checkin" ) clientbutton = hiCreateRadioField(?name 'clientbutton ?choices list("Mine" "Everyone in this branch") ?prompt "Client" ?value "Mine" ?defValue "Mine" ?callback list("CDS_P4RefreshCheckouts(curlibname t)") ) selbutton = hiCreateButton(?name 'selbutton ?buttonText "Select All" ?callback "form->colistbox->value=form->colistbox->choices" ) deselbutton = hiCreateButton(?name 'deselbutton ?buttonText "Deselect All" ?callback "form->colistbox->value=nil" ) selmatchbutton=hiCreateButton(?name 'selmatchbutton ?buttonText "Select Matching" ?callback "form->colistbox->value=CDS_P4SelMatch(form->selmatchstring->value form->colistbox->choices)" ) selmatchstring= hiCreateStringField(?name 'selmatchstring ?prompt "" ?value "" ) checkinmode = hiCreateCyclicField(?name 'checkinmode ?choices list("Preserve Edit" "Preserve Read" "Close") ?prompt "Window Mode" ?value wmode ?defValue "Preserve Edit" ) hiCreateAppForm(?name formSym ?fields list(list(optionsbutton 0:10 10:10 0) list(clientbutton 200:10 20:10 0) list(checkinmode 450:0 100:30 90) list(selbutton 0:35 100:20 0) list(deselbutton 100:35 100:20 0) list(selmatchbutton 200:35 100:20 0) list(selmatchstring 310:30 100:20 0) list(libchoices 450:35 100:30 90) list(colistbox 0:70 700:400 0)) ?formTitle strcat("Show checkouts: " libname " (" client ")") ?callback '(CDS_P4DisplayCoCB nil) ?unmapAfterCB nil ?initialSize t ?buttonLayout 'OKCancelApply ) form = symeval(formSym) form->lib = libname ;; don't display an empty form ;;hiSetFormButtonEnabled( form 'Cancel nil) if( form->colistbox->choices then hiDisplayForm(formSym) else ;;printf("Info: No checkouts for library %s\n" libname) form->colistbox->choices = list(strcat("No checkouts for " libname)) hiDisplayForm(formSym) ) ; ** if form ** else ;; update the form data client = CDS_P4GetClient(ddGetObj(libname)) form = symeval(formSym) form->lib = libname ;; this triggers the Refresh if( libname != form->libchoices->value then form->libchoices->value = libname CDS_P4RefreshCheckouts(nil nil t) else CDS_P4RefreshCheckouts(nil nil t) ) ;; default action is always checkin form->optionsbutton->value = "Checkin" form->clientbutton->value = "Mine" ;;CDS_P4RefreshCheckouts(nil) ;; update the form name if( form->colistbox->choices then hiChangeFormTitle(form strcat("Show checkouts: " libname " (" client ")")) hiDisplayForm(formSym) else form->colistbox->choices = list(strcat("No checkouts for " libname)) hiDisplayForm(formSym) printf("Info: No checkouts for library %s\n" form->libchoices->value) ) ; ** if form ** ) ; ** if symeval ** return(t) ) ; ** let ** ) ; ** procedure CDS_P4DisplayCo ** procedure(CDS_P4SelMatch(match list) let((result) printf("Selecting cells that match %s\n" match) result=rexMatchList(match list) println(result) result ) ) procedure(CDS_lbbDisplayChanges(libname @optional cotable) ;_Apr 4 00 sikand 2324 prog(( formSym colistbox form deselbutton client selbutton changes voptionsbutton boptionsbutton branchspec) formSym = concat("CDS_P4Ch" "Uniq") when( ddGetObjDMSys(ddGetObj(libname)) != "p4" warn("Lib %s is unmanaged..skipping\n" libname) return() ) ;;println(symeval(formSym)) if(symeval(formSym) == 'unbound || !hiIsForm(symeval(formSym)) then changes = CDS_P4GetLibChanges(libname) client = CDS_P4GetClient(ddGetObj(libname)) colistbox = hiCreateListBoxField(?name 'colistbox ?choices changes ?callback "" ?multipleSelect nil ) voptionsbutton = hiCreateRadioField(?name 'voptionsbutton ?choices list( "Describe change" "Re-synchronize") ?prompt "Action" ?value "Describe change" ) boptionsbutton = hiCreateRadioField(?name 'boptionsbutton ?choices list( "Branch changes" "Lib changes") ?prompt "Action" ?value "Lib changes" ?callback '("CDS_lbbBranchUpdate(form)") ) ;; selbutton = hiCreateButton(?name 'selbutton ?buttonText "Select All" ?callback "form->colistbox->value=form->colistbox->choices" ) deselbutton = hiCreateButton(?name 'deselbutton ?buttonText "Deselect All" ?callback "form->colistbox->value=nil" ) hiCreateAppForm(?name formSym ?fields list(list(voptionsbutton 0:10 10:10 0) list(boptionsbutton 300:10 10:10 0) list(selbutton 0:35 100:20 0) list(deselbutton 100:35 100:20 0) list(colistbox 0:70 680:300 0)) ?attachmentList list( nil nil nil nil hicTopPositionSet) ?formTitle strcat("Show changes: " libname " (" client ")") ?callback 'CDS_lbbDisplayChCB() ?initialSize list(700 400) ) form = symeval(formSym) form->lib = libname hiDisplayForm(formSym) else form = symeval(formSym) form->lib = libname hiDisplayForm(formSym) ) ; ** if symeval ** return(t) ) ; ** let ** ) ; ** procedure CDS_lbbDisplayChanges ** procedure(CDS_lbbBranchUpdate(form) ;_Apr 4 00 sikand 478 let((branchspec client libname) if( form->boptionsbutton->value == "Branch changes" then if( branchspec = getShellEnvVar(CDS_P4ProjectBranchEnvVar) then form->colistbox->choices = CDS_P4GetBranchChanges(strcat("//depot/" branchspec)) hiChangeFormTitle(form strcat("Show changes: " branchspec)) else error("No branch detected\n") ) ; ** if branchspec ** else libname = form->lib form->colistbox->choices = CDS_P4GetLibChanges(libname) client = CDS_P4GetClient(ddGetObj(libname)) hiChangeFormTitle(form strcat("Show changes: " libname " (" client ")")) ) ; ** if form ** ) ; ** let ** ) ; ** procedure CDS_lbbBranchUpdate ** procedure(CDS_lbbDisplayChCB(form) ;_May 4 00 sikand 0 ; ;; callback for show versions form let(( changenum choices action lel status pchange uport ufile2 uport2 fname xname uflist el2 cmd lin ufile) choices = form->colistbox->value action = form->voptionsbutton->value foreach( el choices lel = parseString(el) changenum = nthelem(2 lel) when( action == "Describe change" printf("Getting description for change %s, please wait....\n" changenum) ;;status = CDS_P4IPCCommand(strcat("describe -s " changenum ">/tmp/p4des." CDS_P4UserFileName)) status = CDS_P4IPCCommand(strcat("-o /tmp/p4des." CDS_P4UserFileName " describe -s " changenum)) when( status == 0 view(strcat("/tmp/p4des." CDS_P4UserFileName)) ) ) ; ** when action ** when( action == "Re-synchronize" CDS_P4Resync(form->lib) ) when( action == "Undo change" error("Unsupported!") unless(CDS_WarnDialogBox("P4 Interface" "Are you sure you want to undo changes ?") error("Operation cancelled") ) uflist = list() when( rexMatchp("Branch submit" el) CDS_ErrorDialogBox("P4 Interface" "Can't undo branch creation !") error("Operation aborted") ) ;; todo ;; this will only support cdb objects for now ;; no cdfs, prop bags, view files, cat files etc ;; extension part2 ;; get the list of cdb files at that change ufile = strcat("/tmp/p4undo." CDS_P4UserFileName) status = CDS_P4IPCCommand( strcat("-o " ufile " files //...@" changenum ",@" changenum)) unless( status == 0 error("files command failed") ) ;; sync them all back to changenum-1 pchange = sprintf(nil "@%d" evalstring(changenum)-1) uport = infile(ufile) ufile2 = strcat("/tmp/p4undo2." CDS_P4UserFileName) uport2 = outfile(ufile2) while( gets(lin uport) fname = car(parseString(lin)) uflist = cons(fname uflist) rexCompile("#[0-9]+") xname = rexReplace(fname pchange 0) fprintf(uport2 "%s\n" xname) ) ; ** while gets ** close(uport2) close(uport) ;; do the sync action sprintf(cmd "-x %s sync" ufile2) status = CDS_P4IPCCommand(cmd) unless( status == 0 error("sync command failed") ) foreach( nel uflist when( rexMatchp("\\.cdb" nel) ;; call revert file ;;println("Rverting file %s\n",el2) el2 = car(parseString(nel "#")) printf("Reverting file %s\n",el2) CDS_P4RevertDepotFile(el2 form->lib changenum) ) ; ** when rexMatchp ** ) ; ** foreach nel ** ;; re-sync the changes forms CDS_lbbDisplayChanges(form->lib) ) ; ** when action ** ) ; ** foreach el ** ) ; ** let ** ) ; ** procedure CDS_lbbDisplayChCB ** procedure(CDS_P4Cancel() ;_Oct 2 98 sikand 0 let(() println("Got a cancel") ) ) ; ** procedure CDS_P4Cancel ** procedure(CDS_P4DisplayVer(vlist ddid @optional single) ;_Oct 23 01 sikand 231 let(( formname verlistbox voptionsbutton form depotfile) formname = concat("CDS_P4Ver" "Form") depotfile = car(vlist) vlist = cdr(vlist) if( (symeval(formname) == 'unbound || symeval(formname) == nil) then verlistbox = hiCreateListBoxField(?name 'verlistbox ?choices vlist ?multipleSelect nil ) voptionsbutton = hiCreateRadioField(?name 'voptionsbutton ?choices list("Describe change" "Revert version" "Build version copy" ) ?prompt "Action" ?value "Describe change" ) hiCreateAppForm(?name formname ?fields list(list(voptionsbutton 0:10 500:10 0) list(verlistbox 0:35 900:380 0)) ?attachmentList list( nil hicTopPositionSet) ?formTitle "Show versions" ?callback 'CDS_P4DisplayVerCB() ?initialSize list(860 390) ) form = symeval(formname) form->appData = ddid form->appData2 = depotfile hiDisplayForm(form) form->single = single else form = symeval(formname) form->single = single form->verlistbox->choices = vlist form->voptionsbutton->value = "Describe change" form->appData = ddid form->appData2 = depotfile hiDisplayForm(form) ) ; ** if symeval ** ) ; ** let ** ) ; ** procedure CDS_P4DisplayVer ** procedure(CDS_P4Integrated(dfile version) ;_Apr 21 02 sikand 612 ; Get the integrated data for a particular version ; dfile depot file ; version version required let(( integdata matchdata bfrom) CDS_P4IPCBufferProcess(strcat("integrated " dfile)) when( CDS_IPCBuffer integdata = parseString(CDS_IPCBuffer "\n") ;; get the branch from record for the specified version matchdata = car(setof(x integdata rexMatchp(strcat(dfile "#" version " - branch from") x))) unless( matchdata error("CDS_P4Integrated: Couldn't find branch record") ) bfrom = nthelem(5 parseString(matchdata)) ) bfrom ) ; ** let ** ) ; ** procedure CDS_P4Integrated ** procedure(CDS_P4DisplayVerCB(form) ;_Apr 21 02 sikand 3831 ; ;; callback for show versions form prog(( formname choices depotname version changenum lel status depotfile action cell view cellvdir cflist fname lin destfname viewvdir cmd ddid flist lib done vflist labelf lname bname labelp dd cont mfile sversion delist fstable cfile ichange currversion ilist tlist rvmode source) choices = form->verlistbox->value ddid = form->appData depotname = car(form->verlistbox->choices) rexCompile("#[0-9]+") depotfile = form->appData2 currversion = car(reverse(parseString(depotname "#"))) action = form->voptionsbutton->value formname = concat("CDS_P4Ver" "Form") foreach( el choices unless( rexMatchp("depot" el) ;; get the version and change number lel = parseString(el) version = nthelem(2 lel) sversion = substring(version 2) changenum = nthelem(4 lel) when( action == "Describe change" printf("Getting description for change %s, please wait....\n" changenum) ;;status = CDS_P4IPCCommand(strcat("describe -s " changenum ">/tmp/p4des." CDS_P4UserFileName)) status = CDS_P4IPCCommand(strcat("-o /tmp/p4des." CDS_P4UserFileName " describe -s " changenum)) when( status == 0 view(strcat("/tmp/p4des." CDS_P4UserFileName)) ) ) ; ** when action ** when( action == "Revert version" when( sversion == currversion CDS_ErrorDialogBox("P4 Interface" "Hey, that's already the current version!") error("Revert aborted!") ) when( rexMatchp("delete on" el) CDS_ErrorDialogBox("P4 Interface" "Hey, that's a deleted version!") error("Revert aborted!") ) cont = CDS_WarnDialogBox("P4 Interface" "Are you sure you want to revert to an older version ?") unless( cont error("Revert aborted!") ) ;; make sure that the file is not currently opened printf("Checking status of %s...\n" depotfile) CDS_P4IPCBufferProcess(strcat("opened " depotfile)) if( rexMatchp("change" CDS_IPCBuffer) then CDS_ErrorDialogBox("P4 Interface" strcat("This cell is currently checked out --\n" CDS_IPCBuffer)) else ;; do a re-integrate if necessary rather than ;; a local revert ;; this is an important distinction...it stops ;; the integration wizard from generating new ;; entries for reverted cells if possible.... lib = ddid~>lib ;; p4type may be undefined or missing ;; due to property bag write permission errors ;; during revisioning, so let's do some checks ;; since this is pretty important unless( lib~>p4type error("Couldn't determine p4type (Reference,Design,User) for this library") ) if( lib~>p4type == "Reference" || lib~>p4type == "Design" then action = nthelem(5 lel) bname = getShellEnvVar(CDS_P4ProjectBranchEnvVar) ;; add support for mainline version recovery unless( bname rvmode = "mainline" ) if( (action == "integrate" || action == "branch") && bname then done = t ;; if it was ;; get the contents of the copy/branch from ;; record of each file of the atomic ;; but make sure we are not in single mode if( form->single then ;; get the depot file name vflist = CDS_P4GetBranchRecord(form) else vflist = CDS_P4GetAtomicFiles( ddid ?version sversion) ) ; ** if form ** ;; create a label ;; Create a numbered change list ichange = CDS_P4CreateChange(CDS_P4CurrentClient strcat("cds:Checkin re-integrated #" sversion)) foreach( file parseString(vflist) source = CDS_P4Integrated(file sversion) cmd = sprintf(nil "integrate -i -c %s -f %s %s" ichange source file) status = CDS_P4IPCCommand(cmd) ) ;; resolve -at ;; don't stomp other pending resolves though vflist = CDS_P4GetAtomicFiles(ddid ?version sversion) ilist = parseString(vflist) cmd = sprintf(nil "resolve -at %s" vflist) status = CDS_P4IPCCommand(cmd) ;;when( rexMatchp("no file(s) to resolve" CDS_IPCBuffer) ;;error("Resolve failed, get help!") ;;) ;; need to delete files that were not part ;; of the new integrate but may exist ;; in the head revision delist = CDS_P4GetAtomicDifferences(ddid ?v1 "head" ?v2 sversion) foreach( el delist cmd = sprintf(nil "delete -c %s %s" ichange el) status = CDS_P4IPCCommand(cmd) unless( status == 0 error("Failed to delete %s\n",el) ) ) ; ** foreach el ** printf("Checking in re-integrated version %s\n", sversion) sprintf(cmd "-c %s submit -c %s" CDS_P4CurrentClient ichange) status = CDS_P4IPCCommand(cmd) unless( status == 0 error(CDS_IPCBuffer) ) if( rexMatchp("No files to submit" CDS_IPCBuffer) error("Submit failed, get help!") ) ddsHiRefresh() if( (symeval(formname) != 'unbound || symeval(formname) != nil) then form = symeval(formname) when( hiIsFormDisplayed(form) ;; call the routine again to refresh the form CDS_P4ShowVersions(form->appData) ) ) ; ** if symeval ** return(t) ) ; ** if action ** ) ; ** if lib ** unless( done fprintf(stdout "Syncing to change %s\n", changenum) ;; get the atomics specifically for this version flist = parseString(CDS_P4GetAtomicFiles(ddid ?version sversion)) foreach( f flist printf("Syncing %s\n", f) status = CDS_P4IPCCommand(strcat("sync " f "@" changenum)) unless( status == 0 CDS_P4Error("ERROR" "version sync failed") ) ) ; ** foreach f ** ) ; ** unless done ** when( status ==0 && !done printf("Version reverted to change number %s\n", changenum) ;; Create a numbered change list ichange = CDS_P4CreateChange(CDS_P4CurrentClient strcat("cds:Checkin re-synced #" sversion)) foreach( f flist status = CDS_P4IPCCommand(strcat("edit -c " ichange " " f)) unless( status == 0 CDS_P4Error("ERROR" "edit failed (version)") ) status = CDS_P4IPCCommand(strcat("sync " f)) unless( status == 0 CDS_P4Error("ERROR" "sync failed (version)") ) cmd = sprintf(nil "resolve -ay %s" f) status = CDS_P4IPCCommand(cmd) ;;when( rexMatchp("no file(s) to resolve" CDS_IPCBuffer) ;; error("Resolve failed, get help!") ;;) ) ; ** foreach f ** ;; compute the differences in atomicity and ;; remove extraneous co-managed files delist = CDS_P4GetAtomicDifferences(ddid ?v1 "head" ?v2 sversion) foreach( el delist cmd = sprintf(nil "delete -c %s %s" ichange el) status = CDS_P4IPCCommand(cmd) unless( status == 0 CDS_P4Error("ERROR" "delete failed (version)") ) ) ; ** foreach el ** printf("Checking in previous version #%s to head\n", sversion) sprintf(cmd "-c %s submit -c %s" CDS_P4CurrentClient ichange) status = CDS_P4IPCCommand(cmd) unless( status == 0 error(CDS_IPCBuffer) ) ddsHiRefresh() ) ; ** when status ** ) ; ** if rexMatchp ** ) ; ** when action ** when( action == "Build version copy" ;; get the atomic list of files ;; associated with the ddid ;; and their specific versions when( rexMatchp("delete on" el) CDS_ErrorDialogBox("P4 Interface" "Hey, that's a deleted version!") error("Build version copy aborted!") ) cont = CDS_WarnDialogBox("P4 Interface" "This builds you an unmanaged version purely for simultaneous viewing purposes.\nDo not instantiate this version in a design.\nThe cell will be created with a __ver suffix\nUse revert version if you really want to instantiate an older version\n") unless( cont error("User abort!") ) ;; get the cell directory cell = CDS_NFSSimplify(ddid~>cell~>writePath) view = ddid~>view~>name ;; construct a versioned name cellvdir = strcat(cell "___ver" substring(version 2)) ;; make the cell directory when( ! isDir(cellvdir) CDS_IPCCommand(strcat("mkdir " cellvdir)) ) viewvdir = strcat(cellvdir "/" view) ;; make the view directory when( ! isDir(viewvdir) CDS_IPCCommand(strcat("mkdir " viewvdir)) ) cflist = parseString(CDS_P4GetAtomicFiles(ddid ?withversion t ?version sversion)) foreach( dfile cflist ;; get the name of the file fname = car(reverse(parseString(dfile "/"))) fname=car(parseString(fname "#")) ;; build the destination destfname = strcat(viewvdir "/" fname) ;; p4 print them out to the destination ;;sprintf(cmd "print -q %s > %s" dfile destfname) sprintf(cmd "-o %s print -q %s" destfname dfile) status = CDS_P4IPCCommand(cmd) unless( zerop(status) error(strcat("Failed to get file " dfile " from depot !")) ) ) ; ** foreach dfile ** printf("Built version %s as cell %s__ver%s" version ddid~>cell~>name substring(version 2)) ;) ; ** when status ** ) ; ** when action ** ) ; ** unless rexMatchp ** ) ; ** foreach el ** ;; refresh the list box if( (symeval(formname) != 'unbound || symeval(formname) != nil) then form = symeval(formname) when( hiIsFormDisplayed(form) ;; call the routine again to refresh the form CDS_P4ShowVersions(form->appData) ) ) ; ** if symeval ** ) ; ** let ** ) ; ** procedure CDS_P4DisplayVerCB ** procedure(CDS_P4DisplayCoCB(form) ;_Oct 18 00 sikand 1321 prog(( choices action object ddid objcmd objectlist bstring ojl ojln formname cmessage bad CDS_P4MultiSelect check) choices = form->colistbox->value action = form->optionsbutton->value ;;libname = form->lib when( action == "Select All" form->colistbox->value = form->colistbox->choices ) CDS_P4CheckinMode = form->checkinmode->value CDS_P4MultiSelect = nil if( length(choices) > 1 then CDS_P4MultiSelect = t ;; we only want a single message ;; get the message when(action != "Cancel Checkout" cmessage = CDS_P4CheckinMessage(nil t) ) ;; but user didn't specify a message when( cmessage == "" cmessage = "...." ) else cmessage = "" ) ; ** if length ** CDS_P4GroupCheckin = makeTable("CDS_P4GroupCheckin") foreach( el choices bad = nil when( member(el form->colistbox->value) ;; strip out the user rexCompile("\\((\\([a-z@_:]+\\))\\)") if( rexExecute(el) then when( rexSubstitute("\\2") != CDS_P4User warn("Not checkout owner: %s\n" el) bad = t ) el = rexReplace(el "" 1) ) ; ** if rexExecute ** when( ! bad && !rexMatchp("No checkouts" el) rexCompile("#[0-9]+") if( rexExecute(el) then ;; strip the # versio object = rexReplace(el "" 1) ;; turn it into a list objectlist = parseString(object) when( length(objectlist) == 2 sprintf(bstring "%s . . %s" car(objectlist) cadr(objectlist)) ojl = parseString(bstring) ojln = foreach( mapcar xel ojl when( xel == "." xel = nil ) xel ) ; ** foreach mapcar ** ) ; ** when length ** when( length(objectlist) == 3 sprintf(bstring "%s %s . %s" car(objectlist) cadr(objectlist) caddr(objectlist)) ojl = parseString(bstring) ojln = foreach( mapcar xel ojl when( xel == "." xel = nil ) xel ) ; ** foreach mapcar ** ) ; ** when length ** when( length(objectlist) > 3 ojln = objectlist ) sprintf(objcmd "ddGetObj%L" ojln) unless(ddid = evalstring(objcmd) CDS_ErrorDialogBox("P4 Interface" "Bad object data, CDS and P4 are out of sync, please handle manually !\n") return() ) CDS_P4GroupCheckin[ddid] = el else printf("Bad version data!\n") return() ) ; ** if rexExecute ** ) ; ** when bad ** ) ; ** when member ** ) ; ** foreach el ** when( action == "Cancel Checkout" && CDS_P4MultiSelect check = CDS_WarnDialogBox("Cancel Checkout" "Are you sure you want to cancel all these checkouts ?") unless( check return() ) ) ; ** when action ** foreach( gddid CDS_P4GroupCheckin when( action == "Checkin" && ! ddNeedCheckout(gddid) ;;when( action == "Checkin" printf("Checking in %s\n", CDS_P4GroupCheckin[gddid]) ddCheckin(gddid cmessage) ) when( action == "Cancel Checkout" && ! ddNeedCheckout(gddid) ;;when( action == "Cancel Checkout" when(ddCheckin(gddid "cancel (group)" "c") printf("Cancelled checkout for %s\n", CDS_P4GroupCheckin[gddid]) ) ) ) ; ** foreach gddid ** ;; clear the table CDS_P4GroupCheckin = makeTable("CDS_P4GroupCheckin") formname = concat("CDS_P4CO" "Uniq") if( (symeval(formname) != 'unbound || symeval(formname) != nil) then ;; call the routine again to refresh the form form = symeval(formname) when( hiIsFormDisplayed(form) ;; and the form action is not cancel ;;CDS_lbbShowCheckouts(form->libchoices->value) CDS_P4RefreshCheckouts(form->libchoices->value) ) ) ; ** if symeval ** ) ; ** prog ** ) ; ** procedure CDS_P4DisplayCoCB ** procedure(CDS_P4GetLibChanges(lib @optional branch maxchange) ;_Mar 29 00 sikand 333 ; change display browser data collection prog(( root fil cd libid client xlin lin) libid = ddGetObj(lib) ;; is it a Perforce controlled object when( ddGetObjDMSys(libid) != "p4" warn("Lib %s is unmanaged..skipping\n" lib) return() ) cd = list() client = CDS_P4GetClient(libid) CDS_P4CurrentClient = client unless( maxchange maxchange = 100 ) ;; get the root to get the changes CDS_IPCBufferProcess(strcat("p4 -c " client " client -o | grep \\^Root")) root = cadr(parseString(CDS_IPCBuffer)) ;;printf("Root is %s\n",root) CDS_P4IPCCommand(sprintf(nil "-o /tmp/p4changes.%s changes -m %d %s/..." CDS_P4UserFileName maxchange root)) fil = infile(strcat("/tmp/p4changes." CDS_P4UserFileName)) while( gets(lin fil) xlin = substring(lin 1 strlen(lin)-1) cd = cons(xlin cd) ) close(fil) return(reverse(cd)) ) ; ** let ** ) ; ** procedure CDS_P4GetLibChanges ** procedure(CDS_P4GetBranchChanges(branchspec) ;_Apr 4 00 sikand 166 ; change display browser data collection prog((fil lin xlin cd) ;; maxchange support ??? CDS_P4IPCCommand(sprintf(nil "-o /tmp/p4changes.%s changes %s/..." CDS_P4UserFileName branchspec)) fil = infile(strcat("/tmp/p4changes." CDS_P4UserFileName)) while( gets(lin fil) xlin = substring(lin 1 strlen(lin)-1) cd = cons(xlin cd) ) close(fil) return(reverse(cd)) ) ; ** let ** ) ; ** procedure CDS_P4GetBranchChanges ** procedure(CDS_P4BuildTable(lib @optional allclients append) ;_Jun 29 01 sikand 962 ; show checkouts for specified library prog((libid opfile cmd openfile cotable cline dline cell view xcell filen rfile fileddid master client lin user userclient oclient noddobj formname branch bspec matchcount key xline cofile cofilelist dspecrex pline odspec odspecl cclient) libid = ddGetObj(lib) ;; is it a Perforce controlled object when( ddGetObjDMSys(libid) != "p4" CDS_P4Error("P4 Interface" "Library is not managed!") return() ) client = CDS_P4GetClient(libid) CDS_P4CurrentClient = client if( append then cotable = CDS_P4COTable else CDS_P4COTable = makeTable("CDS_P4COTable" nil) cotable = CDS_P4COTable ) ; ** if append ** openfile = strcat("/tmp/p4open." CDS_P4UserFileName) formname = concat("CDS_P4CO" "Uniq") ;;form = symeval(formname) printf("Getting checkouts for %s\n" lib) if( allclients then bspec = strcat("@" lib ":") sprintf(cmd "opened -a //depot/%s/... | grep %s > %s" CDS_P4CurrentBranch bspec openfile) printf("Please wait, getting files for all branch clients....\n") CDS_P4IPCDirectCommand(cmd) else ;;sprintf(cmd "opened > %s" openfile) client = CDS_P4GetClient(ddGetObj(lib)) sprintf(cmd "-o %s opened" openfile) CDS_P4IPCCommand(cmd) ) ; ** if allclients ** ;; read the client to get the depot mapping CDS_P4IPCBufferProcess("client -o") odspec = parseString(CDS_IPCBuffer) odspecl = nthelem(length(odspec)-1 odspec) odspec = parseString(CDS_IPCBuffer) dspecrex= substring(odspecl 1 strlen(odspecl)-3-strlen(lib)-1) ;; read the opened files from disk opfile = infile(openfile) cclient = CDS_P4CurrentClient while( gets(lin opfile) ;; dspecrex is client dependent ;; need to get the client name ;; and then find it's mapping ;; on a file by file basis pline = parseString(lin) if( length(pline) == 6 then ;; default change oclient = CDS_P4CurrentClient else ;; change by someone else userclient = nthelem(8 pline) oclient = cadr(parseString(userclient "@")) ) ; ** if length ** unless( cclient == oclient cclient = oclient CDS_P4IPCBufferProcess(sprintf(nil "-c %s client -o" oclient)) odspec = parseString(CDS_IPCBuffer) odspecl = nthelem(length(odspec)-1 odspec) dspecrex= substring(odspecl 1 strlen(odspecl)-3-strlen(lib)-1) ) ;; remove the depot spec prefix to leave just the library ;; bit ;; eg ;; //depot/foo/bar/cadence/lib/cell/view/layout.cdb ;; should turn into ;; lib/cell/view/layout.cdb ;; -3 is for the ... and -1 is for the / ;; to give the entire prefix rexCompile(dspecrex) xline = car(pline) cofile = rexReplace(xline "" 0) cofilelist = parseString(cofile "/") matchcount = length(cofilelist) cline = lin dline = cofilelist if( rexMatchp(" by " lin) then ;; got a user that's not you userclient=car(reverse(parseString(lin))) user=car(parseString(userclient "@")) oclient = cadr(parseString(userclient "@")) when( oclient != client ;;user = userclient noddobj = t ) else user = nil ) ; ** if rexMatchp ** ;; get the ddobj and then only report the master cond( ;; library file ((matchcount == 2) key = strcat(car(dline) " " cadr(dline)) when( user key = strcat(key " (" user ")") ) cotable[key] = cline ) ;; cell file ((matchcount == 3) key = strcat(car(dline) " " cadr(dline) " " caddr(dline)) when( user key = strcat(key " (" user ")") ) cotable[key] = cline ) ;; view file ((matchcount == 4) ;;lib = nth(0 dline) xcell = nth(1 dline) view = nth(2 dline) filen = nth(3 dline) rexCompile("#[0-9]+") rfile = rexReplace(filen "" 1) if(fileddid = ddGetObj(lib xcell view rfile) then ;; only look for potential masters unless( rexMatchp("master.tag" fileddid~>name) master = CDS_P4GetMaster(fileddid) unless( master master = "ERROR" ) cell = "" for( i 0 length(dline)-2 cell = strcat(cell nth(i dline) " ") i++ ) when( master == rfile cell = strcat(cell " " filen) ;; when user when( user cell = strcat(cell " (" user ")") ) cotable[cell] = cline ) ; ** when master ** when( master == "ERROR" cell = strcat(cell " " master) cotable[cell] = cline ) ) ; ** unless rexMatchp ** else if( ! noddobj then printf("Failed to get ddobj for %s %s %s %s\n", lib xcell view rfile) printf("p4 thinks they exist in the client, but Cadence doesn't, ") printf("please clean up manually or see a developer\n") else cell = "" for( i 0 length(dline)-2 cell = strcat(cell nth(i dline) " ") i++ ) when( rexMatchp("\\.cdb" lin) cell = strcat( cell " " filen) ;; when user when( user cell = strcat(cell " (" user ")") ) cotable[cell] = cline ) ; ** when rexMatchp ** ) ; ** if noddobj ** ) ; ** if fileddid ** ) ) ; ** cond matchcount ** ) ; ** while gets ** close(opfile) return(cotable) ) ; ** prog ** ) ; ** procedure CDS_P4BuildTable ** procedure(CDS_P4RefreshCheckouts(@optional libnamespec refresh override) ;_Jun 26 01 sikand 0 prog(( cotable formname form libname client liblist action all) cotable = nil formname = concat("CDS_P4CO" "Uniq") form = symeval(formname) unless(hiIsFormDisplayed(form) unless( override return(nil) ) ) action = form->clientbutton->value if( action == "Everyone in this branch" then all = t ) if( refresh CDS_P4COTable = makeTable("CDS_P4COTable" nil) ) if( libnamespec then libname = libnamespec else libname = form->lib ) ;;printf("In cb for %s\n" libname) if( all then ;; rebuild the table if( libname == "All" then ;; do a global show checkouts liblist = setof(x ddGetLibList() ddGetObjDMSys(x) == "p4") foreach( lib liblist~>name ;; build the table in append mode cotable = CDS_P4BuildTable(lib t t) ) printf("done\n") else cotable = CDS_P4BuildTable(libname t nil) ) ; ** if libname ** hiChangeFormTitle(form strcat("Show checkouts: " libname " (all)")) else if( libname == "All" then ;; do a global show checkouts liblist = setof(x ddGetLibList() ddGetObjDMSys(x) == "p4") foreach( lib liblist~>name ;; build the table in append mode cotable = CDS_P4BuildTable(lib nil t) ) hiChangeFormTitle(form "Show global checkouts") else cotable = CDS_P4BuildTable(libname nil nil) client = CDS_P4GetClient(ddGetObj(libname)) hiChangeFormTitle(form strcat("Show checkouts: " libname " (" client ")")) ) ; ** if form ** ) ; ** if all ** form->colistbox->choices = sort(cotable~>? 'alphalessp) unless( form->colistbox->choices form->colistbox->choices = list(strcat("No checkouts for " libname)) ) ) ; ** let ** ) ; ** procedure CDS_P4RefreshCheckouts ** procedure(CDS_lbbShowCheckouts(lib) ;_Nov 5 99 sikand 132 ; show checkouts for specified library CDS_P4DisplayCo(lib) ) ; ** procedure CDS_lbbShowCheckouts ** procedure(CDS_P4ShowVersions(ddid @optional single) ;_Oct 23 01 sikand 1191 prog(( client cmd status fileno flog lin vlist depotfile depotver filen linc reportstring formatted_line ver formatted_line_ver) ;; is it a Perforce controlled object when( ddGetObjDMSys(ddid~>lib) != "p4" CDS_P4Error("P4 Interface" "Library is not managed!") return() ) client = CDS_P4GetClient(ddid~>lib) CDS_P4CurrentClient = client filen = CDS_NFSSimplify(ddid~>readPath) fileno = strcat("/tmp/p4flog." CDS_P4UserFileName) ;;sprintf(cmd "filelog %s > %s" filen fileno) sprintf(cmd "-o %s filelog %s" fileno filen) status = CDS_P4IPCCommand(cmd) vlist = nil linc = 0 when( status == 0 flog = infile(fileno) while( gets(lin flog) linc++ lin = car(parseString(lin "\n")) if( linc == 1 then reportstring = reverse(parseString(lin "/")) if( rexMatchp("cdb" lin) then formatted_line = sprintf(nil "%s %s " nthelem(3 reportstring) nthelem(2 reportstring)) else formatted_line = sprintf(nil "%s %s " nthelem(2 reportstring) nthelem(1 reportstring)) ) ; ** if rexMatchp ** depotfile = lin else vlist = cons(lin vlist) ) ; ** if linc ** ) close(flog) ) ; ** when status ** vlist = reverse(vlist) unless( depotfile error(strcat("Failed to get depot filename for " ddid~>name ", is it checked in yet ?")) ) ;; get the version info for the depotfile CDS_P4IPCBufferProcess(strcat("have " depotfile)) depotver = car(parseString(CDS_IPCBuffer " -")) ver = car(reverse(parseString(depotver "#"))) formatted_line_ver = strcat(formatted_line "#" ver) vlist = cons(formatted_line_ver vlist) vlist = cons(depotfile vlist) if( single then CDS_P4DisplayVer(vlist ddid t) else CDS_P4DisplayVer(vlist ddid) ) return(t) ) ; ** prog ** ) ; ** procedure CDS_P4ShowVersions ** procedure(CDS_P4CheckinMessage(ddid @optional multiple) ;_Nov 9 99 sikand 140 let((ckmessageform message ckmessage) ckmessage = hiCreateStringField(?name 'ckmessage ?prompt "Description" ?value "" ) if( ! multiple then if( ddid~>cell && ddid~>view then message = strcat(ddid~>cell~>name " " ddid~>view~>name) else message = ddid~>name ) else message = "group" ) ; ** if multiple ** ckmessageform = hiCreateAppForm(?name 'ckmessageform ?fields '(ckmessage) ?formTitle strcat("Checkin message for " message) ?buttonLayout 'OKCancel ) unless(hiDisplayForm(ckmessageform) CDS_ErrorDialogBox("P4 Interface" "Checkin request cancelled !") error("Checkin cancelled by user request") ) ckmessageform->ckmessage->value ) ; ** let ** ) ; ** procedure CDS_P4CheckinMessage ** procedure(CDS_P4LibFileManager(libname) ;_Oct 23 01 sikand 1057 ;; a front end for manipulating ;; library files let(( libfiles noncatfiles dd dlibfiles catfiles libFileBox libFileActions) dd = ddGetObj(libname) dlibfiles = setof(x dd~>files !rexMatchp("%" x~>name)) catfiles = sort(setof(x dlibfiles rexMatchp("Cat" x~>name))~>name 'alphalessp) noncatfiles = sort(setof(x dlibfiles !rexMatchp("Cat" x~>name))~>name 'alphalessp) libfiles = append(noncatfiles catfiles) ;; need to do some sorting libFileBox = hiCreateListBoxField(?name 'libFileBox ?prompt "Library Files" ?choices libfiles ?multipleSelect nil ) libFileActions = hiCreateCyclicField(?name 'libFileActions ?choices '("Show Versions" "View File") ?prompt "Action" ?value "Show Versions" ?defValue "Show Versions" ) hiCreateAppForm(?name 'libFileBoxForm ?fields list(list(libFileActions 0:10 10:10 0) list(libFileBox 0:70 700:400 0)) ?formTitle strcat("Library files for " libname) ?callback 'CDS_P4LibFileManagerCB() ) libFileBoxForm->lib = libname hiDisplayForm(libFileBoxForm) ) ; ** let ** ) ; ** procedure CDS_P4LibFileManager ** procedure(CDS_P4LibFileManagerCB(form) ;_Apr 11 00 sikand 244 ; callback for lib file manager let(( select ddid vfile) select = car(form~>libFileBox~>value) if( select then when( form~>libFileActions~>value == "Show Versions" ddid = ddGetObj(form->lib nil nil select) CDS_P4ShowVersions(ddid t) ) when( form~>libFileActions~>value == "View File" vfile = ddGetObj(form->lib nil nil select)~>readPath view(vfile) ) else printf("Nothing selected!\n") ) ; ** if select ** ) ; ** let ** ) ; ** procedure CDS_P4LibFileManagerCB ** procedure(CDS_P4GetBranchRecord(form) ;_Apr 11 00 sikand 603 ; get the branch/copy from record ; el matched element in the list ; form the form containing the filelog let(( match fromrec selected fromfile clist fromdata) clist = form->verlistbox->choices selected = car(form->verlistbox->value) match = member(selected clist) unless( match error("Couldn't parse show versions list box\n") ) fromrec = cadr(match) fromdata = car(reverse(parseString(fromrec))) fromfile = car(parseString(fromdata ",")) ) ; ** let ** ) ; ** procedure CDS_P4GetBranchRecord ** procedure(CDS_P4GetCopyTargets(label) ;_Jul 27 00 sikand 347 ; get the copy into targets for the files in this label ; label a p4 label name let((cmd fdata fnamev fnamevd version filen) sprintf(cmd "files @%s" label) CDS_P4IPCBufferProcess(cmd) fdata = parseString(CDS_IPCBuffer "\n") ;; mapcan foreach( mapcan fd fdata fnamev = car(parseString(fd)) fnamevd = parseString(fnamev "#") version = cadr(fnamevd) filen = car(fnamevd) list(CDS_P4ExtractTargets(filen version)) ) ; ** foreach fd ** ) ; ** let ** ) ; ** procedure CDS_P4GetCopyTargets ** procedure(CDS_P4ExtractTargets(filen version) ;_Oct 17 00 sikand 0 ; do a filelog and get the copy into targets for this version let(( changes changedata match vchangetext target j i) CDS_P4IPCBufferProcess(strcat("filelog " filen)) changes = parseString(CDS_IPCBuffer "\n") for( i 2 length(changes) changedata = nthelem(i changes) unless( changedata error("no copy into record") ) when(rexMatchp(strcat("... #" version " ") changedata) ;; let the fun begin j = 0 match = nil while( j j++ vchangetext = nthelem(i+j changes) ;; if we got a new version record stop when( (!vchangetext || rexMatchp("\\.\\.\\. #" vchangetext)) error("No copy into record for %s, seek HELP!!!\n" filen) ) when( rexMatchp(" copy into " vchangetext) || rexMatchp(" branch into " vchangetext) j = nil i = length(changes) ) ) ; ** while j ** target = nthelem(5 parseString(vchangetext)) ) ; ** when rexMatchp ** ) ; ** for i ** target ) ; ** let ** ) ; ** procedure CDS_P4ExtractTargets **