[Bps-public-commit] r16297 - in sd/trunk/lib/App/SD/Replica: hm rt
ruz at bestpractical.com
ruz at bestpractical.com
Tue Oct 14 23:33:04 EDT 2008
Author: ruz
Date: Tue Oct 14 23:33:04 2008
New Revision: 16297
Modified:
sd/trunk/lib/App/SD/Replica/hm.pm
sd/trunk/lib/App/SD/Replica/hm/PullEncoder.pm
sd/trunk/lib/App/SD/Replica/rt/PullEncoder.pm
Log:
* minor refactoring towards readability
Modified: sd/trunk/lib/App/SD/Replica/hm.pm
==============================================================================
--- sd/trunk/lib/App/SD/Replica/hm.pm (original)
+++ sd/trunk/lib/App/SD/Replica/hm.pm Tue Oct 14 23:33:04 2008
@@ -84,14 +84,13 @@
require App::SD::Replica::hm::PullEncoder;
my $recoder = App::SD::Replica::hm::PullEncoder->new( { sync_source => $self } );
for my $task ( @{ $self->find_matching_tasks } ) {
- $args{callback}->($_)
- for @{
- $recoder->run(
- task => $task,
- transactions =>
- $self->find_matching_transactions( task => $task->{id}, starting_transaction => $first_rev )
- )
- };
+ my $changesets = $recoder->run(
+ task => $task,
+ transactions => $self->find_matching_transactions(
+ task => $task->{id}, starting_transaction => $first_rev
+ ),
+ );
+ $args{'callback'}->($_) for @$changesets;
}
}
Modified: sd/trunk/lib/App/SD/Replica/hm/PullEncoder.pm
==============================================================================
--- sd/trunk/lib/App/SD/Replica/hm/PullEncoder.pm (original)
+++ sd/trunk/lib/App/SD/Replica/hm/PullEncoder.pm Tue Oct 14 23:33:04 2008
@@ -34,10 +34,11 @@
foreach my $email ( @{ $txn->{email_entries} } ) {
if ( my $sub = $self->can( '_recode_email_' . 'blah' ) ) {
$sub->(
- $self => previous_state => $previous_state,
- email => $email,
- txn => $txn,
- changeset => $changeset
+ $self,
+ previous_state => $previous_state,
+ email => $email,
+ txn => $txn,
+ changeset => $changeset,
);
}
}
@@ -51,26 +52,20 @@
sub add_prop_change {
my $self = shift;
my %args = validate( @_, { history_entry => 1, previous_state => 1, change => 1 } );
-
+ my $field = $args{'history_entry'}{'field'};
+ my $old = $args{'history_entry'}{'old_value'};
+ my $new = $args{'history_entry'}{'new_value'};
- if ( $args{'previous_state'}->{ $args{history_entry}->{field} } eq $args{history_entry}->{'new_value'} ) {
- $args{'previous_state'}->{ $args{history_entry}->{field} } = $args{history_entry}->{'old_value'};
+ if ( $args{'previous_state'}->{ $field } eq $new ) {
+ $args{'previous_state'}->{ $field } = $old;
} else {
- $args{'previous_state'}->{ $args{history_entry}->{field} } = $args{history_entry}->{'old_value'};
- warn $args{'previous_state'}->{ $args{history_entry}->{field} } . " != "
- . $args{history_entry}->{'new_value'} . "\n\n"
+ $args{'previous_state'}->{ $field } = $old;
+ warn $args{'previous_state'}->{ $field } . " != " . $new . "\n\n"
. YAML::Dump( \%args );
}
-
-
- $args{change}->add_prop_change(
- name => $args{history_entry}->{'field'},
- old => $args{history_entry}->{'old_value'},
- new => $args{history_entry}->{'new_value'}
-
- );
+ $args{change}->add_prop_change( name => $field, old => $old, new => $new );
}
sub recode_create {
Modified: sd/trunk/lib/App/SD/Replica/rt/PullEncoder.pm
==============================================================================
--- sd/trunk/lib/App/SD/Replica/rt/PullEncoder.pm (original)
+++ sd/trunk/lib/App/SD/Replica/rt/PullEncoder.pm Tue Oct 14 23:33:04 2008
@@ -39,7 +39,8 @@
print $progress->report( "%30b %p Est: %E\r", $counter );
$self->sync_source->log(
- "Fetching ticket $id - $counter of " . scalar @tickets );
+ "Fetching ticket $id - $counter of " . scalar @tickets
+ );
$tickets->{$id}->{ticket} = $self->_translate_final_ticket_state(
$self->sync_source->rt->show( type => 'ticket', id => $id )
);
@@ -222,10 +223,6 @@
sub _recode_txn_Set {
my $self = shift;
my %args = validate( @_, { txn => 1, ticket => 1, changeset => 1 } );
-
-
-
-
my $change = Prophet::Change->new(
{ record_type => 'ticket',
More information about the Bps-public-commit
mailing list