From 32c16fd7dfecd841a8b094cca0446d5b726b9ecf Mon Sep 17 00:00:00 2001 From: Andrew Chilton Date: Mon, 25 Jan 2010 14:34:17 +1300 Subject: [PATCH] cil-f7ce705b: Now checks for DependsOn and Precedes before adding it --- issues/c_1d9e3911.cil | 12 ++++++++++++ issues/i_f7ce705b.cil | 5 +++-- lib/CIL/Base.pm | 6 ++---- lib/CIL/Issue.pm | 14 ++++++++++---- 4 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 issues/c_1d9e3911.cil diff --git a/issues/c_1d9e3911.cil b/issues/c_1d9e3911.cil new file mode 100644 index 0000000..58cc7e1 --- /dev/null +++ b/issues/c_1d9e3911.cil @@ -0,0 +1,12 @@ +Issue: f7ce705b +CreatedBy: Andrew Chilton +Inserted: 2010-01-25T01:31:35 +Updated: 2010-01-25T01:31:35 + +Checks the DependsOn and Precedes so it checks first before adding the other +issue. + +Also, since flag_as_updated() wasn't doing the Updated time, now calls +set_updated_now(). + +Finally, set_no_update() changed to be more sane. diff --git a/issues/i_f7ce705b.cil b/issues/i_f7ce705b.cil index 4cb51f4..87d03c4 100644 --- a/issues/i_f7ce705b.cil +++ b/issues/i_f7ce705b.cil @@ -1,10 +1,11 @@ Summary: Check for duplicate DependsOn and Precedes -Status: New +Status: Finished CreatedBy: Andrew Chilton AssignedTo: Andrew Chilton Label: Milestone-v0.07 +Comment: 1d9e3911 Inserted: 2010-01-24T11:08:48 -Updated: 2010-01-24T11:15:59 +Updated: 2010-01-25T01:33:36 Cil allows the addition of duplicate precedes. This shouldn't be allowed. diff --git a/lib/CIL/Base.pm b/lib/CIL/Base.pm index e273e2c..34fba60 100644 --- a/lib/CIL/Base.pm +++ b/lib/CIL/Base.pm @@ -74,6 +74,7 @@ sub new_from_data { $self->set_no_update($field, $data->{$field}); } $self->set_no_update('Changed', 0); + $self->set_no_update('Updated', $data->{Updated}); return $self; } @@ -171,10 +172,7 @@ sub set { # so that we can update fields without 'Updated' being changed sub set_no_update { my ($self, $field, $value) = @_; - - my $saved_update_time = $self->Updated; - $self->set( $field, $value ); - $self->Updated( $saved_update_time ); + $self->{data}{$field} = $value; } sub set_inserted_now { diff --git a/lib/CIL/Issue.pm b/lib/CIL/Issue.pm index 9d23d17..c1360d0 100644 --- a/lib/CIL/Issue.pm +++ b/lib/CIL/Issue.pm @@ -139,7 +139,7 @@ sub add_label { return if grep { $_ eq $label } @{$self->{data}{Label}}; push @{$self->{data}{Label}}, $label; - $self->flag_as_updated(); + $self->set_updated_now(); } sub remove_label { @@ -150,7 +150,7 @@ sub remove_label { # remove this label @{$self->{data}{Label}} = grep { $_ ne $label } @{$self->{data}{Label}}; - $self->flag_as_updated(); + $self->set_updated_now(); } sub add_comment { @@ -183,8 +183,11 @@ sub add_depends_on { croak 'provide an issue name when adding a depends' unless defined $depends; + # return if we already have this depends + return if grep { $_ eq $depends } @{$self->{data}{DependsOn}}; + push @{$self->{data}{DependsOn}}, $depends; - $self->flag_as_updated(); + $self->set_updated_now(); } sub add_precedes { @@ -193,8 +196,11 @@ sub add_precedes { croak 'provide an issue name when adding a precedes' unless defined $precedes; + # return if we already have this precedes + return if grep { $_ eq $precedes } @{$self->{data}{Precedes}}; + push @{$self->{data}{Precedes}}, $precedes; - $self->flag_as_updated(); + $self->set_updated_now(); } sub LabelList { -- 2.39.5