[svk-commit] r2152 - in branches/svk-logging: . lib/SVK/Command lib/SVK/Mirror/Backend t

stig at bestpractical.com stig at bestpractical.com
Thu Nov 16 11:33:29 EST 2006


Author: stig
Date: Thu Nov 16 11:33:29 2006
New Revision: 2152

Added:
   branches/svk-logging/utils/verify-mirror
Modified:
   branches/svk-logging/   (props changed)
   branches/svk-logging/MANIFEST
   branches/svk-logging/lib/SVK/Command/Commit.pm
   branches/svk-logging/lib/SVK/Command/Copy.pm
   branches/svk-logging/lib/SVK/Mirror/Backend/SVNRa.pm
   branches/svk-logging/t/12copy.t

Log:
 r2148 at figleaf (orig r2145):  jesse | 2006-11-16 02:57:56 +0000
 
 r2152 at figleaf (orig r2148):  clkao | 2006-11-16 14:27:37 +0000
 Add a tool "verify-mirror".
 r2153 at figleaf (orig r2149):  clkao | 2006-11-16 15:26:37 +0000
 We can still reuse the commit ra if we can reparent it.
 
 r2154 at figleaf (orig r2150):  clkao | 2006-11-16 15:40:23 +0000
 the pipeline process is accidentally saving commit message for us.


Modified: branches/svk-logging/MANIFEST
==============================================================================
--- branches/svk-logging/MANIFEST	(original)
+++ branches/svk-logging/MANIFEST	Thu Nov 16 11:33:29 2006
@@ -280,3 +280,4 @@
 utils/extract-message-catalog
 utils/pullyu
 utils/svk-ediff.el
+utils/verify-mirror

Modified: branches/svk-logging/lib/SVK/Command/Commit.pm
==============================================================================
--- branches/svk-logging/lib/SVK/Command/Commit.pm	(original)
+++ branches/svk-logging/lib/SVK/Command/Commit.pm	Thu Nov 16 11:33:29 2006
@@ -84,7 +84,7 @@
 	$self->{message} = get_buffer_from_editor
 	    (loc('log message'), $self->message_prompt,
 	     join ("\n", $self->{message} || '', $self->message_prompt, ''), 'commit');
-	++$self->{save_message};
+	$self->{save_message} = $$;
     }
     $self->decode_commit_message;
 }
@@ -123,6 +123,7 @@
 sub save_message {
     my $self = shift;
     return unless $self->{save_message};
+    return unless $self->{save_message} == $$;
     local $@;
     my ($fh, $file) = tmpfile ('commit', DIR => '', TEXT => 1, UNLINK => 0);
     print $fh $self->{message};
@@ -361,7 +362,7 @@
 	    get_buffer_from_editor (loc('log message'), $self->target_prompt,
 				    undef, $file, $target->copath, $target->source->{targets});
 	die loc("No targets to commit.\n") if $#{$targets} < 0;
-	++$self->{save_message};
+	$self->{save_message} = $$;
 	unlink $file;
     }
 

Modified: branches/svk-logging/lib/SVK/Command/Copy.pm
==============================================================================
--- branches/svk-logging/lib/SVK/Command/Copy.pm	(original)
+++ branches/svk-logging/lib/SVK/Command/Copy.pm	Thu Nov 16 11:33:29 2006
@@ -156,7 +156,7 @@
     my $m = $self->under_mirror($dst);
     if ( $m && !$dst->same_source(@src) ) {
         $logger->error(loc("You are trying to copy across different mirrors."));
-        die loc( "Try create an empty directory %1, and run smerge --baseless %2 %3.\n",
+        die loc( "Create an empty directory %1, and run smerge --baseless %2 %3.\n",
             $dst->report, $src[0]->report, $dst->report )
           if $#src == 0 && $dst->isa('SVK::Path');
         return 1;

Modified: branches/svk-logging/lib/SVK/Mirror/Backend/SVNRa.pm
==============================================================================
--- branches/svk-logging/lib/SVK/Mirror/Backend/SVNRa.pm	(original)
+++ branches/svk-logging/lib/SVK/Mirror/Backend/SVNRa.pm	Thu Nov 16 11:33:29 2006
@@ -256,6 +256,11 @@
     my ($self, $ra) = @_;
     return if $self->_cached_ra;
     return if ref($ra) eq 'SVK::Mirror::Backend::SVNRaPipe';
+    if ($ra->{url} ne $self->mirror->url) {
+	return unless _p_svn_ra_session_t->can('reparent');
+	$ra->reparent($self->mirror->url);
+    }
+
     $self->_cached_ra( $ra );
 }
 
@@ -485,8 +490,7 @@
             $msg,
             sub {
 		# only recycle the ra if we are committing from root
-		$self->_ra_finished($self->{commit_ra})
-		    unless length $path;
+		$self->_ra_finished($self->{commit_ra});
                 $committed->(@_);
             },
             @lock ) );

Modified: branches/svk-logging/t/12copy.t
==============================================================================
--- branches/svk-logging/t/12copy.t	(original)
+++ branches/svk-logging/t/12copy.t	Thu Nov 16 11:33:29 2006
@@ -130,7 +130,7 @@
 
 is_output ($svk, 'cp', ['//V/new', '//foo-remote/new'],
 	   ['You are trying to copy across different mirrors.',
-	    'Try create an empty directory //foo-remote/new, and run smerge --baseless //V/new //foo-remote/new.']);
+	    'Create an empty directory //foo-remote/new, and run smerge --baseless //V/new //foo-remote/new.']);
 
 is_output ($svk, 'cp', ['-m', 'copy directly', '//V/me', '//V/me-dcopied'],
 	   ['Committed revision 15.']);

Added: branches/svk-logging/utils/verify-mirror
==============================================================================
--- (empty file)
+++ branches/svk-logging/utils/verify-mirror	Thu Nov 16 11:33:29 2006
@@ -0,0 +1,117 @@
+#!/usr/bin/perl -w
+# XXX: This requires newer svn api do make do_status work
+
+# usage: verify-mirror repospath path revision
+use strict;
+no warnings 'once';
+use SVK;
+use SVK::XD;
+
+my ($repospath, $path, $revision) = @ARGV;
+
+my $repos = SVN::Repos::open($repospath) or die $!;
+my $depot = SVK::Depot->new( {repos => $repos, repospath => $repospath} );
+
+my $t = SVK::Path->real_new( { depot => $depot, revision => $revision, path => $path } );
+
+my ($m, $mpath) = $t->is_mirrored;
+my $rabackend = $m->_backend;
+
+my $changed = $t->root->paths_changed;
+my $rev = $m->find_changeset($t->revision);
+my $ra = $rabackend->_new_ra;
+
+require SVK::Command::Log;
+$ra->get_log([''], $rev, $rev, 0,
+	    1, 1,
+    sub {
+        my ( $paths, $r, $author, $date, $log, $ppool ) = @_;
+        my $pool = SVN::Pool->new($ppool);
+        for my $remotepath ( keys %$paths ) {
+            $pool->clear;
+            my $localpath = $path . $remotepath;
+            my $local     = delete $changed->{$localpath}
+                or die "$localpath is not in changes";
+            my $action = $SVK::Command::Log::chg->[ $local->change_kind ];
+            die "different change action for $remotepath "
+                . $paths->{$remotepath}->action
+                . " and $action"
+                unless $paths->{$remotepath}->action eq $action;
+
+            next if $action eq 'D';
+
+            # XXX: option to turn off strict on copies.
+            if ( defined( my $from = $paths->{$remotepath}->copyfrom_path ) )
+            {
+                my ( $lfrom_rev, $lfrom ) = $t->root->copied_from($localpath);
+                die "copy from rev different for $localpath"
+                    unless $m->find_changeset($lfrom_rev)
+                    == $paths->{$remotepath}->copyfrom_rev;
+                die "copy from path different for $localpath"
+                    unless $path . $from eq $lfrom;
+
+            }
+
+            if ( $t->root->check_path($localpath) == $SVN::Node::file ) {
+                my $p = Path::Class::File->new_foreign( 'Unix', $remotepath );
+                my ( $parent, $target ) = ( $p->parent, $p->basename );
+
+                # do md5 comparison
+
+                my $fra = $rabackend->_new_ra(
+                    url => $m->url . ( $parent eq '/' ? '' : $parent ) );
+
+                # XXX: do_status requires svn trunk, and the required
+                # changed should be merged to 1.4.3
+                my $md5;
+                my $reporter = $fra->do_status(
+                    "$target",
+                    $rev, 1,
+                    MD5Collect::Editor->new(
+                           cb_md5 => sub { $md5->{ $_[0] } = $_[1] },
+#                            _debug => 1
+#                        }
+                    )
+                );
+
+                # my $reporter = $fra->do_update( $rev, "$target", 0,
+                #                    SVK::Editor->new( { _debug => 1 } ) );
+                $reporter->set_path( '', $rev - 1, 0, undef );
+                # $reporter->set_path( $target, $rev-1, 1, '' );
+                $reporter->finish_report;
+
+                die "no md5 found from server for $remotepath ($target)"
+                    unless $md5->{$target};
+
+                die "md5 for $localpath is different"
+                    unless $md5->{$target} eq
+                    $t->root->file_md5_checksum($localpath);
+            }
+
+        }
+    } );
+
+use Data::Dumper;
+die "not in remote: ".join(',', keys %$changed)
+    if keys %$changed;
+
+package MD5Collect::Editor;
+use base 'SVK::Editor';
+__PACKAGE__->mk_accessors(qw(cb_md5));
+
+sub add_file {
+    my $self = shift;
+    my $path = shift;
+    return $path;
+}
+
+sub open_file {
+    my $self = shift;
+    my $path = shift;
+    return $path;
+}
+
+sub close_file {
+    my ($self, $path, $md5) = @_;
+    $self->{cb_md5}->($path, $md5);
+}


More information about the svk-commit mailing list