[Bps-public-commit] Prophet branch, master, updated. 0.69_01-47-g46232c4
jesse
jesse at bestpractical.com
Thu Sep 3 15:40:57 EDT 2009
The branch, master has been updated
via 46232c4da447e61c03ff62970af3161971bab70c (commit)
via 2fa7a52934c77eced67da7362e9f5ac28bfedd6f (commit)
via 61a658203fa22c16d01848ce841c8287708f8c56 (commit)
via 2f112cc476ae8c2936e86149bfb8fa7a47c40ff9 (commit)
via a0138432f6b899010a6e5ec34c1fada7638d4672 (commit)
from 8c0dd82e7c7ca92b3563b81e1c4e1fddb951cb10 (commit)
Summary of changes:
lib/Prophet/App.pm | 1 +
lib/Prophet/FilesystemReplica.pm | 12 ++++++++++--
lib/Prophet/Replica.pm | 3 ++-
lib/Prophet/Replica/sqlite.pm | 23 +++++++++++++++++++----
t/local_metadata.t | 15 +++++++++++++++
5 files changed, 47 insertions(+), 7 deletions(-)
create mode 100644 t/local_metadata.t
- Log -----------------------------------------------------------------
commit a0138432f6b899010a6e5ec34c1fada7638d4672
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Thu Sep 3 12:48:58 2009 -0400
Failing tests proving that local metadata isn't case insensitive
diff --git a/t/local_metadata.t b/t/local_metadata.t
new file mode 100644
index 0000000..773c80e
--- /dev/null
+++ b/t/local_metadata.t
@@ -0,0 +1,15 @@
+use Prophet::Test tests => 6;
+
+as_alice {
+ my $cli = Prophet::CLI->new();
+ $cli->handle->initialize;
+
+ ok($cli->handle->store_local_metadata( foo => 'bar'));
+ is($cli->handle->fetch_local_metadata( 'Foo' ), 'bar');
+ ok($cli->handle->store_local_metadata( Foo => 'bartwo'));
+ is($cli->handle->fetch_local_metadata( 'foo' ), 'bartwo');
+ ok($cli->handle->store_local_metadata( foo => 'barTwo'));
+ is($cli->handle->fetch_local_metadata( 'foo' ), 'barTwo');
+
+};
+
commit 2f112cc476ae8c2936e86149bfb8fa7a47c40ff9
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Thu Sep 3 12:51:19 2009 -0400
Prophet::FilesystemReplia's local metadata is now case insensitive
diff --git a/lib/Prophet/FilesystemReplica.pm b/lib/Prophet/FilesystemReplica.pm
index 12d3cf6..3de5e9e 100644
--- a/lib/Prophet/FilesystemReplica.pm
+++ b/lib/Prophet/FilesystemReplica.pm
@@ -290,7 +290,7 @@ sub store_local_metadata {
my $key = shift;
my $value = shift;
$self->_write_file(
- path =>File::Spec->catfile( $self->local_metadata_dir, $key),
+ path =>File::Spec->catfile( $self->local_metadata_dir, lc($key)),
content => $value,
);
@@ -300,7 +300,15 @@ sub store_local_metadata {
sub fetch_local_metadata {
my $self = shift;
my $key = shift;
- $self->_read_file(File::Spec->catfile($self->local_metadata_dir, $key));
+ # local metadata files used to (incorrectly) be treated as case sensitive.
+ # The code below tries to make sure that we don't lose historical data as we fix this
+ # If there's a new-style all-lowercase file, read that first. If there isn't,
+ # try to read an old-style sensitive file
+
+ my $insensitive_file = File::Spec->catfile($self->local_metadata_dir, lc($key));
+ my $sensitive_file = File::Spec->catfile($self->local_metadata_dir, $key);
+
+ return $self->_read_file($insensitive_file) || $self->_read_file($sensitive_file);
}
commit 61a658203fa22c16d01848ce841c8287708f8c56
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Thu Sep 3 15:38:34 2009 -0400
Prophet::App now has a friendly name for "was asked to characterize an undef replica"
diff --git a/lib/Prophet/App.pm b/lib/Prophet/App.pm
index 18c254a..6d22426 100644
--- a/lib/Prophet/App.pm
+++ b/lib/Prophet/App.pm
@@ -259,6 +259,7 @@ sub display_name_for_replica {
my $self = shift;
my $uuid = shift;
+ return 'Unknown replica!' unless $uuid;
my %possibilities = $self->config->get_regexp( key => '^replica\..*\.uuid$' );
# form a hash of uuid -> name
my %sources_by_uuid = map {
commit 2fa7a52934c77eced67da7362e9f5ac28bfedd6f
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Thu Sep 3 15:39:49 2009 -0400
Made an "is this replica me?" query case insensitive.
diff --git a/lib/Prophet/Replica.pm b/lib/Prophet/Replica.pm
index a4cfe7d..b509631 100644
--- a/lib/Prophet/Replica.pm
+++ b/lib/Prophet/Replica.pm
@@ -485,10 +485,11 @@ sub has_seen_changeset {
$self->display_name_for_replica($args{source_uuid}));
# If the changeset originated locally, we never want it
- if ($args{source_uuid} eq $self->uuid ) {
+ if (lc($args{source_uuid}) eq lc($self->uuid) ) {
$self->log_debug("\t - We have. (It originated locally.)");
return 1
}
+
# Otherwise, if the we have a merge ticket from the source, we don't want
# the changeset if the source's sequence # is >= the changeset's sequence
# #, we can safely skip it
commit 46232c4da447e61c03ff62970af3161971bab70c
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Thu Sep 3 15:40:21 2009 -0400
Made sure that sqlite replicas userdata keys are always lowercase
diff --git a/lib/Prophet/Replica/sqlite.pm b/lib/Prophet/Replica/sqlite.pm
index 4b12cd3..c09ffd7 100644
--- a/lib/Prophet/Replica/sqlite.pm
+++ b/lib/Prophet/Replica/sqlite.pm
@@ -155,6 +155,7 @@ sub _check_for_upgrades {
my $self = shift;
if ( $self->replica_version && $self->replica_version < 2) { $self->_upgrade_replica_to_v2(); }
if ( $self->replica_version && $self->replica_version < 3) { $self->_upgrade_replica_to_v3(); }
+ if ( $self->replica_version && $self->replica_version < 4) { $self->_upgrade_replica_to_v4(); }
}
@@ -166,6 +167,7 @@ sub __fetch_data {
my $table = shift;
my $key = shift;
+ $key = lc($key);
my $sth = $self->dbh->prepare("SELECT value FROM $table WHERE key = ?");
$sth->execute($key);
@@ -175,10 +177,11 @@ sub __fetch_data {
sub __store_data {
my $self = shift;
- my %args = ( key => undef, value => undef, table => undef, @_);
- $self->dbh->do("DELETE FROM $args{table} WHERE key = ?", {},$args{key});
- $self->dbh->do("INSERT INTO $args{table} (key,value) VALUES(?,?)", {}, $args{key}, $args{value});
-
+ my %args = validate(@_, { key => 1, value => 1, table => 1});
+ $args{key} = lc($args{key});
+ $self->dbh->do( "DELETE FROM $args{table} WHERE key = ?", {}, $args{key} );
+ $self->dbh->do( "INSERT INTO $args{table} (key,value) VALUES(?,?)", {}, $args{key}, $args{value} );
+
}
sub fetch_local_metadata {
@@ -975,10 +978,22 @@ sub _upgrade_replica_to_v3 {
],
version => 3
);
+}
+
+
+sub _upgrade_replica_to_v4 {
+ my $self = shift;
+ $self->_do_db_upgrades(
+ statements => [
+ q{UPDATE userdata SET key = lower(key)}
+ ],
+ version => 4
+ );
}
+
sub _do_db_upgrades {
my $self = shift;
my %args = (
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list