From: Matthias Urlichs Date: Mon, 10 Oct 2005 16:45:00 +0000 (+0200) Subject: svn import: Add a loop limit option X-Git-Tag: v0.99.9~112^2~9 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3ef378a67b5b39441837700ab4dfb800eb443c5a;p=git.git svn import: Add a loop limit option The svn library has a serious memory leak. Added a new option (-l NUM) which causes git-svnimport to exit cleanly after fetching that many changes, in order to . Signed-Off-By: Matthias Urlichs --- diff --git a/Documentation/git-svnimport.txt b/Documentation/git-svnimport.txt index a144c6c31..047f8f334 100644 --- a/Documentation/git-svnimport.txt +++ b/Documentation/git-svnimport.txt @@ -10,7 +10,7 @@ git-svnimport - Import a SVN repository into git SYNOPSIS -------- 'git-svnimport' [ -o ] [ -h ] [ -v ] - [ -C ] [ -i ] [ -u ] + [ -C ] [ -i ] [ -u ] [-l limit_nr_changes] [ -b branch_subdir ] [ -t trunk_subdir ] [ -T tag_subdir ] [ -s start_chg ] [ -m ] [ -M regex ] [ ] @@ -70,6 +70,15 @@ When importing incementally, you might need to edit the .git/svn2git file. regex. It can be used with -m to also see the default regexes. You must escape forward slashes. +-l :: + Limit the number of SVN changesets we pull before quitting. + This option is necessary because the SVN library has serious memory + leaks; the recommended value for nontrivial imports is 100. + + git-svnimport will still exit with a zero exit code. You can check + the size of the file ".git/svn2git" to determine whether to call + the importer again. + -v:: Verbosity: let 'svnimport' report what it is doing. diff --git a/git-svnimport.perl b/git-svnimport.perl index 00f563dae..b880297e0 100755 --- a/git-svnimport.perl +++ b/git-svnimport.perl @@ -31,19 +31,19 @@ die "Need CVN:COre 1.2.1 or better" if $SVN::Core::VERSION lt "1.2.1"; $SIG{'PIPE'}="IGNORE"; $ENV{'TZ'}="UTC"; -our($opt_h,$opt_o,$opt_v,$opt_u,$opt_C,$opt_i,$opt_m,$opt_M,$opt_t,$opt_T,$opt_b,$opt_s); +our($opt_h,$opt_o,$opt_v,$opt_u,$opt_C,$opt_i,$opt_m,$opt_M,$opt_t,$opt_T,$opt_b,$opt_s,$opt_l); sub usage() { print STDERR <{'maxrev'}) { $svn->{'svn'}->get_log("/",$current_rev,$current_rev,$current_rev,1,1,\&_commit_all,""); commit_all(); + if($opt_l and not --$opt_l) { + print STDERR "Exiting due to a memory leak. Repeat, please.\n"; + last; + } } @@ -637,7 +642,7 @@ if (defined $orig_git_index) { # Now switch back to the branch we were in before all of this happened if($orig_branch) { - print "DONE\n" if $opt_v; + print "DONE\n" if $opt_v and (not defined $opt_l or $opt_l > 0); system("cp","$git_dir/refs/heads/$opt_o","$git_dir/refs/heads/master") if $forward_master; unless ($opt_i) { @@ -646,7 +651,7 @@ if($orig_branch) { } } else { $orig_branch = "master"; - print "DONE; creating $orig_branch branch\n" if $opt_v; + print "DONE; creating $orig_branch branch\n" if $opt_v and (not defined $opt_l or $opt_l > 0); system("cp","$git_dir/refs/heads/$opt_o","$git_dir/refs/heads/master") unless -f "$git_dir/refs/heads/master"; unlink("$git_dir/HEAD");