NodeReaper has asked for the wisdom of the Perl Monks concerning the following question:

This node was taken out by the NodeReaper on Dec 02, 2011 at 09:45 UTC

Replies are listed 'Best First'.
Re: SVN API log_msg help
by mbethke (Hermit) on Dec 02, 2011 at 01:21 UTC

    Just guessing wildly as I don't have a clue what you're trying to do either but there seems to be a typo in line 4, you likely want a dereferencing arrow instead of a minus:

    $self->{'log_msg_callback'} = $self->{'ctx'}->log_msg_baton3(shift);

      Thanks for reply I am Trying to create a SVN API. In which when i commit a file it will call back the log_msg. i am trying to write the log_msg function which need to take massage from user and kept in a tmp file and commit using that message.

      use SVN::Client; use IO:File; use vars qw($fh $filename); my $template = 'filexxxx'; my $target = '/home/XXX/bla/bla'; my $ctx-> new SVN::Client(); $ctx->log_msg(\&log_msg); print " enter path to commit"; my $path =<>; chomp($path); $ctx->commit($path,0); sub log_msg{ my $log_msg=shift; my $messgpath=shift; my $citem = shift; my $pool = shift; $logmsg =&message(); $citem ={ $citem->path($path), $citem->revision('HEAD') } sub message { ($fh,$filename)=temfile($template, DIR => $target or die "error creating $filename :$!"; $fh =new IO::File "+>> $filename " or die " could not open a file :$!" +; if (defined $fh){ my $line =<STDIN>; print $fh $line; } $logmsg = ` cat $filename`; close($fh) return $logmsg; $messgpath ="$pathh/$filename"; } }
Re: SVN API log_msg help
by pemungkah (Priest) on Dec 02, 2011 at 00:40 UTC
    Question 1: What are you trying to do?

    Question 2: What is your input?

    Question 3: What is your expected output?

    And please indent your code. It is hideously hard to read otherwise. Perl::Tidy can help.

    Guessing from your title, you want to do something with SVN logging. It's not clear from your code what that is. (I have written code against the Subversion API, but I'm still not able to tell what you are trying to do.)

      Thanks for reply I am new to perl please help me out in this. I am Trying to create a SVN API. In which when i commit a file it will call back the log_msg. i am trying to write the log_msg function which need to take massage from user and kept in a tmp file and commit using that message. please find the code below when i run this code its giving me an error " unable to find the object svn_client_commit_item3"

      use SVN::Client; use IO:File; use vars qw($fh $filename); my $template = 'filexxxx'; my $target = '/home/XXX/bla/bla'; my $ctx-> new SVN::Client(); $ctx->log_msg(\&log_msg); print " enter path to commit"; my $path =<>; chomp($path); $ctx->commit($path,0); sub log_msg{ my $log_msg=shift; my $messgpath=shift; my $citem = shift; my $pool = shift; $logmsg =&message(); $citem ={ $citem->path($path), $citem->revision('HEAD') } sub message { ($fh,$filename)=temfile($template, DIR => $target or die "error creating $filename :$!"; $fh =new IO::File "+>> $filename " or die " could not open a file :$!" +; if (defined $fh){ my $line =<STDIN>; print $fh $line; } $logmsg = ` cat $filename`; close($fh) return $logmsg; $messgpath ="$pathh/$filename"; } }
        First, I think that 'use strict' would help you immensely. You have two variables, $logmsg and $log_msg in the log_msg routine, and I'm quite certain that is not what you want!

        Second, you are not setting the log message properly. Since, as the documentation says, the first parameter is a reference to a scalar that should get the log message, you should be doing

        ${ $log_msg } = message();
        (Don't put the leading ampersand on a subroutine call; this makes Perl do funny things like ignore prototypes, none of which you care about, but which could bite you at a later date. Just get out of the habit of using & on subroutines unless you're creating references to them.)

        Your code as it stands seems to want to read standard input, write it to a file, and then read that back in again to set the log message. This could be loads simpler - just read it once, write it out, and then take the copy you already have to set the message:

        open my $fh, '>>', $filename or die "Can't open $filename for appe +nd: $!"; my @lines = <STDIN>; print $fh @lines; close $fh; ${ $log_msg } = join("", @lines); return;
        If there was some reason that you might get an error, then you'd return
        return SVN::Error::create($apr_err, $child, $message);
        $apr_err is documented in there somewhere, not sure where though. The default error handler should be sufficient unless you want to do something like trap errors writing to the log via eval and pass back a specific "hey, I can't log the message" error.

        Leave $citem alone; you can do everything you want with just the $log_msg reference. I found all this poking at SVN::Core and SVN::Client - this much should get you considerably further than you are now.