[Bps-public-commit] r10973 - in SVN-PropDB: . bin lib/Prophet/Sync/Source lib/Prophet/Sync/Source/SVN

jesse at bestpractical.com jesse at bestpractical.com
Sun Mar 2 21:41:58 EST 2008


Author: jesse
Date: Sun Mar  2 21:41:56 2008
New Revision: 10973

Added:
   SVN-PropDB/lib/Prophet/Sync/
   SVN-PropDB/lib/Prophet/Sync/Source/
   SVN-PropDB/lib/Prophet/Sync/Source/SVN/
   SVN-PropDB/lib/Prophet/Sync/Source/SVN.pm
   SVN-PropDB/lib/Prophet/Sync/Source/SVN/ReplayEditor.pm
Modified:
   SVN-PropDB/   (props changed)
   SVN-PropDB/bin/svn-replay

Log:
 r28074 at 31b:  jesse | 2008-03-02 21:41:45 -0500
 * svn replace tool that gets us reasonable property delta reporting


Modified: SVN-PropDB/bin/svn-replay
==============================================================================
--- SVN-PropDB/bin/svn-replay	(original)
+++ SVN-PropDB/bin/svn-replay	Sun Mar  2 21:41:56 2008
@@ -1,145 +1,11 @@
 #!/usr/bin/perl -w
 use strict;
-use SVN::Core;
-use SVN::Ra;
-use SVK;
-use SVK::Config;
 
-my $pool = SVN::Pool->new_default;
-my ($baton, $ref) = SVN::Core::auth_open_helper(SVK::Config->get_auth_providers);
-my $config = SVK::Config->svnconfig;
-my $url = shift;
-my $ra = SVN::Ra->new( url => $url || 'https://svn.apache.org/repos/asf/incubator', config => $config, auth => $baton);
-use SVN::Delta;
-$ra->reparent($url);
-#"https://svn.apache.org/repos/asf/incubator/servicemix/branches/servicemix-4.0");
-#warn $ra->get_dir('', shift || 595538);
+use Prophet::Sync::Source::SVN;
+my $sync = Prophet::Sync::Source::SVN->new();
 
-my $last_child =  $ra->get_latest_revnum;
+$sync->setup(shift @ARGV);
+my @changes = $sync->fetch_changesets();
+warn YAML::Dump(\@changes); use YAML;
 
-
-        my $handle_replayed_txn = sub {
-            use YAML;
-            warn "Asked to replya a txn with args ". YAML::Dump(\@_);
-
-            Prophet::SVN::Delta::Editor::Replay->new(
-                _editor => [ Prophet::SVN::Delta::Editor::Replay->new ],
-                _debug  => 1
-            );
-        };
-
-for ( 1 .. $last_child ) {
-    warn "Now fetching remote rev " . $_;
-
-    warn $ra->replay( $_, 0, 0, $handle_replayed_txn->());
-
-}
-
-package Prophet::SVN::Delta::Editor::Replay;
-use base qw/SVN::Delta::Editor/;
-
-sub apply {
-    my $self = shift;
-    warn "In apply: ";  warn YAML::Dump(\@_)};
-
-sub open_root {
-    my $self = shift;
-    my ($edit_baton, $base_rev, $dir_pool, $root_baton) = (@_);
-    warn "opening the root (it was changed in $base_rev)" ;
-}
-
-sub open_directory { 
-    my $self = shift;
-    my ($path, $parent_baton, $base_rev, $dir_pool, $child_baton) = (@_);
-    
-    warn "open_directory $path (last rev was $base_rev)";
-}
-sub delete_entry { 
-    my $self = shift;
-    my ($path, $revision, $parent_baton) = (@_);
-    warn "Deleting $path (last changed as of $revision)";
-}
-
-sub add_file { 
-    my $self = shift;
-    warn "Adding a file";
-    my ($path, $parent_baton, $copy_path, $copy_revision, $file_pool, $file_baton) = (@_);
-    warn "$path - (Copied from $copy_path as of $copy_revision)";
-}
-
-sub add_directory {
-    my $self = shift;
-    my ($path, $parent_baton, $copyfrom_path, $copyfrom_revision, $dir_pool, $child_baton) = (@_);
-    warn "Added a new directory - $path. It came from $copyfrom_path as of $copyfrom_revision";
-}
-
-sub open_file {
-    my $self = shift;
-    my ($path, $parent_baton, $base_rev, $file_pool, $file_baton) = (@_);
-
-
-    warn "Opening a file for editing: $path. (The previous rev was $base_rev)";
-
-}
-sub close_file {
-    my $self = shift;
-    my ($file_baton, $text_checksum, $pool) = (@_);
-    #  warn " Done with the file edit";
-
-}
-
-sub absent_file {
-    my $self = shift;
-    my ($file_baton, $text_checksum, $pool) = (@_);
-    warn "We aren't allowed to see this file for some reason. maybe authz";
-
-
-}
-
-sub close_directory {
-    my $self = shift;
-    #warn "Done with the directory";
-    my ($dir_baton, $pool) = (@_);
-
-}
-
-sub absent_directory {
-    my $self = shift;
-    my ($path, $parent_baton, $pool) = (@_);
-    warn" We can't see this directory ($path) because of something (maybe authz)";
-}
-
-sub xx_apply_textdelta {
-    my $self = shift;
-    my ($base_checksum, $pool, $window_handler, $handler_baton) = (@_);;
-    warn "Applying a text delta to the file";
-}
-sub change_file_prop {
-    my $self = shift;
-    warn Dumper(\@_); use Data::Dumper;
-    my ($file_baton, $name, $value, $pool) = (@_);
-    warn "Changing the props for this file";
-    warn "$name -> $value";
-
-}
-sub change_dir_prop {
-    my $self = shift;
-    my ($dir_baton, $name, $value, $pool) = (@_);
-    warn "Changing the props for this directory: $name -> $value";
-
-}
-
-sub set_target_revision {
-    my $self = shift;
-    my ($edit_baton, $target_revnum, $pool) = (@_);
-    warn "Set a target revision of $target_revnum";
-
-}
-
-sub close_edit {
-    my $self = shift;
-    my ($edit_baton, $pool) = (@_); 
-    #return "Done with this edit";
-}
 1;
-

Added: SVN-PropDB/lib/Prophet/Sync/Source/SVN.pm
==============================================================================
--- (empty file)
+++ SVN-PropDB/lib/Prophet/Sync/Source/SVN.pm	Sun Mar  2 21:41:56 2008
@@ -0,0 +1,64 @@
+use warnings;
+use strict;
+
+package Prophet::Sync::Source::SVN;
+
+use SVN::Core;
+use SVN::Ra;
+use SVK;
+use SVK::Config;
+use SVN::Delta;
+    
+use Prophet::Sync::Source::SVN::ReplayEditor;
+
+
+
+sub new {
+    my $class = shift;
+    my $self = {};
+    bless $self, $class;
+    return $self;
+}
+
+sub ra {
+    my $self = shift;
+    $self->{'_ra'} = shift if (@_);
+    return $self->{'_ra'};
+
+}
+
+sub setup{
+    my $self = shift;
+    my $url = shift;
+    my ($baton, $ref) = SVN::Core::auth_open_helper(SVK::Config->get_auth_providers);
+    my $config = SVK::Config->svnconfig;
+    $self->ra( SVN::Ra->new( url => $url , config => $config, auth => $baton));
+
+} 
+
+
+
+
+sub fetch_changesets {
+    my $self = shift;
+    my @results;
+    my $last_editor;
+    my $handle_replayed_txn = sub {
+        $last_editor
+            = Prophet::Sync::Source::SVN::ReplayEditor->new( _debug => 0 );
+        $last_editor->ra($self->ra);
+        return $last_editor;
+    };
+
+    for my $rev ( 1 .. $self->ra->get_latest_revnum ) {
+        $Prophet::Sync::Source::SVN::ReplayEditor::CURRENT_REMOTE_REVNO = $rev;
+        # This horrible hack is here because I have no idea how to pass custom variables into the editor
+        $self->ra->replay( $rev, 0, 1, $handle_replayed_txn->() );
+
+        push @results, $last_editor->dump_deltas;
+
+    }
+    return \@results;
+}
+
+1;

Added: SVN-PropDB/lib/Prophet/Sync/Source/SVN/ReplayEditor.pm
==============================================================================
--- (empty file)
+++ SVN-PropDB/lib/Prophet/Sync/Source/SVN/ReplayEditor.pm	Sun Mar  2 21:41:56 2008
@@ -0,0 +1,138 @@
+use warnings;
+use strict;
+
+package Prophet::Sync::Source::SVN::ReplayEditor;
+use base qw/SVN::Delta::Editor/;
+our $CURRENT_REMOTE_REVNO;
+
+sub new {
+    my $self = shift->SUPER::new(@_);
+    $self->{'revision'} = $CURRENT_REMOTE_REVNO;
+    return $self;
+}
+
+
+
+sub ra {
+    my $self = shift;
+    $self->{'_ra'} = shift if (@_);
+    return $self->{'_ra'};
+
+}
+sub apply {
+    my $self = shift;
+};
+
+sub open_root {
+    my $self = shift;
+    my ($edit_baton, $base_rev, $dir_pool, $root_baton) = (@_);
+    $self->{'base_rev'} = $base_rev;
+}
+
+
+sub open_directory { 
+    my $self = shift;
+    my ($path, $parent_baton, $base_rev, $dir_pool, $child_baton) = (@_);
+    push @{$self->{'dir_stack'}}, { path => $path, base_rev => $base_rev};
+}
+sub delete_entry { 
+    my $self = shift;
+    my ($path, $revision, $parent_baton) = (@_);
+    push @{$self->{'paths'}->{ $self->{'dir_stack'}->[-1]->{path} }->{delete_path}}, $path;
+}
+
+sub add_file { 
+    my $self = shift;
+    my ($path, $parent_baton, $copy_path, $copy_revision, $file_pool, $file_baton) = (@_);
+    $self->{'current_file'} = $path;
+    $self->{'current_file_base_rev'} = "newly created";
+    push @{$self->{'paths'}->{ $self->{'dir_stack'}->[-1]->{path} }->{create_file}}, $path;
+}
+
+sub add_directory {
+    my $self = shift;
+    my ($path, $parent_baton, $copyfrom_path, $copyfrom_revision, $dir_pool, $child_baton) = (@_);
+    push @{$self->{'dir_stack'}}, { path => $path, base_rev => -1 };
+    push @{$self->{'paths'}->{ $self->{'dir_stack'}->[-1]->{path} }->{create_dir}}, $path;
+}
+
+sub open_file {
+    my $self = shift;
+    my ($path, $parent_baton, $base_rev, $file_pool, $file_baton) = (@_);
+
+    $self->{'current_file'} = $path;
+    $self->{'current_file_base_rev'} = $base_rev;
+
+    my ($stream, $pool);
+    my ($rev_fetched, $prev_props)  =  $self->ra->get_file($path, $self->{'revision'}-1, $stream,$pool);
+
+    $self->{'paths'}->{$path}->{prev_properties} = $prev_props;
+
+
+
+}
+sub close_file {
+    my $self = shift;
+    my ($file_baton, $text_checksum, $pool) = (@_);
+    delete $self->{'current_file'};
+    delete $self->{'current_file_base_rev'}; 
+
+}
+
+sub absent_file {
+    my $self = shift;
+    my ($file_baton, $text_checksum, $pool) = (@_);
+
+
+}
+
+sub close_directory {
+    my $self = shift;
+    my ($dir_baton, $pool) = (@_);
+    pop @{$self->{dir_stack}};
+
+
+}
+
+sub absent_directory {
+    my $self = shift;
+    my ($path, $parent_baton, $pool) = (@_);
+}
+
+sub change_file_prop {
+    my $self = shift;
+    my ($file_baton, $name, $value, $pool) = (@_);
+
+    $self->{'paths'}->{$self->{'current_file'}}->{prop_deltas}->{$name} = { old => 
+        $self->{'paths'}->{$self->{'current_file'}}->{'prev_properties'}->{$name}
+        , new => $value };
+       
+}
+sub change_dir_prop {
+    my $self = shift;
+    my ($dir_baton, $name, $value, $pool) = (@_);
+    $self->{'paths'}->{ $self->{'dir_stack'}->[-1]->{path} }->{prop_deltas}->{$name} = {
+        old => $self->{'paths'}->{ $self->{'dir_stack'}->[-1]->{path} }->{'prev_properties'}->{$name},
+        new => $value
+        };
+
+}
+
+#sub set_target_revision { my $self = shift; my ($edit_baton, $target_revnum, $pool) = (@_); }
+
+
+sub close_edit {
+    my $self = shift;
+    my ($edit_baton, $pool) = (@_); 
+    warn YAML::Dump($self->{'paths'}); use YAML;
+}
+
+
+sub dump_deltas{
+    my $self = shift;
+    return { revision => $self->{'revision'}, paths => $self->{'paths'}}
+
+}
+
+1;
+



More information about the Bps-public-commit mailing list