Perforce Public Knowledge Base - Using RCS Keywords
Downloads Blog Company Integrations Careers Contact Try Free
Menu Search
Reset Search



Using RCS Keywords

« Go Back



How do I use RCS* keywords in Perforce?
Which RCS keywords are supported?


Files of Perforce type text+k or text+ko can have RCS-style keyword strings inserted in them. All keyword strings are bounded by the $ character. When files of this type are synced to a Perforce client workspace, the keywords strings are replaced with new text strings denoting file properties such as pathname and date.

As of Release 2000.1, Perforce expands the following keywords in text+k (ktext) files:

  • $Id$
  • $Header$
  • $Date$
  • $DateTime$
  • $Change$
  • $File$
  • $Revision$
  • $Author$

Prior to Release 2000.1, Perforce supported only two keywords, $Id$ and $Header$.

When upgrading a pre-2000.1 release server to version 2000.1 or greater, files of type text+k (ktext) are automatically migrated to type text+ko. The text+ko type on the 2000.1+ server is equivalent to the text+k of pre-2000.1 servers.

See the P4 Command Reference section on File Types under Keyword Expansion for more details.


Change file "main.c" into a ktext file using the -t flag in p4 add or p4 edit.

p4 edit -t +k main.c
//depot/test/main.c#9 - opened for edit

The file "main.c" is changed to Perforce type text+k. This file contains all of the available RCS keywords, entered one per line. Using a Perforce version 2000.1 (or later) Server and Client, the keywords expand as follows:

"main.c" file before submission to server:


Submitting "main.c"

p4 submit main.c

Checking that "main.c" is ktext

p4 files main.c
//depot/test/main.c#10 - edit change 1745 (ktext)

"main.c" file after sync and refresh in client workspace:

$Id: //depot/test/main.c#10 $
$Header: //depot/test/main.c#10 $
$Date: 2006/06/21 $
$DateTime: 2006/06/21 17:42:19 $
$Change: 1745 $
$File: //depot/test/main.c $
$Revision: #10 $
$Author: michael $

The process is the same for enabling RCS keyword expansion in a file that is already open for edit, but you use the p4 reopen command instead of p4 add or p4 edit. For example:

p4 reopen -t +k main.c

* RCS is an acronym for Revision Control System, a file versioning system authored by Walter F. Tichy in the early 1980s. RCS is included with most Unix/GNU/Linux distributions. Perforce does not implement the full range of keywords present in RCS. Perforce and RCS keywords of the same name might expand differently.

Related Links



Was this article helpful?



Please tell us how we can make this article more useful.

Characters Remaining: 255