[svk-commit] r2770 - in branches/moose/lib/SVK: Mirror/Backend
nobody at bestpractical.com
nobody at bestpractical.com
Mon Apr 28 10:31:48 EDT 2008
Author: clkao
Date: Mon Apr 28 10:31:46 2008
New Revision: 2770
Modified:
branches/moose/lib/SVK/Mirror.pm
branches/moose/lib/SVK/Mirror/Backend/SVNRa.pm
Log:
use moose for svk::mirror, delegation, and weaken.
Modified: branches/moose/lib/SVK/Mirror.pm
==============================================================================
--- branches/moose/lib/SVK/Mirror.pm (original)
+++ branches/moose/lib/SVK/Mirror.pm Mon Apr 28 10:31:46 2008
@@ -49,8 +49,7 @@
#
# END BPS TAGGED BLOCK }}}
package SVK::Mirror;
-use strict;
-use warnings;
+use Moose;
use SVN::Core;
use SVK::Logger;
@@ -58,38 +57,28 @@
use Sys::Hostname;
use SVK::I18N;
use SVK::Util qw(uri_escape uri_unescape);
-use Scalar::Util 'weaken';
-use base 'Class::Accessor::Fast';
-
-__PACKAGE__->mk_accessors(qw(depot path server_uuid source_uuid pool url _backend _locked follow_anchor_copy _rev_cache));
-
-*repos = sub { Carp::cluck unless $_[0]->depot; shift->depot->repos };
+has [qw(path server_uuid source_uuid url _locked follow_anchor_copy _rev_cache)] => (
+ is => "rw",
+);
+
+has 'pool' => (
+ is => "ro",
+ default => { SVN::Pool->new(undef) },
+);
+
+has depot => (
+ is => "rw",
+ handles => [qw(repos)],
+);
+
+has _backend => (
+ is => 'rw',
+ handles => [qw(find_rev_from_changeset find_changeset sync_changeset traverse_new_changesets mirror_changesets get_commit_editor refresh change_rev_prop fromrev source_path relocate)],
+);
use SVK::Mirror::Backend::SVNRa;
-## class SVK::Mirror;
-## has ($.repos, $.path, $.server_uuid, $.url, $.pool);
-## has $!backend handles <find_changeset sync_changeset traverse_new_changesets mirror_changesets get_commit_editor>;
-## has $!locked
-
-## submethod BUILD($.path, $.repos, :$backend = 'SVNRa', :$.url, :%backend_options) {
-## $!backend = $.load_backend: self;
-## if $.url {
-## $!backend.new: self;
-## }
-## else {
-## $!backend.load: self;
-## }
-## POST {
-## [&&] $.url, $.server_uuid;
-## }
-## }
-
-## method load($path, $repos) {
-## $.new(:$path, :$repos);
-##}
-
=head1 NAME
SVK::Mirror -
@@ -118,18 +107,18 @@
my ( $class, $args ) = @_;
my $self = $class->SUPER::new($args);
+ # in has uri, use a builder to handle this or do it in submethod BUILD
$self->{url} =~ s{/+$}{}g;
$self->{url} = uri_unescape($self->{url});
- $self->pool( SVN::Pool->new(undef) )
- unless $self->pool;
-
if ( $self->path eq '/' ) {
+ # has backend => ( lazy_build => 1 )
+ # sub _build_backend {
$self->_backend(
$self->_create_backend( 'SVNSync',
$args->{backend_options} )
);
- weaken( $self->{_backend}{mirror} );
+ #}
return $self;
}
@@ -145,8 +134,6 @@
$self->_create_backend( $args->{backend}, $args->{backend_options}, $opt{txn}, $editor )
);
- weaken( $self->{_backend}{mirror} );
-
my %mirrors = map { ( $_ => 1 ) } $self->path,
split( /\n/, $t->root->node_prop( '/', 'svm:mirror' ) || '' );
@@ -180,7 +167,6 @@
my $backend = $self->path eq '/' ? 'SVNSync' : 'SVNRa';
$self->_backend(
$self->_load_backend( $backend, $args->{backend_options} ) );
- weaken( $self->{_backend}{mirror} );
return $self;
}
@@ -327,19 +313,6 @@
->refresh_revision;
}
-for my $delegate
- qw( find_rev_from_changeset find_changeset sync_changeset traverse_new_changesets mirror_changesets get_commit_editor refresh change_rev_prop fromrev source_path relocate )
-{
- no strict 'refs';
- *{$delegate} = sub {
- my $self = shift;
- Carp::cluck $delegate unless $self->_backend;
- my $method = $self->_backend->can($delegate);
- unshift @_, $self->_backend;
- goto $method;
- };
-}
-
# compat methods
sub spec {
Modified: branches/moose/lib/SVK/Mirror/Backend/SVNRa.pm
==============================================================================
--- branches/moose/lib/SVK/Mirror/Backend/SVNRa.pm (original)
+++ branches/moose/lib/SVK/Mirror/Backend/SVNRa.pm Mon Apr 28 10:31:46 2008
@@ -62,11 +62,11 @@
use SVK::Logger;
use SVK::Editor::FilterProp;
use SVK::Editor::Composite;
+use Moose;
use Class::Autouse qw(SVK::Editor::SubTree SVK::Editor::CopyHandler SVK::Editor::Translate);
## class SVK::Mirror::Backend::SVNRa;
-## has $.mirror is weak;
## has ($!config, $!auth_baton, $!auth_ref);
## has ($.source_root, $.source_path, $.fromrev)
@@ -76,7 +76,12 @@
# for this: things without _'s will probably move to base
# SVK::Mirror::Backend
-__PACKAGE__->mk_accessors(qw(mirror _config _auth_baton _auth_ref _auth_baton source_root source_path fromrev _has_replay _cached_ra use_pipeline));
+__PACKAGE__->mk_accessors(qw(_config _auth_baton _auth_ref _auth_baton source_root source_path fromrev _has_replay _cached_ra use_pipeline));
+
+has mirror => (
+ is => "rw",
+ is_weak => 1,
+);
=head1 NAME
More information about the svk-commit
mailing list