提交之前使用Perforce触发器更新文件 [英] Updating files with a Perforce trigger before submit
问题描述
我知道,这个问题从本质上已经已被问到,但该问题没有明确的答案,因此请耐心等待.
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.
背景:在我的公司中,我们使用Perforce提交编号作为版本控制的一部分.不管这是否是正确的方法,事情都是这样.当前,许多开发人员会分别提交代码和文档:首先是代码,然后是文档,以使用新的版本号更新面向客户的文档.我想简化此过程.
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.
我的想法如下:创建一个Perforce触发器(在服务器端运行),该触发器扫描提交的文档文件(例如 .txt
)中的唯一术语(例如#### PERFORCE ## CHANGELIST ## NUMBER ### ROFL ### LOL ### WHATEVER #####
),然后将其替换为提交时更改列表的值.我已经知道如何确定该值.我不知道要如何更新文件或在何处更新文件.
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.
我已经确定使用 change-content
触发器(无论是否可行)
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",
是必经之路.此时,文件需要在服务器上的某处存在.我如何从一个Python脚本中确定这些文件的(临时位置),以便我可以更新或
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.
基本上,我要寻找的是类似RCS的功能,但是没有伴随它的难看的特殊字符序列.经过进一步的挖掘,我要问的是与这个问题一个>.但是我相信这是有可能的,因为触发器在服务器端上运行,并且文件已被传输到服务器.因此,它们必须可以通过脚本访问.
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.
请考虑发行说明文档中的以下代码段:
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.
这是用户提交的.然后,我希望触发器在提交过程中拦截该文件(如前所述,在 change-content
阶段)并对其进行更改,以使最终存储在Perforce中的内容如下所示:
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.
其中 52738 是用户提交的最终更改列表号.(如前所述,我已经可以确定这个数字了,所以请对此进行详细说明.)即用户在Perforce客户端控制台上看到的是
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.
推荐答案
-
您是否要替换在不同的客户端工作区(和不同的用户)上编辑的未决变更列表文件的内容?
Are you trying to replace the content of pending changelist files that were edited on a different client workspace (and different user)?
您要在文档文件中替换什么类型的信息?例如,是日期,用户名,例如RCS关键字扩展? http://www.perforce.com/perforce/doc.current/manuals/p4guide/appendix.filetypes.html#DB5-18921
What type of information are you trying to replace in the documentation files? For example, is it a date, username like with RCS keyword expansion? http://www.perforce.com/perforce/doc.current/manuals/p4guide/appendix.filetypes.html#DB5-18921
我想更好地阐明您要完成的工作,以防有另一种方法可以做您想做的事情.
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 )
还有一个现有的Perforce增强请求,我可以将您的信息添加到其中,有关客户端触发器的信息,请先在客户端上修改文件,然后再提交.如果实施,则会通过电子邮件通知您.
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.
这篇关于提交之前使用Perforce触发器更新文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!