[p4] Locking existing labels

todd.benham@kodak.com todd.benham at kodak.com
Thu Nov 15 09:41:57 PST 2007


Thanks for the help.

For the record, I ended up with the following 3 lines in a small .bat file
(note that I am in a windows world and not sed savvy). This would lock any
labels containing the string "l_ProductSeriesA". Conveniently enough, you
do not need to be the owner in order to lock labels (but you normally do
to unlock).


rem Create a list of labels
p4 labels | findstr /c:"l_ProductSeriesA" > list.txt

rem preview the potential lines that will change
for /f "tokens=2" %%i in (list.txt) do p4 label -o %%i | sed "/^Options/
s/unlocked/locked/" | findstr /c:"locked"

rem make the changes
for /f "tokens=2" %%i in (list.txt) do p4 label -o %%i | sed "/^Options/
s/unlocked/locked/" | p4 label -I

More notes: 
If you do this directly from a cmd prompt the %%i needs to be just %i.
For some reason, my sed calls needed "" instead of ''.


Todd 


-----Original Message-----
From: David Weintraub [mailto:qazwart at gmail.com] 
Sent: Monday, November 12, 2007 8:33 PM
To: Looney, James B
Cc: Todd D. Benham
Subject: Re: [p4] Locking existing labels


You can always increase the size of the string in the regex to get a more
specific match. I don't have Perforce up and running here at home, so I am
reluctant to give a better example. Something like this:

 p4 label -o foo | sed 's/^\(Options:.*\)unlock\(.*\)$/\1locked\2/' | p4
label -i

Can't verify this particular one, but it should be close. If I was going
to write a "lock label" script, I'd probably would do something like that.

On Nov 12, 2007 6:20 PM, Looney, James B <james.b.looney at lmco.com> wrote:
> David, I'm copying Todd since he's the OP.
>
> That's true, and would solve the problem provided that "unlocked" 
> doesn't appear anywhere else in the label spec such as the 
> description, spec name, or views.
>
>
>
> > -----Original Message-----
> > From: David Weintraub [mailto:qazwart at gmail.com]
> > Sent: Monday, November 12, 2007 3:01 PM
> > To: Looney, James B
> > Subject: Re: [p4] Locking existing labels
> >
> > Hmmm...
> >
> > On Unix, you could do something like this:
> >
> >     $ p4 label -o foo | sed 's/unlock/locked/' | p4 label -i
> >
> > What you need to do is get a list of labels using "p4 labels", and 
> > find the ones you want, pass the name to the command above, and you 
> > should be set.
> >
> > On Nov 12, 2007 1:50 PM, Looney, James B <james.b.looney at lmco.com> 
> > wrote:
> > > If I came across a need of that nature, I'd write a Python script 
> > > assuming I knew which labels (or what pattern to use).
> > >
> > > Use "p4 -G label -o <label name>" to get marshaled data for
> > each of the
> > > labels to change.
> > > modify the "Options" to replace "unlocked" with "locked", then use 
> > > "p4 -G label -i <modified data>".
> > >
> > > Hope that helps.
> > > -James
> > >
> > >
> > >
> > > > -----Original Message-----
> > > > From: perforce-user-bounces at perforce.com
> > > > [mailto:perforce-user-bounces at perforce.com] On Behalf Of 
> > > > todd.benham at kodak.com
> > > > Sent: Monday, November 12, 2007 10:05 AM
> > > > To: perforce-user at perforce.com
> > > > Subject: [p4] Locking existing labels
> > > >
> > > > Is there a good way to locked a whole bunch of similarly named 
> > > > existing labels?
> > > >
> > > > I am in the windows world mostly using p4v.
> > > >
> > > > Something using Python, perl, or window batch would be fine too.
> > > >
> > > > Todd
> > > > _______________________________________________
> > > > 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 
> > > http://maillist.perforce.com/mailman/listinfo/perforce-user
> > >
> >
> >
> >
> > --
> > --
> > David Weintraub
> > qazwart at gmail.com
> >
>



-- 
--
David Weintraub
qazwart at gmail.com



More information about the perforce-user mailing list