Finding latest Perforce changelist?


I need to know what the most recent Perforce changelist is when I do abuild, and I’m having trouble figuring out how to get it. To do so froma command line, I’d do ‘p4 changes -m1 -s submitted //depot/…’, whichwould give me something like:

Change 34448 on 2006/09/12 by terry@WALLY ‘BUGZID: 5570 - fix for improper’

I can do that with the ‘Perforce Generic’ action, and log theoutput to a variable, but how do I extract the number from the variableand put it in another (or the same) variable? I’d expect to be able tosomehow use “Find String” to do it, but I don’t see how to save thefound string into a variable.

Or is there a better way?

Thanks,

Keith Hearn
Build/Release Engineer
Devicescape Software, Inc.


Well, I found a way to do it. I did a ‘Perforce Generic’ of the’p4 changes’ command and had the output logged to the variableCHANGE_OUT. Then I did a ‘Text Find’ in CHANGE_OUT, looking a theregular expression ’ [0-9]+ ’ (note that there are spaces before the [and after the +). Then, while keeping the ‘Text Find’ selected, Iwent to the 'Script Editor" tab and the ‘OnFindText’ subtab and madeline 2 of the script be ‘CHANGELIST=FoundText’, which set my%CHANGELIST% variable to the found text.

This does have the drawback of having the extra spaces around thenumber in the variable. I supposed I could do it in two stages, firstlooking for 'Change [0-9]+ ', and saving that to a temp variable, thenlook through that one for ‘[0-9]+’ (no spaces), to get just the number.It gets rather cumbersome, though.

Is there a better way to do this that I’m not seeing?

Thanks,

Keith

I started to test this too, currently I’m using regular expression \s\d+\s although I’m not expert in this, it works fine.
For now I just log them, in the OnFind script I put action.SendLogMessage("Found " + Trim(FoundText) + " at " + CStr(Offset))

Btw, how do you decide how many changes back you are retrieving?


Also how do you extract it later? to a file? release notes? I’m asking to get some general ideas…

Thanks,
NirS

Keith,

We’re going to rework the Text Find action in a future version so that you can do subexpression matching, which is what you need. In the meantime, you can use VBScripts Trim() function to trim the extra spaces from the ChangeList variable.

- Angus

You can use the following line to extract the change number. Just change the echo statement to set/write the variable to wherever you like.

for /f “tokens=3” %i in (‘p4 -ztag changes -m1 -s submitted //… ^|findstr change’) do echo %i

Please note the ^ which escapes the pipe, and the -ztag option which makes p4 output parseable data.

/axl

Disclaimer: I only tried this from the cmdline, not from FB.