1

I understand that this question has, in essence, already been asked, but that question did not have an unequivocal answer, so please bear with me.

Background: In my company, we use Perforce submission numbers as part of our versioning. Regardless of whether this is a correct method or not, that is how things are. Currently, many developers do separate submissions for code and documentation: first the code and then the documentation to update the client-facing docs with what the new version numbers should be. I would like to streamline this process.

My thoughts are as follows: create a Perforce trigger (which runs on the server side) which scans the submitted documentation files (such as .txt) for a unique term (such as #####PERFORCE##CHANGELIST##NUMBER###ROFL###LOL###WHATEVER#####) and then replaces it with the value of what the change list would be when submitted. I already know how to determine this value. What I cannot figure out, is how or where to update the files.

I have already determined that using the change-content trigger (whether possible or not), which

"fire[s] after changelist creation and file transfer, but prior to committing the submit to the database",

is the way to go. At this point the files need to exist somewhere on the server. How do I determine the (temporary?) location of these files from within, say, a Python script so that I can update or sed to replace the placeholder value with the intended value? The online documentation for Perforce which I have found so far have not been very explicit on whether this is possible or how the mechanics of a submission at this stage would work.

EDIT

Basically what I am looking for is RCS-like functionality, but without the unsightly special character sequences which accompany it. After more digging, what I am asking is the same as this question. However I believe that this must be possible, because the trigger is running on the server side and the files had already been transferred to the server. They must therefore be accessible by the script.

EXAMPLE

Consider the following snippet from a release notes document:

[#####PERFORCE##CHANGELIST##NUMBER###ROFL###LOL###WHATEVER#####] Added a cool new feature.  Early retirement is in sight.
[52702] Fixed a really annoying bug.  Many lives saved.
[52686] Fixed an annoying bug.

This is what the user submits. I then want the trigger to intercept this file during the submission process (as mentioned, at the change-content stage) and alter it so that what is eventually stored within Perforce looks like this:

[52738] Added a cool new feature.  Early retirement is in sight.
[52702] Fixed a really annoying bug.  Many lives saved.
[52686] Fixed an annoying bug.

Where 52738 is the final change list number of what the user submitted. (As mentioned, I can already determine this number, so please do dwell on this point.) I.e., what the user sees on the Perforce client console is.

Changelist 52733 renamed 52738.
Submitted change 52738.
2
  • This is a question for Stack Overflow.
    – Sven
    Jun 10, 2014 at 20:29
  • @SvW I can re-post the question there, but this is about a Perforce server and scripting happening on it... Jun 10, 2014 at 20:37

3 Answers 3

1

I want to get better clarification on what you are trying to accomplish in case there is another way to do what you want.

Depending on what you are trying to do, you may want to consider shelving ( http://www.perforce.com/perforce/doc.current/manuals/p4guide/chapter.files.html#d0e5537 )

Also, there is an existing Perforce enhancement request I can add your information to, regarding client side triggers to modify files on the client side prior to submit. If it becomes implemented, you will be notified by email.

3
  • Hi @P4Shimada, thank you for responding. I have updated my question and also provided an example of what I am looking for. Jun 11, 2014 at 16:59
  • I would appreciate being added to the enhancement request, thank you. Jun 11, 2014 at 16:59
  • Hi @phantom-99w, You're welcome. Thank you for the updated example. Also, I have added you to the enhancement request for the client side triggers to modify files.
    – P4Shimada
    Jun 17, 2014 at 22:23
0

99w,

I have also added you to an existing enhancement request for Customizable RCS keywords, along with the example you provided.

Short of using a post-command trigger to edit the archive content directly and then update the checksum in the database, there is currently not a way to update the file content with the custom-edited final changelist number.

0

One of the things I learned very early on in programming was to keep out of interrupt level as much as possible, and especially don't do stuff in interrupt that requires resources that can hang the system. I totally get that you want to resolve the internal labeling in sequence, but a better way to do it may be to just set up the edit during the trigger so that a post trigger tool can perform the file modification.

Correct me if I'm looking at this wrong, but there seems a bit of irony, or perhaps recursion, if you are trying to make a file change during the course of submitting a file change. It might be better to have a second change list that is reserved for the log. You always know where that file is, in your local file space. That said, ktext files and $ fields may be able to help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.