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

Slava Imeshev imeshev at yahoo.com
Mon Feb 25 23:02:41 PST 2008


> 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.

Regards,

Slava Imeshev
www.viewtier.com



More information about the perforce-user mailing list