Skip to contentSkip to conversation

Tried to fix git-svn's handling of filenames with embedded '@'.

PATCH In review Seth Falcon 3 participants 9 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

cover Tried to fix git-svn's handling of filenames with embedded '@'.

Hi Eric, all,

I decided to give git-svn a try for a large svn project and during my first git-svn fetch operation, I'm seeing a failure that seems related to recent changes in the handling of svn keywords.

Here is the traceback:

svn: Syntax error parsing revision '.R'
256 at /home/sfalcon/util/scm/bin/git-svn line 1124
main::safe_qx('svn', 'propget', 'svn:keywords', 'Biobase/inst/Code/R/get@[email protected]') called at /home/sfalcon/util/scm/bin/git-svn line 900 main::do_update_index('ARRAY(0x8395840)', 'add', 'undef')
called at /home/sfalcon/util/scm/bin/git-svn line 926

Unfortunately, my project has a file named "get@[email protected]" and svn thinks the '@.R' part is specifying a revision. Here comes a patch that got me going again. Not sure it is the right fix, nor whether it covers all places where some action will be needed.

Best,

+ seth

#1 lore raw

PATCH 1/1 Tried to fix git-svn's handling of filenames with embedded '@'.

svn has trouble parsing files with embedded '@' characters. For example,

svn propget svn:keywords [email protected]
svn: Syntax error parsing revision 'bar.c'

I asked about this on #svn and the workaround suggested was to append an explicit revision specifier:

svn propget svn:keywords [email protected]@BASE

This patch appends '@BASE' to the filename in all calls to 'svn propget'.

---
 contrib/git-svn/git-svn.perl |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
contrib/git-svn/git-svn.perl +4 -3
index b3e0684..498ffe0 100755
@@ -336,7 +336,7 @@ sub show_ignore {
 	my %ign;
 	File::Find::find({wanted=>sub{if(lstat $_ && -d _ && -d "$_/.svn"){
 		s#^\./##;
-		@{$ign{$_}} = safe_qx(qw(svn propget svn:ignore),$_);
+		@{$ign{$_}} = safe_qx(qw(svn propget svn:ignore),$_ . "\@BASE");
 		}}, no_chdir=>1},'.');
 
 	print "\n# /\n";
@@ -860,7 +860,7 @@ sub sys { system(@_) == 0 or croak $? }
 
 sub eol_cp {
 	my ($from, $to) = @_;
-	my $es = safe_qx(qw/svn propget svn:eol-style/, $to);
+	my $es = safe_qx(qw/svn propget svn:eol-style/, $to . "\@BASE");
 	open my $rfd, '<', $from or croak $!;
 	binmode $rfd or croak $!;
 	open my $wfd, '>', $to or croak $!;
@@ -898,7 +898,8 @@ sub do_update_index {
 	while (my $x = <$p>) {
 		chomp $x;
 		if (!$no_text_base && lstat $x && ! -l _ &&
-				safe_qx(qw/svn propget svn:keywords/,$x)) {
+				safe_qx(qw/svn propget svn:keywords/,
+                                        $x . "\@BASE")) {
 			my $mode = -x _ ? 0755 : 0644;
 			my ($v,$d,$f) = File::Spec->splitpath($x);
 			my $tb = File::Spec->catfile($d, '.svn', 'tmp',
Signature · 1 line
1.3.3.gb931
#2 lore raw

Seth: how does this work?

Ick, I just found out keyword killing tests don't pass with svn 1.1, though...

---

svn has trouble parsing files with embedded '@' characters. For example,

svn propget svn:keywords [email protected]
svn: Syntax error parsing revision 'bar.c'

I asked about this on #svn and the workaround suggested was to append an explicit revision specifier:

svn propget svn:keywords [email protected]@BASE

This patch appends '@BASE' to the filename in all calls to 'svn propget'.

Patch originally by Seth Falcon <[email protected]>
Seth: signoff?

[ew: Made to work with older svn that don't support peg revisions]

---
 contrib/git-svn/git-svn.perl |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)
contrib/git-svn/git-svn.perl +13 -4
index b3e0684..54b93f4 100755
@@ -34,7 +34,7 @@ my $sha1_short = qr/[a-f\d]{4,40}/;
 my ($_revision,$_stdin,$_no_ignore_ext,$_no_stop_copy,$_help,$_rmdir,$_edit,
 	$_find_copies_harder, $_l, $_version, $_upgrade, $_authors);
 my (@_branch_from, %tree_map, %users);
-my $_svn_co_url_revs;
+my ($_svn_co_url_revs, $_svn_pg_peg_revs);
 
 my %fc_opts = ( 'no-ignore-externals' => \$_no_ignore_ext,
 		'branch|b=s' => \@_branch_from,
@@ -336,7 +336,7 @@ sub show_ignore {
 	my %ign;
 	File::Find::find({wanted=>sub{if(lstat $_ && -d _ && -d "$_/.svn"){
 		s#^\./##;
-		@{$ign{$_}} = safe_qx(qw(svn propget svn:ignore),$_);
+		@{$ign{$_}} = svn_propget_base('svn:ignore', $_);
 		}}, no_chdir=>1},'.');
 
 	print "\n# /\n";
@@ -860,7 +860,7 @@ sub sys { system(@_) == 0 or croak $? }
 
 sub eol_cp {
 	my ($from, $to) = @_;
-	my $es = safe_qx(qw/svn propget svn:eol-style/, $to);
+	my $es = svn_propget_base('svn:eol-style', $to);
 	open my $rfd, '<', $from or croak $!;
 	binmode $rfd or croak $!;
 	open my $wfd, '>', $to or croak $!;
@@ -898,7 +898,7 @@ sub do_update_index {
 	while (my $x = <$p>) {
 		chomp $x;
 		if (!$no_text_base && lstat $x && ! -l _ &&
-				safe_qx(qw/svn propget svn:keywords/,$x)) {
+				svn_propget_base('svn:keywords', $x)) {
 			my $mode = -x _ ? 0755 : 0644;
 			my ($v,$d,$f) = File::Spec->splitpath($x);
 			my $tb = File::Spec->catfile($d, '.svn', 'tmp',
@@ -1136,6 +1136,9 @@ sub svn_compat_check {
 	if (grep /usage: checkout URL\[\@REV\]/,@co_help) {
 		$_svn_co_url_revs = 1;
 	}
+	if (grep /\[TARGET\[\@REV\]\.\.\.\]/, `svn propget -h`) {
+		$_svn_pg_peg_revs = 1;
+	}
 
 	# I really, really hope nobody hits this...
 	unless (grep /stop-on-copy/, (safe_qx(qw(svn log -h)))) {
@@ -1215,6 +1218,12 @@ sub load_authors {
 	close $authors or croak $!;
 }
 
+sub svn_propget_base {
+	my ($p, $f) = @_;
+	$f .= '@BASE' if $_svn_pg_peg_revs;
+	return safe_qx(qw/svn propget/, $p, $f);
+}
+
 __END__
 
 Data structures:
Signature · 1 line
1.3.3.gef0f
#3 lore raw
Quoted 1 line · Eric Wong

Seth: how does this work?

Your revised patch works for me, thanks.

+ seth

#4 lore raw

PATCH 1/1 git-svn: t0001: workaround a heredoc bug in old versions of dash

In reply to Eric Wong

The dash installed on my Debian Sarge boxes don't seem to like <<'' as a heredoc starter. Recent versions of dash do not need this fix.

---

 contrib/git-svn/t/t0001-contrib-git-svn-props.sh |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

edbca3e1b96747330a4b1459e914b07105b3bc44

contrib/git-svn/t/t0001-contrib-git-svn-props.sh +2 -1
index 6fa7889..23a5a2a 100644
@@ -20,9 +20,10 @@ a_empty_cr=
 a_empty_crlf=
 
 cd import
-	cat >> kw.c <<''
+	cat >> kw.c <<\EOF
 /* Make it look like somebody copied a file from CVS into SVN: */
 /* $Id: kw.c,v 1.1.1.1 1994/03/06 00:00:00 eric Exp $ */
+EOF
 
 	printf "Hello\r\nWorld\r\n" > crlf
 	a_crlf=`git-hash-object -w crlf`
Signature · 1 line
1.3.2.g7d11
#5 lore raw

PATCH 1/1 git-svn: remove assertion that broke with older versions of svn

In reply to Eric Wong

svn < 1.3.x would display changes to keywords lines as modified if they aren't expanded in the working copy. We already check for changes against the git tree here, so checking against the svn one is probably excessive.

---

 contrib/git-svn/git-svn.perl |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

b430de64cb228512b9a817499203827c0ef645aa

contrib/git-svn/git-svn.perl +0 -1
index b3e0684..aac8779 100755
@@ -567,7 +567,6 @@ sub precommit_check {
 sub svn_checkout_tree {
 	my ($svn_rev, $treeish) = @_;
 	my $from = file_to_s("$REV_DIR/$svn_rev");
-	assert_svn_wc_clean($svn_rev);
 	assert_tree($from);
 	print "diff-tree $from $treeish\n";
 	my $pid = open my $diff_fh, '-|';
Signature · 1 line
1.3.2.g7d11
#6 lore raw

PATCH 1/1 git-svn: compat fixes for older svn and dash

In reply to Eric Wong

The following patches work around problems I had with testing git-svn on my Debian Sarge box.

#7 lore raw
In reply to Seth Falcon
Quoted 6 lines · Seth Falcon

svn has trouble parsing files with embedded '@' characters. For example,

svn propget svn:keywords [email protected]
svn: Syntax error parsing revision 'bar.c'

Quoted 7 lines

I asked about this on #svn and the workaround suggested was to append an explicit revision specifier:

svn propget svn:keywords [email protected]@BASE

This patch appends '@BASE' to the filename in all calls to 'svn propget'.

Eric, this sounds sane to me. Ack?

#8 lore raw
Quoted 11 lines · Junio C Hamano
Quoted 9 lines · Seth Falcon

svn has trouble parsing files with embedded '@' characters. For example,

svn propget svn:keywords [email protected]
svn: Syntax error parsing revision 'bar.c'

I asked about this on #svn and the workaround suggested was to append an explicit revision specifier:

Quoted 6 lines
Quoted 4 lines

svn propget svn:keywords [email protected]@BASE

This patch appends '@BASE' to the filename in all calls to 'svn propget'.

Eric, this sounds sane to me. Ack?

Doesn't work with svn 1.1 (a requirement of mine, unfortunately). I'll have a fix for that in a bit.

Signature · 1 line
Eric Wong