[p4] Adding a Changelist # to C++ code...?

Troughton, Robert rtroughton at midway.com
Tue Feb 26 00:42:00 PST 2008


Thanks for the reply - this sounds like exactly what we need. What do I
do with the code that you pseudo'd, though...? Is there somewhere that I
can compile this such that our server will do this?

Sorry... I've not done much work with Perforce other than using the
commandline tools for various simple scripts...


-----Original Message-----
From: perforce-user-bounces at perforce.com
[mailto:perforce-user-bounces at perforce.com] On Behalf Of Slava Imeshev
Sent: 26 February 2008 07:03
To: perforce-user at perforce.com
Subject: Re: [p4] Adding a Changelist # to C++ code...?

> So then I started to wonder whether it could be done 
> server-side, e.g. with a submit trigger.  At submit time, you 
> know (1) the changelist number, and (2) that you are "cleanly 
> synced".  I have a feeling, though, that it's not possible to 
> edit a file in a trigger and "p4 submit" it.  Or is it?  
> Is there a server side solution to this?

Yes, there is, and it is trivial. This case is handled routinely on the
server side by a build
management system. At the build time the build/release management system
supplies the change list
number that it used to do p4 sync to the build script that in turn
generates a version file from a
template. Using pseudo-code:

class Version {

    int changeListNumber() {
      return "@change.list.number@";

  String version() {
     return "MyProduct V.2.0." + changeListNumber();

Token @change.list.number@ is replaced with the change list number at
the build time. The result
is compiled and packaged. This, by the way, is the only way to assign
the factual build change
list number to the product version.

Hope this helps.


Slava Imeshev
perforce-user mailing list  -  perforce-user at perforce.com

More information about the perforce-user mailing list