开发者

Is it possible to use RCS Revision keyword for a depot path?

开发者 https://www.devze.com 2023-04-12 00:34 出处:网络
I\'ve managed to use the $Revision$ RCS keyword in Perforce: when I update my file //depot/dev_projects/main/src/include/version.h it will update my define in the file, nicely:

I've managed to use the $Revision$ RCS keyword in Perforce: when I update my file //depot/dev_projects/main/src/include/version.h it will update my define in the file, nicely:

#define VCS_VERSION "$Revision: #4 $"

That includes the revision for the version.h file.

What I really need is to embed the revision for 开发者_StackOverflowthe folder of my project //depot/dev_projects/main/src/ to the version.h file. So if someone submits a file for example to //depot/dev_projects/main/doc/readme.txt, I would like to see #define VCS_REVISION "$Revision: #5 $" in version.h after I gets the latest revision from depot.

Is there a way to do that?


You have two cases to worry about: exiting files and new files. For existing files (and I'm going to assume you are talking about c/cpp files), you can simply 'p4 reopen' the files with the filetype 'text+k' and then submit those files:

p4 reopen -t text+k //groovy_project/src/....cpp

This would reopen all of the .cpp files in the //groovy_project/src location and make them 'text+k' (the +k means RCS keyword expansion, but I guess you know that since you have keyword expansion working).

For new files, you should use the 'p4 typemap' command. 'p4 typemap' will bring up the typemap in your editor. This form contains a mapping of files to filetypes for new files added to the depot. These are the default filetypes that new files will receive (unless a new file added explicitly uses a different filetype when the file is added). For instance, if you have

TypeMap:
       text+k //groovy_project/src/....cpp

in your typemap, all new .cpp files in the //groovy_project/src folder will get the text+k filetype, allowing for keyword expansion.

Note, if you explicitly give a new file a different type than what is found in the typemap, the explicitly specified type is used. Say you had the typemap above. The command:

p4 add -t text ~/projects/groovy_project/src/newfile.cpp

this file would get added to the depot as text, and not text+k.

I hope that this information helps.

EDIT:

After reading the edits to your original question, the short answer is no, you cannot add a revision for a folder. The slightly longer answer is that Perforce doesn't really know about folders/directories. It just knows about files (and therefore the path to the file). Directories are not really individual objects in the database in a way that would make what you want work.


I think you want the $File$ keyword:

http://kb.perforce.com/article/54/using-rcs-keywords

0

精彩评论

暂无评论...
验证码 换一张
取 消