Prepare Git::SVN::Log for extraction from git-svn.
* Load Git command functions itself. * Can't access the git-svn switch lexical any more, but its only used by Git::SVN::Log so turn it into a Git::SVN::Log global. * Load Git::SVN as needed. No need to load it always, its only used twice. * Moved a state variable to the routine it's used for. (Drive by refactoring) Signed-off-by: Eric Wong <normalperson@yhbt.net>
Michael G. Schwern committed
Jul 26, 2012 at 17:26 UTC
2c96a6c3f1256d94d5f97fb9e0bdeafb8c0224b4
1 file changed
+11
-4
git-svn.perl
+11
-4
@@ -87,7 +87,7 @@ BEGIN {
87
foreach (qw/command command_oneline command_noisy command_output_pipe
88
command_input_pipe command_close_pipe
89
command_bidi_pipe command_close_bidi_pipe/) {
90
- for my $package ( qw(Git::SVN::Migration Git::SVN::Log),
90
+ for my $package ( qw(Git::SVN::Migration),
91
__PACKAGE__) {
92
*{"${package}::$_"} = \&{"Git::$_"};
93
}
@@ -106,7 +106,7 @@ my ($_stdin, $_help, $_edit,
106
$_version, $_fetch_all, $_no_rebase, $_fetch_parent,
107
$_merge, $_strategy, $_preserve_merges, $_dry_run, $_local,
108
$_prefix, $_no_checkout, $_url, $_verbose,
109
- $_git_format, $_commit_url, $_tag, $_merge_info, $_interactive);
109
+ $_commit_url, $_tag, $_merge_info, $_interactive);
110
111
# This is a refactoring artifact so Git::SVN can get at this git-svn switch.
112
sub opt_prefix { return $_prefix || '' }
@@ -270,7 +270,7 @@ my %cmd = (
270
{ 'url' => \$_url, } ],
271
'blame' => [ \&Git::SVN::Log::cmd_blame,
272
"Show what revision and author last modified each line of a file",
273
- { 'git-format' => \$_git_format } ],
273
+ { 'git-format' => \$Git::SVN::Log::_git_format } ],
274
'reset' => [ \&cmd_reset,
275
"Undo fetches back to the specified SVN revision",
276
{ 'revision|r=s' => \$_revision,
@@ -2043,11 +2043,14 @@ package Git::SVN::Log;
2043
use strict;
2044
use warnings;
2045
use Git::SVN::Utils qw(fatal);
2046
+use Git qw(command command_oneline command_output_pipe command_close_pipe);
2047
use POSIX qw/strftime/;
2048
use constant commit_log_separator => ('-' x 72) . "\n";
2049
use vars qw/$TZ $limit $color $pager $non_recursive $verbose $oneline
2050
%rusers $show_commit $incremental/;
2050
-my $l_fmt;
2051
+
2052
+# Option set in git-svn
2053
+our $_git_format;
2054
2055
sub cmt_showable {
2056
my ($c) = @_;
@@ -2093,6 +2096,8 @@ sub git_svn_log_cmd {
2096
}
2097
2098
my ($url, $rev, $uuid, $gs) = ::working_head_info($head);
2099
+
2100
+ require Git::SVN;
2101
$gs ||= Git::SVN->_new;
2102
my @cmd = (qw/log --abbrev-commit --pretty=raw --default/,
2103
$gs->refname);
@@ -2154,6 +2159,7 @@ sub run_pager {
2159
2160
sub format_svn_date {
2161
my $t = shift || time;
2162
+ require Git::SVN;
2163
my $gmoff = Git::SVN::get_tz($t);
2164
return strftime("%Y-%m-%d %H:%M:%S $gmoff (%a, %d %b %Y)", localtime($t));
2165
}
@@ -2224,6 +2230,7 @@ sub process_commit {
2230
return 1;
2231
}
2232
2233
+my $l_fmt;
2234
sub show_commit {
2235
my $c = shift;
2236
if ($oneline) {