[svk-commit] r2545 - in branches/ticket-bug/lib/SVK: Editor

nobody at bestpractical.com nobody at bestpractical.com
Tue Oct 16 10:32:40 EDT 2007


Author: clkao
Date: Tue Oct 16 10:32:36 2007
New Revision: 2545

Modified:
   branches/ticket-bug/lib/SVK/Editor/Merge.pm
   branches/ticket-bug/lib/SVK/Merge.pm

Log:
First cut of ticket overwriting fixes.  The problem is caused
by repos_commit in svn checking directory update-ness with
node_created_rev.  However when we are setting the merge ticket,
we have already modified the content of the directory henec it
is always fresh.

* split get_new_ticket and print_new_ticket
* split set_ticket from cb_merged and call it upon opening
  of the target node.
 


Modified: branches/ticket-bug/lib/SVK/Editor/Merge.pm
==============================================================================
--- branches/ticket-bug/lib/SVK/Editor/Merge.pm	(original)
+++ branches/ticket-bug/lib/SVK/Editor/Merge.pm	Tue Oct 16 10:32:36 2007
@@ -58,7 +58,7 @@
 use autouse 'SVK::Util'
     => qw( slurp_fh md5_fh tmpfile devnull abs2rel );
 
-__PACKAGE__->mk_accessors(qw(inspector notify storage));
+__PACKAGE__->mk_accessors(qw(inspector notify storage ticket cb_merged));
 
 use Class::Autouse qw(SVK::Inspector::Root SVK::Notify
 		      Data::Hierarchy IO::Digest);
@@ -227,21 +227,27 @@
     $self->{storage}->set_target_revision ($revision);
 }
 
+sub set_ticket {
+    my ($self, $baton, $type, $pool) = @_;
+
+    my $func = "change_${type}_prop";
+
+    $self->{storage}->$func( $baton, 'svk:merge', $self->ticket->as_string, $pool );
+
+}
+
 sub open_root {
-    my ($self, $baserev) = @_;
+    my ($self, $baserev, $pool) = @_;
     $self->{baserev} = $baserev;
     $self->{notify} ||= SVK::Notify->new_with_report ($self->{report}, $self->{target});
     $self->{storage_baton}{''} =
 	$self->{storage}->open_root ($self->{cb_rev}->($self->{target}||''));
     $self->{notify}->node_status ('', '');
 
-    my $ticket = $self->{ticket};
     $self->{dh} = Data::Hierarchy->new;
-    $self->{cb_merged} =
-	sub { my ($editor, $baton, $type, $pool) = @_;
-	      my $func = "change_${type}_prop";
-	      $editor->$func ($baton, 'svk:merge', $ticket->(), $pool);
-	  } if $ticket;
+
+    $self->set_ticket($self->{storage_baton}{''}, 'dir', $pool)
+	if !length $self->{target} && $self->ticket;
 
     return '';
 }
@@ -326,7 +332,10 @@
 	$self->{storage}->open_file ($path, $self->{storage_baton}{$pdir},
 				     $self->{cb_rev}->($path), $pool);
     ++$self->{changes};
-    delete $self->{info}{$path}{open};
+    delete $self->{info}{$path}{open}; # 
+
+    $self->set_ticket( $self->{storage_baton}{$path}, 'file', $pool )
+	if $path eq $self->{target} && $self->ticket;
 }
 
 sub ensure_close {
@@ -337,9 +346,9 @@
     $self->{cb_closed}->($path, $checksum, $pool)
         if $self->{cb_closed};
 
-    if ($path eq $self->{target} && $self->{changes} && $self->{cb_merged}) {
+    if ($path eq $self->{target} && $self->{changes} && $self->cb_merged) {
 	$self->ensure_open ($path);
-	$self->{cb_merged}->($self->{storage}, $self->{storage_baton}{$path}, 'file', $pool);
+	$self->cb_merged->($self->{ticket});
     }
 
     if (my $baton = $self->{storage_baton}{$path}) {
@@ -666,9 +675,12 @@
 	}
     }
     $self->{notify}->node_status ($path, '');
-    $self->{storage_baton}{$path} =
+    my $baton = $self->{storage_baton}{$path} =
 	$self->{storage}->open_directory ($path, $self->{storage_baton}{$pdir},
 					  $self->{cb_rev}->($path), @arg);
+    $self->set_ticket->($baton, 'dir', $pool)
+	if $path eq $self->{target} && $self->ticket;
+
     return $path;
 }
 
@@ -681,8 +693,9 @@
     $self->{notify}->flush_dir ($path);
 
     my $baton = $self->{storage_baton}{$path};
-    $self->{cb_merged}->($self->{storage}, $baton, 'dir', $pool)
-	if $path eq $self->{target} && $self->{changes} && $self->{cb_merged};
+    $self->cb_merged->( $self->{ticket} )
+	if $path eq $self->{target} && $self->{changes} && $self->cb_merged;
+
 
     $self->{storage}->close_directory ($baton, $pool);
     delete $self->{storage_baton}{$path}

Modified: branches/ticket-bug/lib/SVK/Merge.pm
==============================================================================
--- branches/ticket-bug/lib/SVK/Merge.pm	(original)
+++ branches/ticket-bug/lib/SVK/Merge.pm	Tue Oct 16 10:32:36 2007
@@ -345,20 +345,29 @@
     return $minfo;
 }
 
-sub get_new_ticket {
+sub _get_new_ticket {
     my ($self, $srcinfo) = @_;
-    my $dstinfo = $self->merge_info ($self->{dst});
+    my $dstinfo = $self->merge_info($self->{dst});
     # We want the ticket representing src, but not dst.
-    my $newinfo = $dstinfo->union ($srcinfo)->del_target ($self->{dst});
-    unless ($self->{quiet}) {
-	for (sort keys %$newinfo) {
-	    $logger->info(loc("New merge ticket: %1:%2", $_, $newinfo->{$_}{rev}))
-		if !$dstinfo->{$_} || $newinfo->{$_}{rev} > $dstinfo->{$_}{rev};
-	}
-    }
+    return $dstinfo->union ($srcinfo)->del_target($self->{dst});
+}
+
+# deprecated
+sub get_new_ticket {
+    my ($self, $srcinfo) = @_;
+    my $newinfo = $self->_get_new_ticket($srcinfo);
+    $self->print_new_ticket($newinfo);
     return $newinfo->as_string;
 }
 
+sub print_new_ticket {
+    my ($self, $dstinfo, $newinfo) = @_;
+    for (sort keys %$newinfo) {
+	$logger->info(loc("New merge ticket: %1:%2", $_, $newinfo->{$_}{rev}))
+	    if !$dstinfo->{$_} || $newinfo->{$_}{rev} > $dstinfo->{$_}{rev};
+    }
+}
+
 sub log {
     my ($self, $no_separator) = @_;
     open my $buf, '>', \ (my $tmp = '');
@@ -528,6 +537,8 @@
     # $cb{inspector} = $self->{dst}->inspector
     # unless ref($cb{inspector}) eq 'SVK::Inspector::Compat' ;
 
+    my $dstinfo = $self->merge_info($self->{dst});
+
     my $meditor = SVK::Editor::Merge->new
 	( anchor => $src->path_anchor,
 	  repospath => $src->repospath, # for stupid copyfrom url
@@ -554,8 +565,12 @@
 					(SVK::Merge::Info->new ($prop->{local}))->as_string);
 			    }
 			},
-	    ticket => 
-	    sub { $self->get_new_ticket ($self->merge_info_with_copy ($src)->add_target ($src)) }
+	    ticket =>
+	    $self->_get_new_ticket($self->merge_info_with_copy($src)->add_target($src)),
+	    cb_merged => sub {
+		my ($ticket) = @_;
+		$self->print_new_ticket( $dstinfo, $ticket ) unless $self->{quiet};
+	    }
 	  ) :
 	  ( prop_resolver => { 'svk:merge' => sub { ('G', undef, 1)} # skip
 			     }),


More information about the svk-commit mailing list