[Bps-public-commit] r16765 - in Prophet/branches/init-and-clone: . lib/Prophet t/Settings/t

sartak at bestpractical.com sartak at bestpractical.com
Sat Nov 8 03:33:23 EST 2008


Author: sartak
Date: Sat Nov  8 03:33:23 2008
New Revision: 16765

Modified:
   Prophet/branches/init-and-clone/   (props changed)
   Prophet/branches/init-and-clone/lib/Prophet/Change.pm
   Prophet/branches/init-and-clone/lib/Prophet/ChangeSet.pm
   Prophet/branches/init-and-clone/t/Settings/t/sync-database-settings.t
   Prophet/branches/init-and-clone/t/publish-pull.t
   Prophet/branches/init-and-clone/t/real-conflicting-merge.t
   Prophet/branches/init-and-clone/t/simple-conflicting-merge.t
   Prophet/branches/init-and-clone/t/simple-push.t

Log:
Merge up init-and-clone

Modified: Prophet/branches/init-and-clone/lib/Prophet/Change.pm
==============================================================================
--- Prophet/branches/init-and-clone/lib/Prophet/Change.pm	(original)
+++ Prophet/branches/init-and-clone/lib/Prophet/Change.pm	Sat Nov  8 03:33:23 2008
@@ -133,8 +133,7 @@
     }
 
     return {
-        record_uuid  => $self->record_uuid,
-        record_type  => $self->record_type,
+        record_type    => $self->record_type,
         change_type  => $self->change_type,
         prop_changes => $props,
     };

Modified: Prophet/branches/init-and-clone/lib/Prophet/ChangeSet.pm
==============================================================================
--- Prophet/branches/init-and-clone/lib/Prophet/ChangeSet.pm	(original)
+++ Prophet/branches/init-and-clone/lib/Prophet/ChangeSet.pm	Sat Nov  8 03:33:23 2008
@@ -153,7 +153,9 @@
     my $self = shift;
     my $as_hash = { map { $_ => $self->$_() } @SERIALIZE_PROPS };
 
-    $as_hash->{'changes'} = [ map $_->as_hash, $self->changes ];
+    for my $change ( $self->changes ) {
+        $as_hash->{changes}->{ $change->record_uuid } = $change->as_hash;
+    }
 
     return $as_hash;
 }
@@ -176,8 +178,8 @@
     my $hashref = shift;
     my $self    = $class->new( { map { $_ => $hashref->{$_} } @SERIALIZE_PROPS } );
 
-    for my $change ( @{ $hashref->{changes} } ) {
-        $self->add_change( change => Prophet::Change->new_from_hashref( $change->{'record_uuid'} => $change ) );
+    for my $change ( keys %{ $hashref->{changes} } ) {
+        $self->add_change( change => Prophet::Change->new_from_hashref( $change => $hashref->{changes}->{$change} ) );
     }
     return $self;
 }

Modified: Prophet/branches/init-and-clone/t/Settings/t/sync-database-settings.t
==============================================================================

Modified: Prophet/branches/init-and-clone/t/publish-pull.t
==============================================================================
--- Prophet/branches/init-and-clone/t/publish-pull.t	(original)
+++ Prophet/branches/init-and-clone/t/publish-pull.t	Sat Nov  8 03:33:23 2008
@@ -100,10 +100,9 @@
 
     my $changeset = $args{changeset}->as_hash;
 
-    my $changes = [
-        {
+    my $changes = {
+        $args{record_uuid} => {
             change_type  => 'add_file',
-            record_uuid  => $args{record_uuid},
             record_type  => $args{record_type},
             prop_changes => {
                 status => {
@@ -124,7 +123,7 @@
                 },
             },
         },
-    ];
+    };
 
     if ($args{merge}) {
         my $change_type = $args{sequence_no} > 1
@@ -135,16 +134,15 @@
                                ? $args{sequence_no} - 1
                                : undef;
 
-        push @$changes, {
+        $changes->{ replica_uuid_for('alice') } = {
             change_type  => $change_type,
-            record_uuid  => replica_uuid_for('alice'),
             record_type  => '_merge_tickets',
             prop_changes => {
                 'last-changeset' => {
                     old_value => $prev_changeset_num,
                     new_value => $args{sequence_no},
                 }
-            },
+            }
         };
     }
 

Modified: Prophet/branches/init-and-clone/t/real-conflicting-merge.t
==============================================================================
--- Prophet/branches/init-and-clone/t/real-conflicting-merge.t	(original)
+++ Prophet/branches/init-and-clone/t/real-conflicting-merge.t	Sat Nov  8 03:33:23 2008
@@ -168,11 +168,10 @@
     my @hashes = map { $_->as_hash } @changesets;
     is_deeply(
         \@hashes,
-        [   {   changes => [
-                    {
+        [   {   changes => {
+                    $record_id => {
                         change_type  => 'update_file',
-                        record_uuid  => $record_id,
-                        record_type  => 'Bug',
+                        record_type    => 'Bug',
                         prop_changes => {
                             status => {
                                 old_value => 'stalled',
@@ -180,7 +179,7 @@
                             }
                         }
                     }
-                ],
+                },
                 creator              => undef,
                 created              => $changesets[0]->created,
                 is_nullification     => 1,
@@ -199,27 +198,30 @@
                 original_sequence_no => $ALICE_LAST_REV_CACHE,
                 source_uuid          => replica_uuid(),
                 original_source_uuid => as_alice { replica_uuid() },
-                changes              => [
-                    {
-                        record_uuid  => $record_id,
-                        record_type  => 'Bug',
+                changes              => {
+                    $record_id => {
+                        record_type    => 'Bug',
                         change_type  => 'update_file',
                         prop_changes => {
                             status => { old_value => 'new', new_value => 'open' }
-                        },
+
+                            }
+
                     },
-                    {
-                        record_uuid  => as_alice{ replica_uuid() },
-                        record_type  => '_merge_tickets',
+                    as_alice {
+                        replica_uuid();
+                    } => {
+                        record_type    => '_merge_tickets',
                         change_type  => 'update_file',
                         prop_changes => {
                             'last-changeset' => {
                                 old_value => $ALICE_LAST_REV_CACHE - 1,
                                 new_value => $ALICE_LAST_REV_CACHE
                             }
-                        }
+                            }
+
                     }
-                ],
+                }
             },
 
             {
@@ -231,16 +233,18 @@
                 original_sequence_no => replica_last_rev(),
                 source_uuid          => replica_uuid(),
                 original_source_uuid => replica_uuid(),
-                changes              => [
-                    {
-                        record_uuid  => $record_id,
-                        record_type  => 'Bug',
+                changes              => {
+                    $record_id => {
+                        record_type    => 'Bug',
                         change_type  => 'update_file',
                         prop_changes => {
                             status => { old_value => 'open', new_value => 'stalled' }
-                        },
+
+                            }
+
                     }
-                ]
+                    }
+
             }
         ],
         "Bob's final state is as we expect"

Modified: Prophet/branches/init-and-clone/t/simple-conflicting-merge.t
==============================================================================
--- Prophet/branches/init-and-clone/t/simple-conflicting-merge.t	(original)
+++ Prophet/branches/init-and-clone/t/simple-conflicting-merge.t	Sat Nov  8 03:33:23 2008
@@ -127,14 +127,14 @@
             original_source_uuid => undef,
             sequence_no          => undef,
             source_uuid          => undef,
-            changes              => [
-                {
+            changes              => {
+                $record_id => {
                     change_type  => 'update_file',
-                    record_uuid  => $record_id,
-                    record_type  => 'Bug',
+                    record_type    => 'Bug',
                     prop_changes => { status => { old_value => 'stalled', new_value => 'new' } }
-                }
-            ]
+                    }
+
+            }
         }
     );
 
@@ -167,28 +167,27 @@
             sequence_no          => undef,
             original_sequence_no => $alice->latest_sequence_no,
             original_source_uuid => replica_uuid_for('alice'),
-            changes              => [
-                {
-                    record_uuid  => $record_id,
-                    record_type  => 'Bug',
+            changes              => {
+                $record_id => {
+                    record_type    => 'Bug',
                     change_type  => 'update_file',
                     prop_changes => { status => { old_value => 'new', new_value => 'stalled' } }
                 },
-                {
+
+                replica_uuid_for('alice') => {
                     change_type  => 'update_file',
-                    record_uuid  => replica_uuid_for('alice'),
-                    record_type  => '_merge_tickets',
+                    record_type    => '_merge_tickets',
                     prop_changes => {
                         'last-changeset' => {
                             old_value => ($alice->latest_sequence_no-1),
                             new_value => $alice->latest_sequence_no
                         }
+                        }
+
                     }
 
                 }
 
-            ],
-
         },
         "yay. the last rev from alice synced right"
     );

Modified: Prophet/branches/init-and-clone/t/simple-push.t
==============================================================================
--- Prophet/branches/init-and-clone/t/simple-push.t	(original)
+++ Prophet/branches/init-and-clone/t/simple-push.t	Sat Nov  8 03:33:23 2008
@@ -94,8 +94,9 @@
             'original_source_uuid' => replica_uuid_for('bob'),
             'is_resolution'        => undef,
             'source_uuid'          => replica_uuid_for('bob'),
-            'changes'              => [
-                {   'change_type'  => 'add_file',
+            'changes'              => {
+                $openbug => {
+                    'change_type'  => 'add_file',
                     'prop_changes' => {
                         'from' => {
                             'new_value' => 'bob',
@@ -114,10 +115,9 @@
                             'old_value' => undef
                         },
                     },
-                    'record_uuid' => $openbug,
                     'record_type' => 'Bug'
                 }
-            ],
+            },
             'is_nullification' => undef,
         }
     ]
@@ -177,8 +177,9 @@
             'original_source_uuid' => replica_uuid_for('bob'),
             'is_resolution'        => undef,
             'source_uuid'          => replica_uuid_for('bob'),
-            'changes'              => [
-                {   'change_type'  => 'add_file',
+            'changes'              => {
+                $last_id => {
+                    'change_type'  => 'add_file',
                     'prop_changes' => {
                         'from' => {
                             'new_value' => 'bob',
@@ -197,10 +198,9 @@
                             'old_value' => undef,
                         },
                     },
-                    'record_uuid' => $last_id,
-                    'record_type' => 'Bug',
+                    'record_type' => 'Bug'
                 }
-            ],
+            },
             'is_nullification' => undef,
         }
     ];



More information about the Bps-public-commit mailing list