5 messages in com.perforce.perforce-userAutomate Label process| From | Sent On | Attachments |
|---|---|---|
| Char...@7thstreet.com | 28 Apr 1999 11:26 | |
| RJac...@symantec.comRJackson | 28 Apr 1999 13:31 | |
| Dave...@vignette.com | 28 Apr 1999 14:21 | |
| Chri...@wrq.com | 28 Apr 1999 14:24 | |
| Dave...@vignette.com | 28 Apr 1999 14:50 |
| Subject: | Automate Label process![]() |
|---|---|
| From: | Chri...@wrq.com (Chri...@wrq.com) |
| Date: | 04/28/1999 02:24:35 PM |
| List: | com.perforce.perforce-user |
very much along the lines of what rusty said...
the following is an excerpt that someone here wrote. it's from our upper-level makefile. it uses make targets to label, lock labels, and unlock labels. (note that this is written for Opus make). you pass the target a label name, as in
make label labelname="my_label"
if you don't pass a label name, it uses a utility called "query" (that i believe was written in-house) to prompt for the label name. (you'd probably have to substitute something else for "query" if you want that functionality). note that the targets also use shell commands (sed, grep, rm, etc.) -- we use a shell toolkit on our NT boxes.
as i said, this pretty much has all the steps that rusty already outlined. hope this helps.
=========================================================================== #-----------------------------------------------------------------------
------------------------------- # Label: Label the depot. # Algorithm: 1. Prompt for the label. # 2. If it's already been used, prompt for overwriting. # 3. Label the depot. #-----------------------------------------------------------------------
------------------------------- Label .ALWAYS $(SILENT) : %if "$(labelName)" == "" ### Prompt for the label. %set labelTmp = $(MAKE_TMP)\label.tmp rm -f $(labelTmp) %echo Enter the label: query 50 >$(labelTmp) %set labelName = $(labelTmp,@) %if "$(labelName)" == "" %abort 1 (Label) A label is required. %endif %endif
### See if it has already been used. %set labelListTmp = $(MAKE_TMP)\labelList.tmp rm -f $(labelListTmp) %set labelListTmp2 = $(MAKE_TMP)\labelList2.tmp rm -f $(labelListTmp2) *--p4 labels >$(labelListTmp) sed -i -e 's/label \(.*\) [0-9*].*/\1/' $(labelListTmp) >$(labelListTmp2) --grep -i "\<$(labelName)\>" $(labelListTmp2) %if $(STATUS) == 0 ### The label already exists. %if ( "$(DAILYBLD)" != "1" ) ### Assume this target is not being called from the daily build ### Ask user if they want to resync the label to the current client contents. %set responseTmp = $(MAKE_TMP)\response.tmp rm -f $(responseTmp) %echo Label '$(labelName)' has already been used. Do you wish to update it with %echo the current contents of your client (Y/[N])? query 5 >$(responseTmp) %set response = $(responseTmp,@) %if "$(response)" != "Y" %abort 1 (Label) Label command aborted by user. %endif %elif ( "$(DAILYBLD)" == "1" ) %echo Label '$(labelName)' has already been used. %echo Unlocking and updating label in Perforce... %endif ### Unlock the label. %do UnlockLabel LabelID=$(labelName) %else ### Create the new label. %set labelFormSrc = $(BUILTINS,D)\smsutils\$(labelForm) %set labelFormTmp = $(MAKE_TMP)\labelForm.tmp rm -f $(labelFormTmp)
### Insert the label name and date into the label-template form. %do GetCurrentDateAndTime sed -i -e 's/%LabelName%/$(labelName)/' \ -e 's/%LabelDate%/$(currentDate) $(currentYear)/' \ -e 's/%UserID%/$(USERNAME)/' \ $(labelFormSrc) >$(labelFormTmp)
### Save it. %echo %echo Creating new label '$(labelName)' ... %if ( %defined( infofile ) && "$(DAILYBLD)" == "1" ) ### Assume this target has been called from the daily build, ### in which case, write the output to the "info" file %echo Label creation output will be written to $(infofile) %echo >>$(infofile) %echo Creating label $(labelName) in Perforce... >>$(infofile) *--p4 label -i <$(labelFormTmp) >>$(infofile) %else *--p4 label -i <$(labelFormTmp) %endif %endif
### Synchronize the label with the current client contents. %echo %echo Synchronizing label '$(labelName)' with client contents ... %if ( %defined( infofile ) && "$(DAILYBLD)" == "1" ) ### Assume this target has been called from the daily build, ### in which case, write the output to the "info" file %echo Labelsync output will be written to $(infofile) %echo >>$(infofile) %echo Synchronizing files to label $(labelName) in Perforce...
$(infofile)
*--p4 labelsync -l $(labelName) >>$(infofile) %else *--p4 labelsync -l $(labelName) %endif
### Lock the label. %do LockLabel LabelID=$(labelName)
#-----------------------------------------------------------------------
------------------------------- # LockLabel # Description: Change the lock attribute in the specified label spec to 'locked.' #-----------------------------------------------------------------------
------------------------------- LockLabel .ALWAYS $(SILENT): ### Prompt for label, if not passed. %if "$(LabelID)" == "" %set labelTmp = $(MAKE_TMP)\label.tmp rm -f $(labelTmp) %echo Enter the label: query 50 >$(labelTmp) %set labelID = $(labelTmp,@) %if "$(labelID)" == "" %abort 1 (LockLabel) Error: A label is required. %endif %endif
### Validate the label. %set labelListTmp = $(MAKE_TMP)\labelList.tmp rm -f $(labelListTmp) %set labelListTmp2 = $(MAKE_TMP)\labelList2.tmp rm -f $(labelListTmp2) *--p4 labels >$(labelListTmp) sed -i -e 's/label \(.*\) [0-9*].*/\1/' $(labelListTmp) >$(labelListTmp2) --grep -i "\<$(labelID)\>" $(labelListTmp2) %if $(STATUS) != 0 ### The label doesn't exist. %abort 1 (LockLabel) Error: The label '$(labelID)' does not exist. %endif
### Temporary files %set labelFormTmp1 = $(MAKE_TMP)\labelForm1.tmp %set labelFormTmp2 = $(MAKE_TMP)\labelForm2.tmp rm -f $(labelFormTmp1) rm -f $(labelFormTmp2)
### Get current label specification, set attribute, and save the label spec. *--p4 label -o $(labelID) >$(labelFormTmp1) %echo %echo Locking label '$(labelID)' ... sed -i -e 's/%LabelName%/$(labelID)/' \ -e 's/unlocked/locked/' \ $(labelFormTmp1) >$(labelFormTmp2) *--p4 label -i <$(labelFormTmp2)
#-----------------------------------------------------------------------
------------------------------- # UnlockLabel # Description: Change the lock attribute in the specified label spec to 'unlocked.' #-----------------------------------------------------------------------
------------------------------- UnlockLabel .ALWAYS $(SILENT): ### Prompt for label, if not passed. %if "$(LabelID)" == "" %set labelTmp = $(MAKE_TMP)\label.tmp rm -f $(labelTmp) %echo Enter the label: query 50 >$(labelTmp) %set labelID = $(labelTmp,@) %if "$(labelID)" == "" %abort 1 (UnlockLabel) Error: A label is required. %endif %endif
### Validate the label. %set labelListTmp = $(MAKE_TMP)\labelList.tmp rm -f $(labelListTmp) %set labelListTmp2 = $(MAKE_TMP)\labelList2.tmp rm -f $(labelListTmp2) *--p4 labels >$(labelListTmp) sed -i -e 's/label \(.*\) [0-9*].*/\1/' $(labelListTmp) >$(labelListTmp2) --grep -i "\<$(labelID)\>" $(labelListTmp2) %if $(STATUS) != 0 ### The label doesn't exist. %abort 1 (UnlockLabel) Error: The label '$(labelID)' does not exist. %endif
### Temporary files %set labelFormTmp1 = $(MAKE_TMP)\labelForm1.tmp %set labelFormTmp2 = $(MAKE_TMP)\labelForm2.tmp rm -f $(labelFormTmp1) rm -f $(labelFormTmp2)
### Get current label specification, set attribute, and save the label spec. *--p4 label -o $(labelID) >$(labelFormTmp1) %echo %echo Unlocking label '$(labelID)' ... sed -i -e 's/%LabelName%/$(labelID)/' \ -e 's/\([ ]\)locked/\1unlocked/' \ $(labelFormTmp1) >$(labelFormTmp2) *--p4 label -i <$(labelFormTmp2) ===========================================================================
------Original Message----- From: charlie at 7thstreet.com [SMTP:charlie at 7thstreet.com] Sent: Wednesday, April 28, 1999 11:27 AM To: perforce-user at perforce.com Subject: Automate Label process
Does anyone know of a way to automate the process of creating a new label and syncing (Replace files in label with client files) to a certain client on a daily basis?




