[p4] How to get newest label matching a regexp?
Jeff A. Bowles
jab at pobox.com
Thu Mar 27 08:20:37 PDT 2008
Mr. Ivey's got the best suggestion I know.
It's helpful to remember that the tagged output ("p4 -Ztag labels") has a
blank line between each of the labels. (Assuming that there are no newlines
in descriptions of the labels, that means the blank line can be seen as a
separator between data.)
This directly plays into Perl's processing of paragraphs in input text; set
"$/" to an empty string and parse away.
ps. If you're a Python or Ruby enthusiast, there are a lot of options that
come along for the ride with "p4 -G" and "p4 -R". (The other option - p4perl
/ p4ruby / p4python - is even more attractive.)
pps. His trick works for finding client workspaces based on time ("find me
the old workspaces") also.
On Wed, Mar 26, 2008 at 10:56 AM, Ivey, William <william_ivey at bmc.com>
> It's an "undocumented" feature that's documented in the
> "p4 help undoc" text. It's been around for a long time.
> -----Original Message-----
> From: Karr, David [mailto:david.karr at wamu.net]
> Sent: Wednesday, March 26, 2008 11:52 AM
> To: Ivey, William; perforce-user at perforce.com
> Subject: RE: [p4] How to get newest label matching a regexp?
> I don't appear to find a "-ztag" command-line option. Is that only
> available in 2007.3?
> > -----Original Message-----
> > From: Ivey, William [mailto:william_ivey at bmc.com]
> > Sent: Wednesday, March 26, 2008 9:22 AM
> > To: Karr, David; perforce-user at perforce.com
> > Subject: RE: [p4] How to get newest label matching a regexp?
> > If you use the -ztag option:
> > p4 -ztag labels
> > You'll get timestamps down the the second in easy to compare
> > epoch-seconds format:
> > ... Update 1156897852
> > ... Access 1156897851
> > You will have to process multiple lines of output per label.
> > Each line is nicely prefixed, though, so it's not too bad.
> > -Wm
> > -----Original Message-----
> > From: perforce-user-bounces at perforce.com
> > [mailto:perforce-user-bounces at perforce.com] On Behalf Of Karr, David
> > Sent: Wednesday, March 26, 2008 10:44 AM
> > To: perforce-user at perforce.com
> > Subject: [p4] How to get newest label matching a regexp?
> > I need to write a procedure to get the newest label that
> > matches a regular expression. I can see how to do this
> > conceptually, but there's a minor problem.
> > In P4Win, the list of labels lists the label creation time
> > down to the second. However, running "p4 labels" from the
> > command line only gets this down to the day. If two labels
> > were created on the same day, I don't know which one is newer.
> > Is the order of the output of "p4 labels" significant? Are
> > they in creation order, or in alphabetical order?
> > _______________________________________________
> > perforce-user mailing list - perforce-user at perforce.com
> > http://maillist.perforce.com/mailman/listinfo/perforce-user
> perforce-user mailing list - perforce-user at perforce.com
Jeff Bowles - jeff.a.bowles at gmail.com
More information about the perforce-user