Helo Jason,
thanks for looking this up. I have changed a lot of code in the last
days, so it is very possible that I broke something. Esp. the CRLF vs.
LF changes are untested from my side, since I work only on windows. I
don't have the problem here.
The CRLF to LF conversion is tied to the "svn:eol-style" property, and
this property is only assigned due to auto-props. There is no implicit
assignment from the converter itslef, like with the svn:mime-type
property. Auto-props are only assigned in the ADD handler [1]: If I
remeber this correctly, this was enough to set the property. The only
problem was to emit an emty props block within the next revision. Since
this will delete all assigned properties. Therefor the check in L845 [2]
Your proposed change might work, and is in almost all cases propably the
correct answer. But it is technically not correct since someone could
specify a different svn:eol-style for non binary files in the
auto-props. The correct solution would be to query each time for the
auto-props and to check wether the eol-style is set.
While thinking about that, it could also be possible that a rename
could also change the properties.
What about the following patch?
Index: Dumpfile.pm
===================================================================
--- Dumpfile.pm (revision 319)
+++ Dumpfile.pm (working copy)
@@ -308,6 +308,10 @@
my $node = Vss2Svn::Dumpfile::Node->new();
$node->set_initial_props($newpath, $data);
+ # change the properties according to the new name
+# if (defined $self->{auto_props}) {
+# $node->add_props ($self->{auto_props}->get_props ($newpath));
+# }
$node->{action} = 'add';
my($copyrev, $copypath);
@@ -764,17 +768,27 @@
my($self, $node) = @_;
my $fh = $self->{fh};
+ # only in an add or rename action the propery array is set. So we
have
+ # to lookup the eol-style flag again. The best thing is to query the
+ # property always temporarirly
+ my %tmpProps = ();
+ if (defined $self->{auto_props}) {
+ %tmpProps = $self->{auto_props}->get_props ($node->{path});
+ }
+ my $eolStyle = %tmpProps->{'svn:eol-style'};
+ my $isNative = (defined $eolStyle && $eolStyle eq 'native') ? 1 : 0;
+
my $string = $node->get_headers();
print $fh $string;
$self->output_content($node->{hideprops}? undef : $node->{props},
- $node->{text}, $node->{file});
+ $node->{text}, $node->{file}, $isNative);
} # End output_node
###############################################################################
# output_content
###############################################################################
sub output_content {
- my($self, $props, $text, $file) = @_;
+ my($self, $props, $text, $file, $isNative) = @_;
my $fh = $self->{fh};
@@ -803,11 +817,16 @@
my $md5;
$md5 = Digest::MD5->new if $self->{do_md5};
+ # prevent errors due to non existing files
+ if(!defined $text && defined $file && !-e $file) {
+ $text = "";
+ }
+
# convert CRLF -> LF before calculating the size and compute the md5
if(!defined $text && defined $file) {
- my ($input, $output);
- my $style = $props->{'svn:eol-style'};
- if (defined $style && $style eq 'native') {
+
+ my ($input, $output);
+ if (defined $isNative) {
open ($input, "<:crlf", $file);
my $tmpFile = "$gTmpDir/crlf_to_lf.tmp.txt";
open ($output, ">", $tmpFile);
Dirk
[1]
http://www.pumacode.org/projects/vss2svn/browser/trunk/script/Vss2Svn/Dumpfile.pm#L233
[2]
http://www.pumacode.org/projects/vss2svn/browser/trunk/script/Vss2Svn/Dumpfile.pm#L845
Jason Winnebeck schrieb:
Jason Winnebeck wrote:
I have found the bug and I'm seeing if I can fix it. In
output_content the
file is converted from CRLF to LF if and only if "svn:eol-style" is
defined as
native, but the property is set only when the file is added. When
change nodes
are being output, the svn:eol-style property is not emitted (I
presume because
only property changes are needed?). This leads to a lack of
conversion of
these nodes. I've never worked with Perl and I've never worked with
vss2svn
code but I will see if I can figure out a hack. What we need to find
out is if
the node is a "text" node. What I don't understand is why does it
matter if
the eol-style is native or not? This is because I'm not sure if the
content
should always be in LF on every platform, or if it is based on
platform, or
based on eol-style setting. At least I know in my case it should
always be LF
in the dumpfile.
The attached patch seems to work, except for XML files in SourceSafe
2005, which are treated as Unicode but the ssphys thinks they are
binary. For that I wrote my own hack that works for my repository
only (not in this patch). I will continue testing to make sure the
history works properly. I've also noticed that the CRLF problem
affects more than just annotate, it also affects diff and merge over
the affected areas, causing conflicts when the files are identical on
"export".
Jason
------------------------------------------------------------------------
Index: Vss2Svn/Dumpfile.pm
===================================================================
--- Vss2Svn/Dumpfile.pm (revision 321)
+++ Vss2Svn/Dumpfile.pm (working copy)
@@ -767,14 +767,14 @@
my $string = $node->get_headers();
print $fh $string;
$self->output_content($node->{hideprops}? undef : $node->{props},
- $node->{text}, $node->{file});
+ $node->{text}, $node->{file},
$node->{is_binary});
} # End output_node
###############################################################################
# output_content
###############################################################################
sub output_content {
- my($self, $props, $text, $file) = @_;
+ my($self, $props, $text, $file, $is_binary) = @_;
my $fh = $self->{fh};
@@ -805,9 +805,9 @@
# convert CRLF -> LF before calculating the size and compute the
md5
if(!defined $text && defined $file) {
- my ($input, $output);
+ my ($input, $output);
my $style = $props->{'svn:eol-style'};
- if (defined $style && $style eq 'native') {
+ if ( defined $is_binary && !$is_binary ) {
open ($input, "<:crlf", $file);
my $tmpFile = "$gTmpDir/crlf_to_lf.tmp.txt";
open ($output, ">", $tmpFile);
Index: Vss2Svn/Dumpfile/Node.pm
===================================================================
--- Vss2Svn/Dumpfile/Node.pm (revision 321)
+++ Vss2Svn/Dumpfile/Node.pm (working copy)
@@ -34,6 +34,7 @@
hideprops => 0,
file => undef,
text => undef,
+ is_binary => undef,
};
$self = bless($self, $class);
@@ -49,11 +50,8 @@
$self->{kind} = ($data->{itemtype} == 1)? 'dir' : 'file';
$self->{path} = $itempath;
+ $self->{is_binary} = $data->{is_binary};
-# if ($data->{is_binary}) {
-# $self->add_prop('svn:mime-type', 'application/octet-stream');
-# }
-
} # End set_initial_props
###############################################################################
------------------------------------------------------------------------
_______________________________________________
vss2svn-users mailing list
Project homepage:
http://www.pumacode.org/projects/vss2svn/
Subscribe/Unsubscribe/Admin:
http://lists.pumacode.org/mailman/listinfo/vss2svn-users-lists.pumacode.org
Mailing list web interface (with searchable archives):
http://dir.gmane.org/gmane.comp.version-control.subversion.vss2svn.user
_______________________________________________
vss2svn-users mailing list
Project homepage:
http://www.pumacode.org/projects/vss2svn/
Subscribe/Unsubscribe/Admin:
http://lists.pumacode.org/mailman/listinfo/vss2svn-users-lists.pumacode.org
Mailing list web interface (with searchable archives):
http://dir.gmane.org/gmane.comp.version-control.subversion.vss2svn.user