[PATCH] git-svn now work with crlf convertion enabled.

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Alexander Litvinov
Date: Wednesday, July 30, 2008 - 10:43 pm

Make git-svn works with crlf (or any other) file content convertion enabled.

When we modify file content SVN cant apply its delta to it. To fix this
situation I take full file content from SVN as next revision. This is
dump and slow but it works.
---
 git-svn.perl |   34 +++++++++++++++++++---------------
 1 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index cf6dbbc..606a177 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -28,6 +28,7 @@ sub fatal (@) { print STDERR "@_\n"; exit 1 }
 require SVN::Core; # use()-ing this causes segfaults for me... *shrug*
 require SVN::Ra;
 require SVN::Delta;
+require SVN::Client;
 if ($SVN::Core::VERSION lt '1.1.0') {
 	fatal "Need SVN::Core 1.1.0 or better (got $SVN::Core::VERSION)";
 }
@@ -3075,6 +3076,7 @@ sub new {
 	my $self = SVN::Delta::Editor->new;
 	bless $self, $class;
 	$self->{c} = $git_svn->{last_commit} if exists $git_svn->{last_commit};
+	$self->{url} = $git_svn->{url};
 	$self->{empty} = {};
 	$self->{dir_prop} = {};
 	$self->{file_prop} = {};
@@ -3214,30 +3216,32 @@ sub change_file_prop {
 
 sub apply_textdelta {
 	my ($self, $fb, $exp) = @_;
-	my $fh = IO::File->new_tmpfile;
-	$fh->autoflush(1);
-	# $fh gets auto-closed() by SVN::TxDelta::apply(),
-	# (but $base does not,) so dup() it for reading in close_file
-	open my $dup, '<&', $fh or croak $!;
+
 	my $base = IO::File->new_tmpfile;
 	$base->autoflush(1);
 	if ($fb->{blob}) {
 		print $base 'link ' if ($fb->{mode_a} == 120000);
 		my $size = $::_repository->cat_blob($fb->{blob}, $base);
 		die "Failed to read object $fb->{blob}" if ($size < 0);
-
-		if (defined $exp) {
-			seek $base, 0, 0 or croak $!;
-			my $got = ::md5sum($base);
-			die "Checksum mismatch: $fb->{path} $fb->{blob}\n",
-			    "expected: $exp\n",
-			    "     got: $got\n" if ($got ne $exp);
-		}
 	}
 	seek $base, 0, 0 or croak $!;
-	$fb->{fh} = $dup;
+
+	my $fh = IO::File->new_tmpfile;
+	$fh->autoflush(1);
+
+	$fb->{fh} = $fh;
 	$fb->{base} = $base;
-	[ SVN::TxDelta::apply($base, $fh, undef, $fb->{path}, $fb->{pool}) ];
+
+	my $url = $self->{url};
+	$url =~ s/\/$//;
+	$url .= '/';
+	$url .= $fb->{path};
+
+	my $rev = $self->{file_prop}->{$fb->{path}}->{'svn:entry:committed-rev'};
+	die ("Can't find $fb->{path} revision") unless defined $rev;
+
+	my $ctx = SVN::Client->new();
+	$ctx->cat($fh, $url, $rev);
 }
 
 sub close_file {
-- 
1.5.6.2

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
git-svn does not seems to work with crlf convertion enabled., Alexander Litvinov, (Wed Jul 23, 1:44 am)
Re: git-svn does not seems to work with crlf convertion en ..., Johannes Schindelin, (Wed Jul 23, 2:18 am)
Re: git-svn does not seems to work with crlf convertion en ..., Alexander Litvinov, (Wed Jul 23, 4:52 am)
Re: git-svn does not seems to work with crlf convertion en ..., Johannes Schindelin, (Wed Jul 23, 5:57 am)
Re: git-svn does not seems to work with crlf convertion en ..., Johannes Schindelin, (Wed Jul 23, 9:07 am)
Re: git-svn does not seems to work with crlf convertion en ..., Alexander Litvinov, (Wed Jul 23, 8:13 pm)
Re: git-svn does not seems to work with crlf convertion en ..., Johannes Schindelin, (Thu Jul 24, 7:40 am)
Re: git-svn does not seems to work with crlf convertion en ..., Alexander Litvinov, (Tue Jul 29, 9:37 pm)
[PATCH] git-svn now work with crlf convertion enabled., Alexander Litvinov, (Wed Jul 30, 10:43 pm)
Re: [PATCH] git-svn now work with crlf convertion enabled., Alexander Litvinov, (Wed Jul 30, 10:57 pm)
Re: [PATCH] git-svn now work with crlf convertion enabled., Dmitry Potapov, (Thu Jul 31, 3:45 am)
[RFC] hash-object --no-filters, Dmitry Potapov, (Thu Jul 31, 12:09 pm)
Re: [PATCH] git-svn now work with crlf convertion enabled., Alexander Litvinov, (Thu Jul 31, 8:23 pm)
Re: [PATCH] git-svn now work with crlf convertion enabled., Junio C Hamano, (Thu Jul 31, 10:09 pm)
Re: [PATCH] git-svn now work with crlf convertion enabled., Dmitry Potapov, (Fri Aug 1, 12:44 am)
Re: [PATCH] git-svn now work with crlf convertion enabled., Dmitry Potapov, (Fri Aug 1, 12:47 am)
Re: [PATCH] git-svn now work with crlf convertion enabled., Alexander Litvinov, (Fri Aug 1, 4:11 am)
Re: [PATCH] git-svn now work with crlf convertion enabled., Alexander Litvinov, (Fri Aug 1, 4:27 am)
Re: [PATCH] git-svn now work with crlf convertion enabled., Alexander Litvinov, (Sun Aug 3, 8:10 pm)
Re: git-svn does not seems to work with crlf convertion en ..., Johannes Schindelin, (Wed Aug 6, 5:43 am)