threads / patch / 4316

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

Subject: [PATCH 0/1] Tried to fix git-svn's handling of filenames with embedded '@'.

## tl;dr

9 messages between May 28, 2006 and May 30, 2006. Diffs are folded; open one to read it.

replies: 8people: 3as markdown or json

Seth Falcon· May 28, 2006, 18:15 UTC · lore
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@PKGNAME@.R') 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@PKGNAME@.R" 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
Seth Falcon· May 28, 2006, 18:15 UTC · re: Seth Falcon · lore

[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 foo@bar.c
  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 foo@bar.c@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(-)
Show changes to contrib/git-svn/git-svn.perl +4 −3
diff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl
index b3e0684..498ffe0 100755
--- a/contrib/git-svn/git-svn.perl
+++ b/contrib/git-svn/git-svn.perl
@@ -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',
-- 
1.3.3.gb931
Junio C Hamano· May 28, 2006, 20:42 UTC · re: Seth Falcon · lore

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

Seth Falcon <sethfalcon@gmail.com> writes:
Show 13 quoted lines
> svn has trouble parsing files with embedded '@' characters.  For
> example,
>
>   svn propget svn:keywords foo@bar.c
>   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 foo@bar.c@BASE
>
> This patch appends '@BASE' to the filename in all calls to 'svn
> propget'.
Eric, this sounds sane to me.  Ack?
Eric Wong· May 29, 2006, 05:25 UTC · re: Junio C Hamano · lore

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

Junio C Hamano <junkio@cox.net> wrote:
Show 17 quoted lines
> Seth Falcon <sethfalcon@gmail.com> writes:
> 
> > svn has trouble parsing files with embedded '@' characters.  For
> > example,
> >
> >   svn propget svn:keywords foo@bar.c
> >   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 foo@bar.c@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.

-- 
Eric Wong
Eric Wong· May 29, 2006, 06:35 UTC · re: Seth Falcon · lore

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

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 foo@bar.c
  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 foo@bar.c@BASE

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

Patch originally by Seth Falcon <sethfalcon@gmail.com>
Seth: signoff?
[ew: Made to work with older svn that don't support peg revisions]
Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
 contrib/git-svn/git-svn.perl |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)
Show changes to contrib/git-svn/git-svn.perl +13 −4
diff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl
index b3e0684..54b93f4 100755
--- a/contrib/git-svn/git-svn.perl
+++ b/contrib/git-svn/git-svn.perl
@@ -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:
-- 
1.3.3.gef0f
Seth Falcon· May 29, 2006, 17:47 UTC · re: Eric Wong · lore

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

Eric Wong <normalperson@yhbt.net> writes:
> Seth: how does this work?
Your revised patch works for me, thanks.
+ seth
Eric Wong· May 30, 2006, 02:03 UTC · re: Eric Wong · lore

[PATCH] git-svn: t0001: workaround a heredoc bug in old versions of dash

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.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
 contrib/git-svn/t/t0001-contrib-git-svn-props.sh |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
edbca3e1b96747330a4b1459e914b07105b3bc44
Show changes to contrib/git-svn/t/t0001-contrib-git-svn-props.sh +2 −1
diff --git a/contrib/git-svn/t/t0001-contrib-git-svn-props.sh b/contrib/git-svn/t/t0001-contrib-git-svn-props.sh
index 6fa7889..23a5a2a 100644
--- a/contrib/git-svn/t/t0001-contrib-git-svn-props.sh
+++ b/contrib/git-svn/t/t0001-contrib-git-svn-props.sh
@@ -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`
-- 
1.3.2.g7d11
Eric Wong· May 30, 2006, 02:03 UTC · re: Eric Wong · lore

[PATCH] git-svn: remove assertion that broke with older versions of svn

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.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
 contrib/git-svn/git-svn.perl |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
b430de64cb228512b9a817499203827c0ef645aa
Show changes to contrib/git-svn/git-svn.perl +0 −1
diff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl
index b3e0684..aac8779 100755
--- a/contrib/git-svn/git-svn.perl
+++ b/contrib/git-svn/git-svn.perl
@@ -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, '-|';
-- 
1.3.2.g7d11

← back to recent threads