]> git.mjollnir.org Git - cil.git/commitdiff
cil-f7ce705b: Now checks for DependsOn and Precedes before adding it
authorAndrew Chilton <andychilton@gmail.com>
Mon, 25 Jan 2010 01:34:17 +0000 (14:34 +1300)
committerAndrew Chilton <andychilton@gmail.com>
Mon, 25 Jan 2010 01:34:17 +0000 (14:34 +1300)
issues/c_1d9e3911.cil [new file with mode: 0644]
issues/i_f7ce705b.cil
lib/CIL/Base.pm
lib/CIL/Issue.pm

diff --git a/issues/c_1d9e3911.cil b/issues/c_1d9e3911.cil
new file mode 100644 (file)
index 0000000..58cc7e1
--- /dev/null
@@ -0,0 +1,12 @@
+Issue: f7ce705b
+CreatedBy: Andrew Chilton <andychilton@gmail.com>
+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.
index 4cb51f451c17587a7860b8a5d29137a4cf558724..87d03c48af04287040bc52adab4698070d6df0f7 100644 (file)
@@ -1,10 +1,11 @@
 Summary: Check for duplicate DependsOn and Precedes
-Status: New
+Status: Finished
 CreatedBy: Andrew Chilton <andychilton@gmail.com>
 AssignedTo: Andrew Chilton <andychilton@gmail.com>
 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.
 
index e273e2cc09827f2c8e4002c0840ade14dafb2193..34fba603b1b696e7a20f3cf1f900068c5ffdfcdf 100644 (file)
@@ -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 {
index 9d23d17d1dd5dd289579f88305975e0dcfad5844..c1360d0112f63d90a5db34b522d4de100fe5197e 100644 (file)
@@ -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 {