--
=== lib/SVK/Command/Copy.pm ================================================================== --- lib/SVK/Command/Copy.pm (revision 73228) +++ lib/SVK/Command/Copy.pm (local) @@ -52,7 +52,7 @@ use strict; use SVK::Version; our $VERSION = $SVK::VERSION; use base qw( SVK::Command::Mkdir ); -use SVK::Util qw( get_anchor get_prompt abs2rel splitdir is_uri make_path is_path_inside); +use SVK::Util qw( get_anchor abs2rel splitdir is_uri make_path is_path_inside); use SVK::I18N; use SVK::Logger; === lib/SVK/Command.pm ================================================================== --- lib/SVK/Command.pm (revision 73228) +++ lib/SVK/Command.pm (local) @@ -1033,6 +1033,10 @@ ); } else { + if ($ENV{'SVKBATCHMODE'}) { + die(loc("This command needs to be run interactively\n")); + } + $prompt = loc ("Enter a depot path to %1 into (under // if no leading '/'): ", loc($action)); } === lib/SVK/Help/Environment.pod ================================================================== --- lib/SVK/Help/Environment.pod (revision 73228) +++ lib/SVK/Help/Environment.pod (local) @@ -140,6 +140,12 @@ C<svk log> command. The value of this variable can be anything that you can pass to C<svk log>'s C<--output> option. +=item SVKBATCHMODE + +When you set this variable to a true value, SVK should never prompt the user for an +interactive response. + + =item $SVKPGP svk supports signing and verifying changesets using the Gnu Privacy Guard. === lib/SVK/Util.pm ================================================================== --- lib/SVK/Util.pm (revision 73228) +++ lib/SVK/Util.pm (local) @@ -173,6 +173,8 @@ sub get_prompt { { my ($prompt, $pattern) = @_; + return '' if ($ENV{'SVKBATCHMODE'}); + local $| = 1; print $prompt; @@ -266,70 +268,76 @@ =cut sub get_buffer_from_editor { - my ($what, $sep, $content, $file, $anchor, $targets_ref) = @_; + my ( $what, $sep, $content, $file, $anchor, $targets_ref ) = @_; my $fh; - if (defined $content) { - ($fh, $file) = tmpfile ($file, TEXT => 1, UNLINK => 0); - print $fh $content; - close $fh; + if ( defined $content ) { + ( $fh, $file ) = tmpfile( $file, TEXT => 1, UNLINK => 0 ); + print $fh $content; + close $fh; + } else { + open $fh, $file or die $!; + local $/; + $content = <$fh>; + close $fh; } - else { - open $fh, $file or die $!; - local $/; - $content = <$fh>; - close $fh; - } my $time = time; - while (1) { + while (!$ENV{'SVKBATCHMODE'} && 1) { open my $fh, '<', $file or die $!; my $md5 = md5_fh($fh); close $fh; - edit_file ($file); + edit_file($file); open $fh, '<', $file or die $!; - last if ($md5 ne md5_fh($fh)); + last if ( $md5 ne md5_fh($fh) ); close $fh; - my $ans = get_prompt( - loc("%1 not modified: a)bort, e)dit, c)ommit?", ucfirst($what)), - qr/^[aec]/, - ); - last if $ans =~ /^c/; - # XXX: save the file somewhere - unlink ($file), die loc("Aborted.\n") if $ans =~ /^a/; + my $ans = get_prompt( + loc( "%1 not modified: a)bort, e)dit, c)ommit?", ucfirst($what) ), + qr/^[aec]/, + ); + last if $ans =~ /^c/; + + # XXX: save the file somewhere + unlink($file), die loc("Aborted.\n") if $ans =~ /^a/; } open $fh, $file or die $!; local $/; - my @ret = defined $sep ? split (/\n\Q$sep\E\n/, <$fh>, 2) : (<$fh>); + my @ret = defined $sep ? split( /\n\Q$sep\E\n/, <$fh>, 2 ) : (<$fh>); close $fh; unlink $file; die loc("Cannot find separator; aborted.\n") - if defined($sep) and !defined($ret[1]); + if defined($sep) + and !defined( $ret[1] ); return $ret[0] unless wantarray; # Compare targets in commit message - my $old_targets = (split (/\n\Q$sep\E\n/, $content, 2))[1]; - $old_targets =~ s/^\?.*//mg; # remove unversioned files + my $old_targets = ( split( /\n\Q$sep\E\n/, $content, 2 ) )[1]; + $old_targets =~ s/^\?.*//mg; # remove unversioned files - my @new_targets = - map { - s/^\s+//; # proponly change will have leading spacs - [split(/[\s\+]+/, $_, 2)]} - grep {!/^\?/m} # remove unversioned fils - grep {/\S/} - split(/\n+/, $ret[1]); + my @new_targets + = map { + s/^\s+//; # proponly change will have leading spacs + [ split( /[\s\+]+/, $_, 2 ) ] + } + grep { + !/^\?/m + } # remove unversioned fils + grep {/\S/} + split( /\n+/, $ret[1] ); - if ($old_targets ne $ret[1]) { - # Assign new targets - @$targets_ref = map abs2rel($_->[1], $anchor, undef, '/'), @new_targets; + if ( $old_targets ne $ret[1] ) { + + # Assign new targets + @$targets_ref = map abs2rel( $_->[1], $anchor, undef, '/' ), + @new_targets; } - return ($ret[0], [EMAIL PROTECTED]); + return ( $ret[0], [EMAIL PROTECTED] ); } =head3 get_encoding