All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH 4/5] git-svn: fix bottleneck in stash_placeholder_list()
@ 2013-05-01  5:09 Ilya Basin
  2013-05-01  8:31 ` Re[2]: " Ilya Basin
  0 siblings, 1 reply; 19+ messages in thread
From: Ilya Basin @ 2013-05-01  5:09 UTC (permalink / raw)
  To: Git mailing list; +Cc: Ray Chen, Eric Wong

IB> +       return undef if (!keys $self->{_save_ph});
Correct is: return undef if (!keys %{$self->{_save_ph}});

In my repo the placeholders change too often (in 1/4 commits). I'm
thinking of using:
'git config --unset "svn-remote.$repo_id.added-placeholder" path_regex'
instead of full rewrite.

^ permalink raw reply	[flat|nested] 19+ messages in thread
* [PATCH 4/5] git-svn: fix bottleneck in stash_placeholder_list()
@ 2013-04-30 17:37 Ilya Basin
  0 siblings, 0 replies; 19+ messages in thread
From: Ilya Basin @ 2013-04-30 17:37 UTC (permalink / raw)
  To: Git mailing list; +Cc: Ray Chen, Eric Wong

.git/config is written on each commit. It's slow
---
 perl/Git/SVN/Fetcher.pm | 77 +++++++++++++++++++++++++++++++------------------
 1 file changed, 49 insertions(+), 28 deletions(-)

diff --git a/perl/Git/SVN/Fetcher.pm b/perl/Git/SVN/Fetcher.pm
index e658889..a5ad4cd 100644
--- a/perl/Git/SVN/Fetcher.pm
+++ b/perl/Git/SVN/Fetcher.pm
@@ -1,5 +1,6 @@
 package Git::SVN::Fetcher;
 use vars qw/@ISA $_ignore_regex $_preserve_empty_dirs $_placeholder_filename
+            $_package_inited
             @deleted_gpath %added_placeholder $repo_id/;
 use strict;
 use warnings;
@@ -26,32 +27,9 @@ sub new {
 		                  _mark_empty_symlinks($git_svn, $switch_path);
 	}
 
-	# some options are read globally, but can be overridden locally
-	# per [svn-remote "..."] section.  Command-line options will *NOT*
-	# override options set in an [svn-remote "..."] section
-	$repo_id = $git_svn->{repo_id};
-	my $k = "svn-remote.$repo_id.ignore-paths";
-	my $v = eval { command_oneline('config', '--get', $k) };
-	$self->{ignore_regex} = $v;
-
-	$k = "svn-remote.$repo_id.preserve-empty-dirs";
-	$v = eval { command_oneline('config', '--get', '--bool', $k) };
-	if ($v && $v eq 'true') {
-		$_preserve_empty_dirs = 1;
-		$k = "svn-remote.$repo_id.placeholder-filename";
-		$v = eval { command_oneline('config', '--get', $k) };
-		$_placeholder_filename = $v;
-	}
-
-	# Load the list of placeholder files added during previous invocations.
-	$k = "svn-remote.$repo_id.added-placeholder";
-	$v = eval { command_oneline('config', '--get-all', $k) };
-	if ($_preserve_empty_dirs && $v) {
-		# command() prints errors to stderr, so we only call it if
-		# command_oneline() succeeded.
-		my @v = command('config', '--get-all', $k);
-		$added_placeholder{ dirname($_) } = $_ foreach @v;
-	}
+	_try_init_package($git_svn);
+	$self->{_save_ph} = { %added_placeholder };
+	$self->{ignore_regex} = $_ignore_regex;
 
 	$self->{empty} = {};
 	$self->{dir_prop} = {};
@@ -64,6 +42,43 @@ sub new {
 	$self;
 }
 
+sub _try_init_package {
+	if (!$_package_inited) {
+		my ( $git_svn ) = @_;
+
+		$_package_inited = 1;
+		$repo_id = $git_svn->{repo_id};
+
+		# some options are read globally, but can be overridden locally
+		# per [svn-remote "..."] section.  Command-line options will *NOT*
+		# override options set in an [svn-remote "..."] section
+
+		my $k = "svn-remote.$repo_id.ignore-paths";
+		my $v = eval { command_oneline('config', '--get', $k) };
+		$_ignore_regex = $v;
+
+		$k = "svn-remote.$repo_id.preserve-empty-dirs";
+		$v = eval { command_oneline('config', '--get', '--bool', $k) };
+		if ($v && $v eq 'true') {
+			$_preserve_empty_dirs = 1;
+			$k = "svn-remote.$repo_id.placeholder-filename";
+			$v = eval { command_oneline('config', '--get', $k) };
+			$_placeholder_filename = $v;
+
+			# Load the list of placeholder files added during previous invocations.
+			$k = "svn-remote.$repo_id.added-placeholder";
+			$v = eval { command_oneline('config', '--get-all', $k) };
+			if ($v) {
+				# command() prints errors to stderr, so we only call it if
+				# command_oneline() succeeded.
+				my @v = command('config', '--get-all', $k);
+				$added_placeholder{ dirname($_) } = $_ foreach @v;
+			}
+		}
+	}
+	undef
+}
+
 # this uses the Ra object, so it must be called before do_{switch,update},
 # not inside them (when the Git::SVN::Fetcher object is passed) to
 # do_{switch,update}
@@ -123,8 +138,6 @@ sub is_path_ignored {
 	return 1 if in_dot_git($path);
 	return 1 if defined($self->{ignore_regex}) &&
 	            $path =~ m!$self->{ignore_regex}!;
-	return 0 unless defined($_ignore_regex);
-	return 1 if $path =~ m!$_ignore_regex!o;
 	return 0;
 }
 
@@ -506,6 +519,14 @@ sub add_placeholder_file {
 
 sub stash_placeholder_list {
 	my ($self) = @_;
+
+	for ( keys %added_placeholder ) {
+		goto theydiffer if (!delete $self->{_save_ph}{$_});
+	}
+	return undef if (!keys $self->{_save_ph});
+
+theydiffer:
+
 	my $k = "svn-remote.$repo_id.added-placeholder";
 	my $v = eval { command_oneline('config', '--get-all', $k) };
 	command_noisy('config', '--unset-all', $k) if $v;
-- 
1.8.1.5

^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2013-05-28 12:58 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-01  5:09 [PATCH 4/5] git-svn: fix bottleneck in stash_placeholder_list() Ilya Basin
2013-05-01  8:31 ` Re[2]: " Ilya Basin
2013-05-01 17:09   ` Junio C Hamano
2013-05-01 19:51     ` Re[2]: " Ilya Basin
2013-05-01 21:30       ` Eric Wong
2013-05-01 21:53         ` Junio C Hamano
2013-05-02  2:49           ` Eric Wong
2013-05-02 17:31             ` Re[2]: " Ilya Basin
2013-05-02 20:40               ` Eric Wong
2013-05-03  5:26                 ` Re[2]: " Ilya Basin
2013-05-03  6:42                   ` Re[3]: " Ilya Basin
2013-05-06  8:14                     ` Re[4]: " Ilya Basin
2013-05-06  8:58               ` Re[3]: " Ilya Basin
2013-05-09  1:05                 ` Eric Wong
2013-05-28 12:57                 ` Re[4]: " Ilya Basin
2013-05-02 18:59             ` Ray Chen
2013-05-02  3:51         ` Re[2]: " Ilya Basin
2013-05-02 20:09           ` Eric Wong
  -- strict thread matches above, loose matches on Subject: below --
2013-04-30 17:37 Ilya Basin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.