[p4] P4::ParseSpec question from p4 perl api

Qazwart qazwart at gmail.com
Sat Aug 11 20:17:55 PDT 2007


The P4Perl doesn't run Perforce commands. Instead, it executes the  
various P4/C++ methods.

I'm wondering if the "form" you're getting is in a format that the P4/ 
Perl module thinks it should be in. It might be having a hard time  
parsing the form. Try simply printing out the form with the following  
trigger:

   use strict;
   use warnings;

   open(FORM, "$ARGV[0]") or
     die qq(Can't open formfile "$ARGV[0]" for reading\n);
   print qq(The form contains ");
   while(my $line = <FORM>) {
     print "$line";
   }
   print qq("\n);

This will surround the form with quotes. That way, you can see if  
there is an extra NL or not.

Then try this:


   use P4;
   use strict;
   use warnings;

   my $clientId = "<your Client Id>";
   my $p4 = new P4;
   $p4->ParseForms();
   $p4->Connect() or die( "Failed to connect to server" );
   my $clientRef = $p4->FetchClient("$clientId");
   die qq(Client "$clientId" not fetched!\n) if $p4->ErrorCount;
   my $client = $p4->FormatClient($clientRef);
   print qq(The client form is "$client"\n);

Again, the form will print with quotes around it. Compare the two,  
and that will show you whether or not you're missing something.

On Aug 10, 2007, at 7:10 AM, <Jamie.Echlin at barclayscapital.com>  
<Jamie.Echlin at barclayscapital.com> wrote:

> Hi,
>
> I am writing a form-out trigger on "client", because I want to default
> new clients to the revertunchanged option (anything other than the
> submit unchanged option really).
>
> Trigger looks like:
> 	ClientOut form-out client "perl \blah\ClientFormOut.pl
> %formfile% %serverport%"
>
> So I open and read the formfile in the trigger, great. Now, instead of
> just do a plain substitution on the file (just in case  
> SubmitOptions is
> the user name or something - I know it's not likely but I have other
> triggers), I want to convert it to a hash. So I call
>
> $p4->ParseSpec("client", $form);
>
> ($form is the string containing the contents of the formfile). However
> this starts infinite recursion because it runs client -o. Maybe I am
> missing something in ParseSpec, according to the docs it should just
> convert a string to a hash, no need to run a perforce command at all?
>
> Cheers, jamie
>
>
>
> ---------------------------------------------------------------------- 
> --
> 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.
> ---------------------------------------------------------------------- 
> --
>
> _______________________________________________
> perforce-user mailing list  -  perforce-user at perforce.com
> http://maillist.perforce.com/mailman/listinfo/perforce-user

David Weintraub
david at weintraub.name
qazwart at gmail.com




More information about the perforce-user mailing list