Prepare Git::SVN for extraction into its own file.
This means it should be able to load without git-svn being loaded. * Load Git.pm on its own and all the needed command functions. * It needs to grab at a git-svn lexical $_prefix representing the --prefix option. Provide opt_prefix() for that. This is a refactoring artifact. The prefix should really be passed into Git::SVN->new. * Unqualify unnecessarily fully qualified globals like $Git::SVN::default_repo_id. * Lexically isolate the class just to make sure nothing is leaking out. Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Eric Wong <normalperson@yhbt.net>
Michael G. Schwern committed
Jul 26, 2012 at 16:22 UTC
0f80aa03cf17973cb15eb34d5efedbd5eba70596
1 file changed
+18
-4
git-svn.perl
+18
-4
@@ -89,7 +89,7 @@ BEGIN {
89
foreach (qw/command command_oneline command_noisy command_output_pipe
90
command_input_pipe command_close_pipe
91
command_bidi_pipe command_close_bidi_pipe/) {
92
- for my $package ( qw(Git::SVN::Migration Git::SVN::Log Git::SVN),
92
+ for my $package ( qw(Git::SVN::Migration Git::SVN::Log),
93
__PACKAGE__) {
94
*{"${package}::$_"} = \&{"Git::$_"};
95
}
@@ -109,6 +109,10 @@ my ($_stdin, $_help, $_edit,
109
$_merge, $_strategy, $_preserve_merges, $_dry_run, $_local,
110
$_prefix, $_no_checkout, $_url, $_verbose,
111
$_git_format, $_commit_url, $_tag, $_merge_info, $_interactive);
112
+
113
+# This is a refactoring artifact so Git::SVN can get at this git-svn switch.
114
+sub opt_prefix { return $_prefix || '' }
115
+
116
$Git::SVN::_follow_parent = 1;
117
$Git::SVN::Fetcher::_placeholder_filename = ".gitignore";
118
$_q ||= 0;
@@ -2037,6 +2041,7 @@ sub gc_directory {
2041
}
2042
}
2043
2044
+{
2045
package Git::SVN;
2046
use strict;
2047
use warnings;
@@ -2055,6 +2060,13 @@ use Memoize; # core since 5.8.0, Jul 2002
2060
use Memoize::Storable;
2061
use POSIX qw(:signal_h);
2062
2063
+use Git qw(
2064
+ command
2065
+ command_oneline
2066
+ command_noisy
2067
+ command_output_pipe
2068
+ command_close_pipe
2069
+);
2070
use Git::SVN::Utils qw(fatal can_compress);
2071
2072
my $can_use_yaml;
@@ -4279,12 +4291,13 @@ sub find_rev_after {
4291
sub _new {
4292
my ($class, $repo_id, $ref_id, $path) = @_;
4293
unless (defined $repo_id && length $repo_id) {
4282
- $repo_id = $Git::SVN::default_repo_id;
4294
+ $repo_id = $default_repo_id;
4295
}
4296
unless (defined $ref_id && length $ref_id) {
4285
- $_prefix = '' unless defined($_prefix);
4297
+ # Access the prefix option from the git-svn main program if it's loaded.
4298
+ my $prefix = defined &::opt_prefix ? ::opt_prefix() : "";
4299
$_[2] = $ref_id =
4287
- "refs/remotes/$_prefix$Git::SVN::default_ref_id";
4300
+ "refs/remotes/$prefix$default_ref_id";
4301
}
4302
$_[1] = $repo_id;
4303
my $dir = "$ENV{GIT_DIR}/svn/$ref_id";
@@ -4346,6 +4359,7 @@ sub uri_decode {
4359
sub remove_username {
4360
$_[0] =~ s{^([^:]*://)[^@]+@}{$1};
4361
}
4362
+}
4363
4364
package Git::SVN::Log;
4365
use strict;