[svk-commit] r2828 - branches/path-resolver/lib/SVK/Editor

nobody at bestpractical.com nobody at bestpractical.com
Wed May 7 21:46:09 EDT 2008


Author: ruz
Date: Wed May  7 21:46:08 2008
New Revision: 2828

Modified:
   branches/path-resolver/lib/SVK/Editor/Merge.pm

Log:
* add path resolver for file changes

Modified: branches/path-resolver/lib/SVK/Editor/Merge.pm
==============================================================================
--- branches/path-resolver/lib/SVK/Editor/Merge.pm	(original)
+++ branches/path-resolver/lib/SVK/Editor/Merge.pm	Wed May  7 21:46:08 2008
@@ -342,9 +342,13 @@
 
 sub open_file {
     my ($self, $path, $pdir, $rev, $pool) = @_;
-    # modified but rm locally - tag for conflict?
+    unless ( defined $pdir ) {
+        $self->node_conflict($path);
+        return undef;
+    }
     my ($basepath, $fromrev, $inspector) = $self->resolve_base($path);
-    if (defined $pdir && $inspector->exist($basepath, $pool) == $SVN::Node::file) {
+    my $kind = $inspector->exist($basepath, $pool);
+    if ($kind == $SVN::Node::file) {
 	$self->{info}{$path}{baseinfo} = [$basepath, $fromrev, $inspector]
 	    if defined $fromrev;
 	$self->{info}{$path}{open} = [$pdir, $rev];
@@ -352,6 +356,35 @@
 	$self->{notify}->node_status ($path, '');
 	$pool->default if $pool && $pool->can ('default');
 	return $path;
+    } elsif ( !$kind ) {
+        # no file in dst
+        unless ( $self->{'resolve'} ) {
+            $self->node_conflict($path);
+            return undef;
+        }
+
+        require SVK::PathResolve;
+        my $action = SVK::PathResolve->new->change_file($path);
+        if ( $action eq 's' ) {
+            ++$self->{skipped};
+            ++$self->{changes};
+            $self->{notify}->node_status ($path, '');
+            return undef;
+        }
+        elsif ( $action eq 'a' ) {
+            $self->{added}{$path} = 1;
+            $self->{info}{$path}{overwrite} = 1;
+            $self->{info}{$path}{fpool} = $pool;
+            $self->{info}{$path}{baseinfo} = [$basepath, $fromrev, $inspector]
+                if defined $fromrev;
+            $self->{storage_baton}{$path} = $self->{storage}->add_file(
+                $path, $self->{storage_baton}{$pdir}, undef, -1, $pool
+            );
+            return $path;
+        }
+        else {
+            die "uknown action";
+        }
     }
     ++$self->{skipped};
     $self->{notify}->flush ($path);
@@ -569,6 +602,7 @@
 sub close_file {
     my ($self, $path, $checksum, $pool) = @_;
     return unless $path;
+
     my $info = $self->{info}{$path};
     my $fh = $info->{fh};
     my $iod;
@@ -582,7 +616,28 @@
     }
 
     # let close_directory reports about its children
-    if ($info->{fh}{new}) {
+    if ($info->{fh}{new} && $info->{overwrite}) {
+        # path conflict resolution, dst file doesn't exist, user requested 'add' it back
+
+        # XXX: this most probably doesn't work well with eol styles
+        # as ruz doesn't understand them well
+
+        # XXX: reopen handle, that's pretty bad that slurp_fh doesn't
+        # croak on closed FH
+        open $fh->{new}[FH], $fh->{new}[FILENAME];
+
+        open my $tmp_fh, '<', $fh->{new}[FILENAME];
+	$iod = IO::Digest->new ($tmp_fh, 'MD5');
+
+        local $self->{send_fulltext} = 1;
+	unless ($self->_overwrite_local_file ($fh, $path, $tmp_fh, $pool)) {
+	    $self->node_conflict ($path);
+	} else {
+            ++$self->{changes};
+            $self->{notify}->node_status ($path, 'A');
+        }
+	$self->cleanup_fh ($fh);
+    } elsif ($info->{fh}{new}) {
 
 	$self->_merge_file_unchanged ($path, $checksum, $pool), return
 	    if $checksum eq $storagebase_checksum;
@@ -815,7 +870,7 @@
     return undef unless $inspector->localmod ($basepath, $md5, $pool);
     return {} unless $self->{resolve};
 
-    my $fh = $self->{info}{$path}->{fh} || {};
+    my $fh = $self->{info}{$path}{fh} || {};
     $fh->{base} ||= [$no_base? (tmpfile('base-')): ($self->_retrieve_base($path, $pool))];
     $fh->{new} = [tmpfile('new-')];
     $fh->{local} = [tmpfile('local-')];


More information about the svk-commit mailing list