about summary refs log tree commit homepage
path: root/perl/Git/SVN/Editor.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perl/Git/SVN/Editor.pm')
-rw-r--r--perl/Git/SVN/Editor.pm38
1 files changed, 38 insertions, 0 deletions
diff --git a/perl/Git/SVN/Editor.pm b/perl/Git/SVN/Editor.pm
index 34e8af966c..4088f13e72 100644
--- a/perl/Git/SVN/Editor.pm
+++ b/perl/Git/SVN/Editor.pm
@@ -288,6 +288,40 @@ sub apply_autoprops {
         }
 }
 
+sub check_attr {
+        my ($attr,$path) = @_;
+        my $val = command_oneline("check-attr", $attr, "--", $path);
+        if ($val) { $val =~ s/^[^:]*:\s*[^:]*:\s*(.*)\s*$/$1/; }
+        return $val;
+}
+
+sub apply_manualprops {
+        my ($self, $file, $fbat) = @_;
+        my $pending_properties = check_attr( "svn-properties", $file );
+        if ($pending_properties eq "") { return; }
+        # Parse the list of properties to set.
+        my @props = split(/;/, $pending_properties);
+        # TODO: get existing properties to compare to
+        # - this fails for add so currently not done
+        # my $existing_props = ::get_svnprops($file);
+        my $existing_props = {};
+        # TODO: caching svn properties or storing them in .gitattributes
+        # would make that faster
+        foreach my $prop (@props) {
+                # Parse 'name=value' syntax and set the property.
+                if ($prop =~ /([^=]+)=(.*)/) {
+                        my ($n,$v) = ($1,$2);
+                        for ($n, $v) {
+                                s/^\s+//; s/\s+$//;
+                        }
+                        my $existing = $existing_props->{$n};
+                        if (!defined($existing) || $existing ne $v) {
+                            $self->change_file_prop($fbat, $n, $v);
+                        }
+                }
+        }
+}
+
 sub A {
         my ($self, $m, $deletions) = @_;
         my ($dir, $file) = split_path($m->{file_b});
@@ -296,6 +330,7 @@ sub A {
                                         undef, -1);
         print "\tA\t$m->{file_b}\n" unless $::_q;
         $self->apply_autoprops($file, $fbat);
+        $self->apply_manualprops($m->{file_b}, $fbat);
         $self->chg_file($fbat, $m);
         $self->close_file($fbat,undef,$self->{pool});
 }
@@ -311,6 +346,7 @@ sub C {
         my $fbat = $self->add_file($self->repo_path($m->{file_b}), $pbat,
                                 $upa, $self->{r});
         print "\tC\t$m->{file_a} => $m->{file_b}\n" unless $::_q;
+        $self->apply_manualprops($m->{file_b}, $fbat);
         $self->chg_file($fbat, $m);
         $self->close_file($fbat,undef,$self->{pool});
 }
@@ -333,6 +369,7 @@ sub R {
                                 $upa, $self->{r});
         print "\tR\t$m->{file_a} => $m->{file_b}\n" unless $::_q;
         $self->apply_autoprops($file, $fbat);
+        $self->apply_manualprops($m->{file_b}, $fbat);
         $self->chg_file($fbat, $m);
         $self->close_file($fbat,undef,$self->{pool});
 
@@ -348,6 +385,7 @@ sub M {
         my $fbat = $self->open_file($self->repo_path($m->{file_b}),
                                 $pbat,$self->{r},$self->{pool});
         print "\t$m->{chg}\t$m->{file_b}\n" unless $::_q;
+        $self->apply_manualprops($m->{file_b}, $fbat);
         $self->chg_file($fbat, $m);
         $self->close_file($fbat,undef,$self->{pool});
 }