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

Jamie.Echlin at barclayscapital.com Jamie.Echlin at barclayscapital.com
Thu Feb 21 07:16:01 PST 2008


It's not 100% reliable and possibly was called a hack because you might
just sync a single file to 1000 say, with the rest of the depot files
being at 999. However the command below will report 1000.

AFAIK if you don't have a label you can't accurately record the state of
the workspace, unless you record the version of every single file.

Cheers, jamie

> -----Original Message-----
> From: perforce-user-bounces at perforce.com 
> [mailto:perforce-user-bounces at perforce.com] On Behalf Of 
> Troughton, Robert
> Sent: 21 February 2008 12:24
> To: Stephen Vance
> Cc: perforce-user at perforce.com
> Subject: Re: [p4] Adding a Changelist # to C++ code...?
> 
> This sounds good. Is there a way to have it automatically 
> generate that header file, though?
> 
> We were previously told by Perforce tech support that the way 
> to get the changelist number was:-
> 
> p4 -c NCE-RTroughton changes -t -m 1 "#have"
> 
> However, we were told at the time that this wouldn't be 100% 
> reliable...
> but it seems good enough for us, anyway. We've never 
> encountered a problem using it...
> 
> My question, really, is how to use this to create a header... 
> I guess I could write a little app which takes the output 
> from this and parses it...? But is there a better way?
> 
> Typical output from the above says:-
> 
> "Change 56552 on 2008/02/21 08:10_37 by JBlack at NCE-JBlack 
> '[xxxproject]
> - [fix] make something work'"
> 
> ...
> 
> 
> -----Original Message-----
> From: Stephen Vance [mailto:steve at vance.com]
> Sent: 21 February 2008 11:32
> To: Troughton, Robert
> Cc: perforce-user at perforce.com
> Subject: Re: [p4] Adding a Changelist # to C++ code...?
> 
> Robert --
> 
> The typical approach to this is to have your build system 
> generate a header file with the information in it.
> 
> I don't understand your comment about the "hack." Changelist 
> numbers are
> 
> unique. As long as you craft your 'p4 changes -m1' command 
> correctly, you will always get the correct answer. I don't 
> understand what you mean
> 
> by "an identical but different changelist."
> 
> Steve
> 
> Troughton, Robert wrote:
> > Does anyone know of a way to integrate the last synced 
> version number 
> > from Perforce into C++ code, such that it can be displayed 
> on screen?
> >
> >  
> >
> > I suspect that this is impossible... but it's worth asking.
> >
> >  
> >
> > Basically, if I sync to changelist X and make some changes, I'd like
> our
> > app to display on screen that I'm running version X. I know that
> there's
> > a commandline "hack" to find out the changelist that I last 
> sync'ed to 
> > (it's a hack because it does a search across the depot so could, 
> > potentially, report an identical but different changelist). However,
> is
> > there a good way to automagically put this changelist 
> number into the 
> > sourcecode?
> >
> >  
> >
> > Has anyone attempted anything similar to this...?
> >
> >  
> >
> > Robert
> >
> > _______________________________________________
> > perforce-user mailing list  -  perforce-user at perforce.com 
> > http://maillist.perforce.com/mailman/listinfo/perforce-user
> >
> >   
> 
> --
> Stephen Vance
> www.vance.com
> 
> _______________________________________________
> perforce-user mailing list  -  perforce-user at perforce.com 
> http://maillist.perforce.com/mailman/listinfo/perforce-user
> 
------------------------------------------------------------------------
For important statutory and regulatory disclosures and more information about Barclays Capital, please visit our web site at http://www.barcap.com.

Internet communications are not secure and therefore the Barclays Group does not accept legal responsibility for the contents of this message.  Although the Barclays Group operates anti-virus programmes, it does not accept responsibility for any damage whatsoever that is caused by viruses being passed.  Any views or opinions presented are solely those of the author and do not necessarily represent those of the Barclays Group.  Replies to this email may be monitored by the Barclays Group for operational or business reasons.

Barclays Capital is the investment banking division of Barclays Bank PLC, a company registered in England (number 1026167) with its registered office at 1 Churchill Place, London, E14 5HP. This email may relate to or be sent from other members of the Barclays Group.
------------------------------------------------------------------------




More information about the perforce-user mailing list