[Bps-public-commit] r11797 - in sd/trunk: lib/App/SD/Replica/Hiveminder lib/App/SD/Replica/RT t
jesse at bestpractical.com
jesse at bestpractical.com
Sun Apr 20 17:02:14 EDT 2008
Author: jesse
Date: Sun Apr 20 17:02:13 2008
New Revision: 11797
Modified:
sd/trunk/lib/App/SD/Replica/Hiveminder.pm
sd/trunk/lib/App/SD/Replica/Hiveminder/PullEncoder.pm
sd/trunk/lib/App/SD/Replica/RT.pm
sd/trunk/lib/App/SD/Replica/RT/PullEncoder.pm
sd/trunk/t/sd-rt-hm.t
Log:
* Quiet down 'empty' props
Modified: sd/trunk/lib/App/SD/Replica/Hiveminder.pm
==============================================================================
--- sd/trunk/lib/App/SD/Replica/Hiveminder.pm (original)
+++ sd/trunk/lib/App/SD/Replica/Hiveminder.pm Sun Apr 20 17:02:13 2008
@@ -186,7 +186,6 @@
my %attr;
for my $key ( keys %props ) {
-
# XXX: fill me in
# next unless ( $key =~ /^(summary|queue|status|owner|custom)/ );
$attr{$key} = $props{$key};
Modified: sd/trunk/lib/App/SD/Replica/Hiveminder/PullEncoder.pm
==============================================================================
--- sd/trunk/lib/App/SD/Replica/Hiveminder/PullEncoder.pm (original)
+++ sd/trunk/lib/App/SD/Replica/Hiveminder/PullEncoder.pm Sun Apr 20 17:02:13 2008
@@ -20,6 +20,8 @@
my $previous_state = $args{'task'};
for my $txn ( sort { $b->{'id'} <=> $a->{'id'} } @{ $args{'transactions'} } ) {
+
+
my $changeset = Prophet::ChangeSet->new(
{ original_source_uuid => $self->sync_source->uuid,
original_sequence_no => $txn->{'id'},
@@ -81,6 +83,8 @@
sub add_prop_change {
my $self = shift;
my %args = validate( @_, { history_entry => 1, previous_state => 1, change => 1 } );
+
+
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'};
@@ -90,6 +94,8 @@
. $args{history_entry}->{'new_value'} . "\n\n"
. YAML::Dump( \%args );
}
+
+
$args{change}->add_prop_change(
name => $args{history_entry}->{'field'},
old => $args{history_entry}->{'old_value'},
@@ -253,4 +259,5 @@
return $changeset;
}
+
1;
Modified: sd/trunk/lib/App/SD/Replica/RT.pm
==============================================================================
--- sd/trunk/lib/App/SD/Replica/RT.pm (original)
+++ sd/trunk/lib/App/SD/Replica/RT.pm Sun Apr 20 17:02:13 2008
@@ -216,8 +216,7 @@
$id = $self->integrate_ticket_update( $change, $changeset );
} else {
- require YAML::Syck;
- die "AAAAAH I DO NOT KNOW HOW TO PUSH " . YAML::Syck::Dump($change);
+ return undef;
}
$self->record_pushed_transactions( ticket => $id, changeset => $changeset );
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 Sun Apr 20 17:02:13 2008
@@ -22,14 +22,16 @@
$args{'ticket'}->{'id'} =~ s/^ticket\///g;
my $ticket = $args{'ticket'};
-
+ map { delete $ticket->{$_} if (!defined $ticket->{$_} || $ticket->{$_} eq '') } keys %$ticket;
+ map { $ticket->{$_} = $self->date_to_iso( $ticket->{$_} ) } qw(Created Resolved Told LastUpdated Starts Started);
+ map { $ticket->{$_} =~ s/ minutes$// if defined $ticket->{$_} } qw(TimeWorked TimeLeft TimeEstimated);
my $create_state = $ticket;
- map { $create_state->{$_} = $self->date_to_iso( $create_state->{$_} ) }
- qw(Created Resolved Told LastUpdated Starts Started);
- map { $create_state->{$_} =~ s/ minutes$// } qw(TimeWorked TimeLeft TimeEstimated);
my @changesets;
for my $txn ( sort { $b->{'id'} <=> $a->{'id'} } @{ $args{'transactions'} } ) {
+ delete $txn->{'OldValue'} if ( $txn->{'OldValue'} eq '');
+ delete $txn->{'NewValue'} if ( $txn->{'NewValue'} eq '');
+
if ( my $sub = $self->can( '_recode_txn_' . $txn->{'Type'} ) ) {
my $changeset = Prophet::ChangeSet->new(
{ original_source_uuid => $self->sync_source->uuid,
@@ -86,6 +88,10 @@
sub _recode_txn_Set {
my $self = shift;
my %args = validate( @_, { ticket => 1, txn => 1, create_state => 1, changeset => 1 } );
+
+
+
+
my $change = Prophet::Change->new(
{ record_type => 'ticket',
@@ -103,9 +109,8 @@
}
} elsif ( $args{txn}->{Field} eq 'Owner' ) {
- $args{'txn'}->{NewValue} = $self->resolve_user_id_to( name => $args{'txn'}->{'NewValue'} ),
- $args{'txn'}->{OldValue}
- = $self->resolve_user_id_to( name => $args{'txn'}->{'OldValue'} )
+ $args{'txn'}->{NewValue} = $self->resolve_user_id_to( name => $args{'txn'}->{'NewValue'} );
+ $args{'txn'}->{OldValue} = $self->resolve_user_id_to( name => $args{'txn'}->{'OldValue'} );
}
@@ -114,9 +119,7 @@
$args{'create_state'}->{ $args{txn}->{Field} } = $args{txn}->{'OldValue'};
} else {
$args{'create_state'}->{ $args{txn}->{Field} } = $args{txn}->{'OldValue'};
- warn $args{'create_state'}->{ $args{txn}->{Field} } . " != "
- . $args{txn}->{'NewValue'} . "\n\n"
- . YAML::Dump( \%args );
+ warn $args{'create_state'}->{ $args{txn}->{Field} } . " != " . $args{txn}->{'NewValue'} . "\n\n" . YAML::Dump( \%args );
}
$change->add_prop_change(
name => $args{txn}->{'Field'},
@@ -337,7 +340,7 @@
my $self = shift;
my $date = shift;
- return '' if $date eq 'Not set';
+ return undef if $date eq 'Not set';
my $t = DateTime::Format::HTTP->parse_datetime($date);
return $t->ymd . " " . $t->hms;
}
Modified: sd/trunk/t/sd-rt-hm.t
==============================================================================
--- sd/trunk/t/sd-rt-hm.t (original)
+++ sd/trunk/t/sd-rt-hm.t Sun Apr 20 17:02:13 2008
@@ -89,10 +89,13 @@
as_bob {
local $ENV{SD_REPO} = $ENV{'PROPHET_REPO'};
run_output_matches( 'sd', [ 'ticket', '--list', '--regex', '.' ], [] );
+
+ diag("Bob pulling from RT");
( $ret, $out, $err ) = run_script( 'sd', [ 'pull', $sd_rt_url ] );
diag($err) if ($err);
run_output_matches( 'sd', [ 'ticket', '--list', '--regex', '.' ], [qr/(.*?)(?{ $flyman_uuid = $1 }) Fly Man new/] );
+ diag("Bob pulling from alice");
( $ret, $out, $err ) = run_script( 'sd', [ 'pull', repo_uri_for('alice') ] );
run_output_matches(
'sd',
@@ -100,6 +103,8 @@
[ sort "$yatta_uuid YATTA (no status)", "$flyman_uuid Fly Man new", ]
);
+
+ diag("Bob pushing to RT");
( $ret, $out, $err ) = run_script( 'sd', [ 'push', $sd_rt_url ] );
diag($err) if ($err);
More information about the Bps-public-commit
mailing list