git-svn: simplify the handling of fatal errors
* git-svn.perl (&fatal): Append the newline at the end of the error message. Adjust all callers. Signed-off-by: Benoit Sigoure <tsuna@lrde.epita.fr> Acked-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Benoit Sigoure committed
Oct 16, 2007 at 16:36 UTC
207f1a75e7e4d14286aeed107af7c56dc811797b
1 file changed
+21
-21
git-svn.perl
+21
-21
@@ -24,12 +24,12 @@ $Git::SVN::Log::TZ = $ENV{TZ};
24
$ENV{TZ} = 'UTC';
25
$| = 1; # unbuffer STDOUT
26
27
-sub fatal (@) { print STDERR @_; exit 1 }
27
+sub fatal (@) { print STDERR "@_\n"; exit 1 }
28
require SVN::Core; # use()-ing this causes segfaults for me... *shrug*
29
require SVN::Ra;
30
require SVN::Delta;
31
if ($SVN::Core::VERSION lt '1.1.0') {
32
- fatal "Need SVN::Core 1.1.0 or better (got $SVN::Core::VERSION)\n";
32
+ fatal "Need SVN::Core 1.1.0 or better (got $SVN::Core::VERSION)";
33
}
34
push @Git::SVN::Ra::ISA, 'SVN::Ra';
35
push @SVN::Git::Editor::ISA, 'SVN::Delta::Editor';
@@ -372,7 +372,7 @@ sub cmd_set_tree {
372
} elsif (scalar @tmp > 1) {
373
push @revs, reverse(command('rev-list',@tmp));
374
} else {
375
- fatal "Failed to rev-parse $c\n";
375
+ fatal "Failed to rev-parse $c";
376
}
377
}
378
my $gs = Git::SVN->new;
@@ -382,7 +382,7 @@ sub cmd_set_tree {
382
fatal "There are new revisions that were fetched ",
383
"and need to be merged (or acknowledged) ",
384
"before committing.\nlast rev: $r_last\n",
385
- " current: $gs->{last_rev}\n";
385
+ " current: $gs->{last_rev}";
386
}
387
$gs->set_tree($_) foreach @revs;
388
print "Done committing ",scalar @revs," revisions to SVN\n";
@@ -411,7 +411,7 @@ sub cmd_dcommit {
411
(undef, $last_rev, undef) = cmt_metadata("$d~1");
412
unless (defined $last_rev) {
413
fatal "Unable to extract revision information ",
414
- "from commit $d~1\n";
414
+ "from commit $d~1";
415
}
416
}
417
if ($_dry_run) {
@@ -524,7 +524,7 @@ sub cmd_create_ignore {
524
my $ignore = '.' . $path . '.gitignore';
525
my $s = $props->{'svn:ignore'} or return;
526
open(GITIGNORE, '>', $ignore)
527
- or fatal("Failed to open `$ignore' for writing: $!\n");
527
+ or fatal("Failed to open `$ignore' for writing: $!");
528
$s =~ s/[\r\n]+/\n/g;
529
chomp $s;
530
# Prefix all patterns so that the ignore doesn't apply
@@ -532,7 +532,7 @@ sub cmd_create_ignore {
532
$s =~ s#^#/#gm;
533
print GITIGNORE "$s\n";
534
close(GITIGNORE)
535
- or fatal("Failed to close `$ignore': $!\n");
535
+ or fatal("Failed to close `$ignore': $!");
536
command_noisy('add', $ignore);
537
});
538
}
@@ -548,7 +548,7 @@ sub get_svnprops {
548
# prefix THE PATH by the sub-directory from which the user
549
# invoked us.
550
$path = $cmd_dir_prefix . $path;
551
- fatal("No such file or directory: $path\n") unless -e $path;
551
+ fatal("No such file or directory: $path") unless -e $path;
552
my $is_dir = -d $path ? 1 : 0;
553
$path = $gs->{path} . '/' . $path;
554
@@ -581,7 +581,7 @@ sub cmd_propget {
581
usage(1) if not defined $prop;
582
my $props = get_svnprops($path);
583
if (not defined $props->{$prop}) {
584
- fatal("`$path' does not have a `$prop' SVN property.\n");
584
+ fatal("`$path' does not have a `$prop' SVN property.");
585
}
586
print $props->{$prop} . "\n";
587
}
@@ -645,7 +645,7 @@ sub cmd_multi_fetch {
645
sub cmd_commit_diff {
646
my ($ta, $tb, $url) = @_;
647
my $usage = "Usage: $0 commit-diff -r<revision> ".
648
- "<tree-ish> <tree-ish> [<URL>]\n";
648
+ "<tree-ish> <tree-ish> [<URL>]";
649
fatal($usage) if (!defined $ta || !defined $tb);
650
my $svn_path;
651
if (!defined $url) {
@@ -663,7 +663,7 @@ sub cmd_commit_diff {
663
if (defined $_message && defined $_file) {
664
fatal("Both --message/-m and --file/-F specified ",
665
"for the commit message.\n",
666
- "I have no idea what you mean\n");
666
+ "I have no idea what you mean");
667
}
668
if (defined $_file) {
669
$_message = file_to_s($_file);
@@ -726,7 +726,7 @@ sub complete_svn_url {
726
if ($path !~ m#^[a-z\+]+://#) {
727
if (!defined $url || $url !~ m#^[a-z\+]+://#) {
728
fatal("E: '$path' is not a complete URL ",
729
- "and a separate URL is not specified\n");
729
+ "and a separate URL is not specified");
730
}
731
return ($url, $path);
732
}
@@ -747,7 +747,7 @@ sub complete_url_ls_init {
747
$repo_path =~ s#^/+##;
748
unless ($ra) {
749
fatal("E: '$repo_path' is not a complete URL ",
750
- "and a separate URL is not specified\n");
750
+ "and a separate URL is not specified");
751
}
752
}
753
my $url = $ra->{url};
@@ -1753,7 +1753,7 @@ sub assert_index_clean {
1753
$x = command_oneline('write-tree');
1754
if ($y ne $x) {
1755
::fatal "trees ($treeish) $y != $x\n",
1756
- "Something is seriously wrong...\n";
1756
+ "Something is seriously wrong...";
1757
}
1758
});
1759
}
@@ -2179,7 +2179,7 @@ sub set_tree {
2179
my ($self, $tree) = (shift, shift);
2180
my $log_entry = ::get_commit_entry($tree);
2181
unless ($self->{last_rev}) {
2182
- fatal("Must have an existing revision to commit\n");
2182
+ fatal("Must have an existing revision to commit");
2183
}
2184
my %ed_opts = ( r => $self->{last_rev},
2185
log => $log_entry->{log},
@@ -3128,7 +3128,7 @@ sub apply_diff {
3128
if (defined $o{$f}) {
3129
$self->$f($m);
3130
} else {
3131
- fatal("Invalid change type: $f\n");
3131
+ fatal("Invalid change type: $f");
3132
}
3133
}
3134
$self->rmdirs if $_rmdir;
@@ -3759,15 +3759,15 @@ sub config_pager {
3759
sub run_pager {
3760
return unless -t *STDOUT && defined $pager;
3761
pipe my $rfd, my $wfd or return;
3762
- defined(my $pid = fork) or ::fatal "Can't fork: $!\n";
3762
+ defined(my $pid = fork) or ::fatal "Can't fork: $!";
3763
if (!$pid) {
3764
open STDOUT, '>&', $wfd or
3765
- ::fatal "Can't redirect to stdout: $!\n";
3765
+ ::fatal "Can't redirect to stdout: $!";
3766
return;
3767
}
3768
- open STDIN, '<&', $rfd or ::fatal "Can't redirect stdin: $!\n";
3768
+ open STDIN, '<&', $rfd or ::fatal "Can't redirect stdin: $!";
3769
$ENV{LESS} ||= 'FRSX';
3770
- exec $pager or ::fatal "Can't run pager: $! ($pager)\n";
3770
+ exec $pager or ::fatal "Can't run pager: $! ($pager)";
3771
}
3772
3773
sub tz_to_s_offset {
@@ -3903,7 +3903,7 @@ sub cmd_show_log {
3903
$r_min = $r_max = $::_revision;
3904
} else {
3905
::fatal "-r$::_revision is not supported, use ",
3906
- "standard \'git log\' arguments instead\n";
3906
+ "standard 'git log' arguments instead";
3907
}
3908
}
3909