git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/8] Prepare Git::SVN::Migration for extraction from git-svn.

From
Michael G. Schwern <schwern@pobox.com>
Date
Jul 27, 2012, 00:26 UTC
Message-ID
<1343348767-86446-4-git-send-email-schwern@pobox.com>
In-Reply-To
<1343348767-86446-1-git-send-email-schwern@pobox.com>
From: "Michael G. Schwern" <schwern@pobox.com>
* Load Git command functions on its own.
* Load Git::SVN modules on its own.
Drive by refactorings...
* Use our() instead of use vars.
* Eliminate the auto loading of Git functions.
---
 git-svn.perl | 36 ++++++++++++++++++++++++------------
 1 file changed, 24 insertions(+), 12 deletions(-)
diff --git a/git-svn.perl b/git-svn.perl
index 7c8da44..db60984 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -14,6 +14,18 @@ use Git::SVN;
 use Git::SVN::Log;
 use Git::SVN::Utils qw(fatal can_compress);
 
+use Git qw(
+    git_cmd_try
+    command
+    command_oneline
+    command_noisy
+    command_output_pipe
+    command_close_pipe
+    command_bidi_pipe
+    command_close_bidi_pipe
+);
+
+
 # From which subdir have we been invoked?
 my $cmd_dir_prefix = eval {
 	command_oneline([qw/rev-parse --show-prefix/], STDERR => 0)
@@ -75,7 +87,6 @@ use File::Spec;
 use File::Find;
 use Getopt::Long qw/:config gnu_getopt no_ignore_case auto_abbrev/;
 use IPC::Open3;
-use Git;
 use Git::SVN::Editor qw//;
 use Git::SVN::Fetcher qw//;
 use Git::SVN::Ra qw//;
@@ -83,16 +94,6 @@ use Git::SVN::Prompt qw//;
 use Memoize;  # core since 5.8.0, Jul 2002
 
 BEGIN {
-	# import functions from Git into our packages, en masse
-	no strict 'refs';
-	foreach (qw/command command_oneline command_noisy command_output_pipe
-	            command_input_pipe command_close_pipe
-	            command_bidi_pipe command_close_bidi_pipe/) {
-		for my $package ( qw(Git::SVN::Migration),
-			__PACKAGE__) {
-			*{"${package}::$_"} = \&{"Git::$_"};
-		}
-	}
 	Memoize::memoize 'Git::config';
 	Memoize::memoize 'Git::config_bool';
 }
@@ -2080,7 +2081,14 @@ use warnings;
 use Carp qw/croak/;
 use File::Path qw/mkpath/;
 use File::Basename qw/dirname basename/;
-use vars qw/$_minimize/;
+
+our $_minimize;
+use Git qw(
+	command
+	command_noisy
+	command_output_pipe
+	command_close_pipe
+);
 
 sub migrate_from_v0 {
 	my $git_dir = $ENV{GIT_DIR};
@@ -2189,6 +2197,7 @@ sub migrate_from_v2 {
 	read_old_urls(\%l_map, '', "$ENV{GIT_DIR}/svn");
 	my $migrated = 0;
 
+	require Git::SVN;
 	foreach my $ref_id (sort keys %l_map) {
 		eval { Git::SVN->init($l_map{$ref_id}, '', undef, $ref_id) };
 		if ($@) {
@@ -2200,6 +2209,9 @@ sub migrate_from_v2 {
 }
 
 sub minimize_connections {
+	require Git::SVN;
+	require Git::SVN::Ra;
+
 	my $r = Git::SVN::read_all_remotes();
 	my $new_urls = {};
 	my $root_repos = {};
-- 
1.7.11.1
Previous: Michael G. SchwernNext: Michael G. Schwern
Message 4 of 16 in “Extract remaining classes from git-svn”
  1. Michael G. SchwernJul 27, 2012
  2. 1/8 Prepare Git::SVN::Log for extraction from git-svn.Michael G. Schwern, Jul 27, 2012
  3. 2/8 Extract Git::SVN::Log from git-svn.Michael G. Schwern, Jul 27, 2012
  4. 3/8 Prepare Git::SVN::Migration for extraction from git-svn.Michael G. Schwern, Jul 27, 2012
  5. 4/8 Extract Git::SVN::Migration from git-svn.Michael G. Schwern, Jul 27, 2012
  6. 5/8 Load all the modules in one place and before running code.Michael G. Schwern, Jul 27, 2012
  7. 6/8 Move Git::IndexInfo into its own file.Michael G. Schwern, Jul 27, 2012
  8. 7/8 Extract Git::SVN::GlobSpec from git-svn.Michael G. Schwern, Jul 27, 2012
  9. 8/8 Fix indents to match style.Michael G. Schwern, Jul 27, 2012
  10. Michael G SchwernJul 27, 2012
  11. Erik Faye-LundJul 27, 2012
  12. Michael G SchwernJul 27, 2012
  13. Eric WongJul 28, 2012
  14. Junio C HamanoJul 28, 2012
  15. Eric WongJul 28, 2012
  16. Junio C HamanoJul 28, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.