[Bps-public-commit] r11402 - in SVN-PropDB/lib/Prophet: .

clkao at bestpractical.com clkao at bestpractical.com
Wed Apr 2 20:00:19 EDT 2008


Author: clkao
Date: Wed Apr  2 20:00:18 2008
New Revision: 11402

Modified:
   SVN-PropDB/lib/Prophet/CLI.pm
   SVN-PropDB/lib/Prophet/Handle.pm
   SVN-PropDB/lib/Prophet/Sync/Source/SVN.pm

Log:
whatever that is working.

Modified: SVN-PropDB/lib/Prophet/CLI.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/CLI.pm	(original)
+++ SVN-PropDB/lib/Prophet/CLI.pm	Wed Apr  2 20:00:18 2008
@@ -74,6 +74,24 @@
     };
 }
 
+=head2 register_types TYPES
+
+Register cmd_C<type> methods if the calling namespace that handles the cli command for each of the record type C<type>.
+
+=cut
+
+sub register_types {
+    my $self = shift;
+    my @types = (@_);
+    
+    my $calling_package = (caller)[0];
+    for my $type (@types) {
+        no strict 'refs';
+         *{$calling_package."::cmd_".$type} = $self->record_cmd($type);
+        }
+}
+
+
 =head2 parse_args
 
 This routine pulls arguments passed on the command line out of ARGV and sticks them in L</args>. The keys have leading "--" stripped.
@@ -110,14 +128,18 @@
     }
 }
 
-=head2 args
+=head2 args [$ARGS]
 
 Returns a reference to the key-value pairs passed in on the command line
 
+If passed a hashref, sets the args to taht;
+
 =cut
 
 sub args {
     my $self = shift;
+    
+    $self->{'args'} = shift if $_[0]; 
     return $self->{'args'};
 
 }
@@ -193,6 +215,9 @@
 
     my $opts = $cli->args();
 
+    warn $opts->{from};
+    warn $opts->{to};
+    
     my $source = Prophet::Sync::Source->new( { url => $opts->{'from'} } );
     my $target = Prophet::Sync::Source->new( { url => $opts->{'to'} } );
 

Modified: SVN-PropDB/lib/Prophet/Handle.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Handle.pm	(original)
+++ SVN-PropDB/lib/Prophet/Handle.pm	Wed Apr  2 20:00:18 2008
@@ -12,11 +12,13 @@
 use SVN::Fs;
 
 our $DEBUG = '0';
-__PACKAGE__->mk_accessors(qw(repo_path repo_handle db_root current_edit _pool));
+__PACKAGE__->mk_accessors(qw(repo_path repo_handle current_edit _pool));
 
-=head2 new { repository => $FILESYSTEM_PATH, db_root => $REPOS_PATH }
+use constant db_root => '_prophet';
+
+=head2 new { repository => $FILESYSTEM_PATH}
  
-Create a new subversion filesystem backend repository handle. If the repository/path don't exist, create it.
+Create a new subversion filesystem backend repository handle. If the repository don't exist, create it.
 
 =cut
 
@@ -24,8 +26,7 @@
     my $class = shift;
     my $self  = {};
     bless $self, $class;
-    my %args = validate( @_, { repository => 1, db_root => 1 } );
-    $self->db_root( $args{'db_root'} );
+    my %args = validate( @_, { repository => 1, db_root => 0 } );
     $self->repo_path( $args{'repository'} );
     $self->_connect();
     $self->_pool( SVN::Pool->new );

Modified: SVN-PropDB/lib/Prophet/Sync/Source/SVN.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Sync/Source/SVN.pm	(original)
+++ SVN-PropDB/lib/Prophet/Sync/Source/SVN.pm	Wed Apr  2 20:00:18 2008
@@ -28,17 +28,22 @@
 
 =cut
 
-sub setup {
+sub _get_ra {
     my $self = shift;
     my ( $baton, $ref ) = SVN::Core::auth_open_helper( Prophet::Sync::Source::SVN::Util->get_auth_providers );
     my $config = Prophet::Sync::Source::SVN::Util->svnconfig;
+    return SVN::Ra->new( url => $self->url, config => $config, auth => $baton, pool => $self->pool ) ;
+}
+
+sub setup {
+    my $self = shift;
     my $pool   = SVN::Pool->new;
 
     $self->pool($pool);
-    eval { $self->ra( SVN::Ra->new( url => $self->url, config => $config, auth => $baton, pool => $self->pool ) ); };
-    Carp::confess $@ if $@;
+
+    $self->ra( $self->_get_ra );
     if ( $self->url =~ /^file:\/\/(.*)$/ ) {
-        $self->prophet_handle( Prophet::Handle->new( { repository => $1, db_root => '_prophet' } ) );
+        $self->prophet_handle( Prophet::Handle->new( { repository => $1 } ) );
     }
     if ( $self->url =~ m/_res$/ ) {
 
@@ -75,25 +80,20 @@
     my $self = shift;
     my %args = validate( @_, { after => 1 } );
     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;
-    };
 
     my $first_rev = ( $args{'after'} + 1 ) || 1;
 
     # XXX TODO we should  be using a svn get_log call here rather than simple iteration
     # clkao explains that this won't deal cleanly with cases where there are revision "holes"
     for my $rev ( $first_rev .. $self->ra->get_latest_revnum ) {
+        my $editor = Prophet::Sync::Source::SVN::ReplayEditor->new( _debug => 0 );
+        $editor->ra( $self->_get_ra );
         my $pool = SVN::Pool->new_default;
 
         # This horrible hack is here because I have no idea how to pass custom variables into the editor
         $Prophet::Sync::Source::SVN::ReplayEditor::CURRENT_REMOTE_REVNO = $rev;
-        $self->ra->replay( $rev, 0, 1, $handle_replayed_txn->() );
-        push @results, $self->_recode_changeset( $last_editor->dump_deltas, $self->ra->rev_proplist($rev) );
+        $self->ra->replay( $rev, 0, 1, $editor );
+        push @results, $self->_recode_changeset( $editor->dump_deltas, $self->ra->rev_proplist($rev) );
 
     }
 
@@ -306,7 +306,7 @@
     my ($source) = validate_pos( @_, { type => SCALAR } );
     my ( $stream, $pool );
 
-    my $filename = join( "/", "_prophet", $Prophet::Handle::MERGETICKET_METATYPE, $source );
+    my $filename = join( "/", $self->prophet_handle->db_root, $Prophet::Handle::MERGETICKET_METATYPE, $source );
     my ( $rev_fetched, $props )
         = eval { $self->ra->get_file( $filename, $self->ra->get_latest_revnum, $stream, $pool ); };
 



More information about the Bps-public-commit mailing list