Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Perforce, interlabel,interchangelist diffs.

Jose
2009-05-18
2013-06-03
  • Jose
    Jose
    2009-05-18

    Hi,
       I have modified my local perforce.pm to make the diffs work for inter label and inter changelist scenarios. You need to give start tag and end tag as the label1/changelist1  and label2/changelist2. Make sure that the diff topic size is high enough in your codestriker.conf.

    See the attached file for the code.

    Regards
    Arun Jose

    Code

    sub getDiff ($$$$$) {
        my ($self, $start_tag, $end_tag, $module_name,
            $stdout_fh, $stderr_fh) = @_;

        # Currently diff retrievals are only supported for a single tag.
        #if ($start_tag ne '' && $end_tag ne '') {
         #   print $stderr_fh, "Diff retrieval cannot be performed with both tags defined.\n";
          #  return $Codestriker::OK;
       # }
    # start tag/end tag can be label1/label2 or changelist1/changelist2.

        if( $start_tag ne $end_tag && $start_tag ne '' && $end_tag ne '' )
        {   
        my $rev1 = "$module_name\@$start_tag";
        my $rev2 = "$module_name\@$end_tag";

            Codestriker::execute_command($stdout_fh, $stderr_fh,$Codestriker::p4,
              '-p', $self->{hostname} . ':' . $self->{port},'-u', $self->{user},'-P', $self->{password}, 'diff2','-du','-u', $rev1, $rev2);
        }
        else # original case with one of the tags.
        {
        my $tag = $start_tag ne '' ? $start_tag : $end_tag;
            Codestriker::execute_command($stdout_fh, $stderr_fh, $Codestriker::p4,'-p', $self->{hostname} . ':' . $self->{port},
    '-u', $self->{user},'-P', $self->{password}, 'describe',
    '-du', $tag);
        }
        return $Codestriker::OK;
    }

    Notes
    -------
    Thanks to Alberto Meza  for his inputs in one of the comments back in Jan 2009. Even though it was a great start for me,it didnt work in my environment. The reason was diff2 was expecting 2 parameters, I splitted the start tag end tag into 2 different strings and passed to the Codestriker::execute_command() and thankfully Codestriker::execute_command()  works with variable number of arguments. Another modification was made to add the '-u' flag for diff2 , without this it was generating diffs even for files with the same contents. Hope this helps to perforce users.

     
    • David Sitsky
      David Sitsky
      2009-06-01

      Hi Arun,

      Thanks for this - its on my list to get it into 1.9.10.

      Cheers,
      David

       
  • David Sitsky
    David Sitsky
    2009-10-07

    I've finally had time to put this into CVS.  I made some slight changes to the code, but it should be fine.  I'll be releasing a beta of 1.9.10 soon - will you be able to test it for the Perforce changes for me?

     
  • Jose
    Jose
    2009-10-07

    Sure David, give me the new beta, I will test it for you on perforce.
    Cheers
    Arun

     
  • David Sitsky
    David Sitsky
    2009-10-17

    Hi Arun,

    I have put up a test release with your code (slightly modified) into 1.9.10 test 1.  Could you download it and let me know if all is well?  Thanks.

    Cheers,
    David

     
  • Jose
    Jose
    2009-10-19

    Hi david, I did try to install it , while I try to install I get the following message
    # ./install.pl
    Checking for  LWP::UserAgent (any)     ok: found v2.033
    Checking for             CGI (v2.56)   ok: found v3.15
    Checking for       Net::SMTP (any)     ok: found v2.29
    Checking for MIME::QuotedPrint (v2.14)   ok: found v3.07
    Checking for             DBI (v1.13)   ok: found v1.607
    Checking for        Template (v2.07)   ok: found v2.20
    Checking for  HTML::Entities (any)     ok: found v1.35
    Checking for      File::Temp (any)     ok: found v0.16
    Checking for        XML::RSS (v1.05)    ok: not found, optional
    Checking for    Encode::Byte (any)     ok: found v2.00
    Checking for Encode::Unicode (any)     ok: found v2.02
    Checking for     DBD::Oracle (any)     ok: found v1.22
    Creating 1 deltas for topic 589705
    Creating delta rows for topic 589705
    DBD::Oracle::st execute failed: ORA-01400: cannot insert NULL into ("TEST"."DELTA"."DELTATEXT") (DBD ERROR: error possibly near <*> indicator at char 159 in 'INSERT INTO delta (topicid, file_sequence, delta_sequence, old_linenumber, new_linenumber, deltatext, description, repmatch) VALUES (:p1, :p2, :p3, :p4, :p5, :<*>p6, :p7, :p8)')  at /var/www/codestriker/codestriker-1.9.10-test1/lib/Codestriker/Model/File.pm line 53, <TEMP_FILE> line 9.
    DBD::Oracle::st execute failed: ORA-01400: cannot insert NULL into ("TEST"."DELTA"."DELTATEXT") (DBD ERROR: error possibly near <*> indicator at char 159 in 'INSERT INTO delta (topicid, file_sequence, delta_sequence, old_linenumber, new_linenumber, deltatext, description, repmatch) VALUES (:p1, :p2, :p3, :p4, :p5, :<*>p6, :p7, :p8)')  at /var/www/codestriker/codestriker-1.9.10-test1/lib/Codestriker/Model/File.pm line 53, <TEMP_FILE> line 9.

    Looks like some issue to deal with the existing tables?

     
  • Jose
    Jose
    2009-10-20

    David,
               I managed to sort that out. Some how the delta_text field in the delta table had a non null constraint. I relaxed that from the admin side. Then the installation went well. Now, there are couple of changes we need to do to make everything work.
        in perforce.pm, please change the code as below , other wise it wont execute the inter label diffs.

    `if ($start_tag ne '' && $end_tag ne '') {
            #print $stderr_fh, "Diff retrieval cannot be performed with both tags defined.\n";
            #return $Codestriker::OK;
        }

    now for the single tag case, please change
    push @args, 'du';
    to
    push @args, '-du';

    after doing these changes, everything works for me. Thanks for fixing the General comments also.

    Regards
    Arun