]> git.mjollnir.org Git - cil.git/commitdiff
Progress on #c98515e2, can now do 'depends-on' and 'precedes'.
authorAndrew Chilton <andychilton@gmail.com>
Tue, 1 Jul 2008 12:36:18 +0000 (00:36 +1200)
committerAndrew Chilton <andychilton@gmail.com>
Tue, 1 Jul 2008 12:36:18 +0000 (00:36 +1200)
bin/cil
etc/bash_completion.d/cil
issues/c_d87e016d.cil [new file with mode: 0644]
issues/i_c98515e2.cil
lib/CIL.pm
lib/CIL/Issue.pm

diff --git a/bin/cil b/bin/cil
index c29484c1587ee3c4db8a1093a4be6c632320789a..6c1e919912644a84fb728facaf39b07ae36098d8 100755 (executable)
--- a/bin/cil
+++ b/bin/cil
@@ -92,6 +92,7 @@ my %BOOLEAN_ARGS = (
        if @ARGV == 0;
 
     my $command = shift @ARGV;
+    $command =~ s{-}{_}gxms;
     no strict 'refs';
     if ( not defined &{"cmd_$command"} ) {
        Getopt::Mixed::abortMsg("'$command' is not a valid cil command.");
@@ -386,7 +387,7 @@ sub cmd_fsck {
             }
 
             # check that all it's comments are there and that they have this parent
-            my $comments = $i->Comments;
+            my $comments = $i->CommentList;
             foreach my $c ( @$comments ) {
                 # see if this comment exists at all
                 if ( exists $comment->{$c} ) {
@@ -400,7 +401,7 @@ sub cmd_fsck {
             }
 
             # check that all it's attachments are there and that they have this parent
-            my $attachments = $i->Attachments;
+            my $attachments = $i->AttachmentList;
             foreach my $a ( @$attachments ) {
                 # see if this attachment exists at all
                 if ( exists $attachment->{$a} ) {
@@ -550,6 +551,26 @@ sub cmd_am {
     }
 }
 
+sub cmd_depends_on {
+    my ($cil, undef, $issue_name, $depends_name) = @_;
+
+    my $issue = load_issue_fuzzy($cil, $issue_name);
+    my $depends = load_issue_fuzzy($cil, $depends_name);
+
+    $issue->add_depends_on( $depends->name );
+    $depends->add_precedes( $issue->name );
+
+    $issue->save($cil);
+    $depends->save($cil);
+}
+
+sub cmd_precedes {
+    my ($cil, undef, $issue_name, $depends_name) = @_;
+
+    # switch them round and call 'DependsOn'
+    cmd_depends_on($cil, undef, $depends_name, $issue_name);
+}
+
 ## ----------------------------------------------------------------------------
 # helpers
 
@@ -725,7 +746,7 @@ sub filter_issues {
         my @tmp;
         foreach my $issue ( @new_issues ) {
             push @tmp, $issue
-                if grep { $_ eq $args->{l} } @{$issue->Labels};
+                if grep { $_ eq $args->{l} } @{$issue->LabelList};
         }
         @new_issues = @tmp;
     }
@@ -790,7 +811,9 @@ sub display_issue_headers {
     field( 'AssignedTo', $issue->AssignedTo() );
     field( 'Inserted', $issue->Inserted() );
     field( 'Status', $issue->Status() );
-    field( 'Labels', join(' ', @{$issue->Label()}) );
+    field( 'Labels', join(' ', @{$issue->LabelList()}) );
+    field( 'DependsOn', join(' ', @{$issue->DependsOnList()}) );
+    field( 'Precedes', join(' ', @{$issue->PrecedesList()}) );
 }
 
 sub display_issue {
@@ -803,11 +826,15 @@ sub display_issue {
     field( 'CreatedBy', $issue->CreatedBy() );
     field( 'AssignedTo', $issue->AssignedTo() );
     field( 'Label', $_ )
-        foreach sort @{$issue->Label()};
+        foreach sort @{$issue->LabelList()};
     field( 'Comment', $_ )
-        foreach sort @{$issue->Comment()};
+        foreach sort @{$issue->CommentList()};
     field( 'Attachment', $_ )
-        foreach sort @{$issue->Attachment()};
+        foreach sort @{$issue->AttachmentList()};
+    field( 'DependsOn', $_ )
+        foreach sort @{$issue->DependsOnList()};
+    field( 'Precedes', $_ )
+        foreach sort @{$issue->PrecedesList()};
     field( 'Inserted', $issue->Inserted() );
     field( 'Updated', $issue->Inserted() );
     text('Description', $issue->Description());
@@ -825,6 +852,10 @@ sub display_issue_full {
     field( 'AssignedTo', $issue->AssignedTo() );
     field( 'Label', $_ )
         foreach sort @{$issue->Label()};
+    field( 'DependsOn', $_ )
+        foreach sort @{$issue->DependsOnList()};
+    field( 'Precedes', $_ )
+        foreach sort @{$issue->PrecedesList()};
     field( 'Inserted', $issue->Inserted() );
     field( 'Updated', $issue->Inserted() );
     text('Description', $issue->Description());
@@ -1033,6 +1064,21 @@ Shows the issue name with more detail.
 Shortcut so that you can set a new status on an issue without having to edit
 it.
 
+=item depends-on ISSUE1 ISSUE2
+
+Shortcut so that cil will add a 'DependsOn' from issue 1 to issue
+2. Conversley, issue 2 will also then contain a 'Precedes' pointer to issue 1.
+
+=item precedes ISSUE1 ISSUE2
+
+This is the exact opposite of C<depends-on> and is here for convenience and
+completeness. ie. issue 1 has to be completed before issue 2.
+
+=item status ISSUE NEW_STATUS
+
+Shortcut so that you can set a new status on an issue without having to edit
+it.
+
 =item edit ISSUE
 
 Edits the issue. If it changes, set the updates time to now.
index 3a570876e9e82527ec39701bb4e56c17670f5399..9c86338d09d1a2f4f3545bece9fc902d2d7c50e0 100644 (file)
@@ -38,7 +38,7 @@ _cil()
 
     # constants
     opts="--help --version --path --status --label --filename --is-open --is-closed --assigned-to --created-by"
-    commands="init add summary list show status edit comment attach extract"
+    commands="init add summary list show status depends-on precedes edit comment attach extract"
 
        COMPREPLY=()
        cur=${COMP_WORDS[COMP_CWORD]}
diff --git a/issues/c_d87e016d.cil b/issues/c_d87e016d.cil
new file mode 100644 (file)
index 0000000..e9bf8b1
--- /dev/null
@@ -0,0 +1,14 @@
+Issue: c98515e2
+CreatedBy: Andrew Chilton <andychilton@gmail.com>
+Inserted: 2008-07-01T12:16:51
+Updated: 2008-07-01T12:29:32
+
+Added the 'DependsOn' and 'Precedes' fields. These are automatically added when
+using the command line such as:
+
+   cil depends-on cafebabe feedface
+   cil precedes feedface cafebabe
+
+Both of these commands do the same thing.
+
+ToDo: add checks for this functionality into 'fsck'.
index d3c25e6acdd0e4e25ec21a57effe54b78cf61142..20b6178baad189ff2e5f65c86bdd05791e3a9040 100644 (file)
@@ -1,9 +1,10 @@
 Summary: Allow dependencies between issues
-Status: New
+Status: InProgress
 CreatedBy: Andrew Chilton <andychilton@gmail.com>
 AssignedTo: Andrew Chilton <andychilton@gmail.com>
+Comment: d87e016d
 Inserted: 2008-07-01T03:23:39
-Updated: 2008-07-01T03:30:14
+Updated: 2008-07-01T12:31:17
 
 Francois suggested that allowing dependencies between issues would be
 good. ie. this one here is dependent on that one over there (ie. the
index c0a55c6896ef72d1ffe09c4124dc42c10142294e..e2c9e649732213f937390d62392c8a758e75487a 100644 (file)
@@ -159,7 +159,7 @@ sub get_comments_for {
     my ($self, $issue) = @_;
 
     my @comments;
-    foreach my $comment_name ( @{$issue->Comments} ) {
+    foreach my $comment_name ( @{$issue->CommentList} ) {
         my $comment = CIL::Comment->new_from_name( $self, $comment_name );
         push @comments, $comment;
     }
@@ -174,7 +174,7 @@ sub get_attachments_for {
     my ($self, $issue) = @_;
 
     my @attachments;
-    foreach my $attachment_name ( @{$issue->Attachments} ) {
+    foreach my $attachment_name ( @{$issue->AttachmentList} ) {
         my $attachment = CIL::Attachment->new_from_name( $self, $attachment_name );
         push @attachments, $attachment;
     }
index d44626e874e8a89e0ada95f2dc4c79b16b05ab60..eff317fad32497ca1f8730e19930144088cf7b98 100644 (file)
@@ -31,14 +31,16 @@ use CIL::Utils;
 use base qw(CIL::Base);
 
 # fields specific to Issue
-__PACKAGE__->mk_accessors(qw(Summary Status AssignedTo Label Comment Attachment Description));
+__PACKAGE__->mk_accessors(qw(Summary Status AssignedTo DependsOn Precedes Label Comment Attachment Description));
 
-my @FIELDS = ( qw(Summary Status CreatedBy AssignedTo Label Comment Attachment Inserted Updated Description) );
+my @FIELDS = ( qw(Summary Status CreatedBy AssignedTo DependsOn Precedes Label Comment Attachment Inserted Updated Description) );
 my $cfg = {
     array => {
         Label      => 1,
         Comment    => 1,
         Attachment => 1,
+        DependsOn  => 1,
+        Precedes   => 1,
     },
 };
 
@@ -65,6 +67,8 @@ sub new {
         Label       => [],
         Comment     => [],
         Attachment  => [],
+        DependsOn   => [],
+        Precedes    => [],
         Description => '',
     };
     $self->{Changed} = 0;
@@ -109,7 +113,7 @@ sub is_valid {
 
     # see if we only allow certain Labels
     if ( $cil->LabelStrict ) {
-        my @labels = @{$self->Labels};
+        my @labels = @{$self->LabelList};
         foreach my $label ( @labels ) {
             unless ( exists $cil->LabelAllowed()->{$label} ) {
                 push @errors, "LabelStrict is turned on but this issue has an invalid label '$label'";
@@ -155,21 +159,51 @@ sub add_attachment {
     $self->flag_as_updated();
 }
 
-sub Labels {
+sub add_depends_on {
+    my ($self, $depends) = @_;
+
+    croak 'provide an issue name when adding a depends'
+        unless defined $depends;
+
+    push @{$self->{data}{DependsOn}}, $depends;
+    $self->flag_as_updated();
+}
+
+sub add_precedes {
+    my ($self, $precedes) = @_;
+
+    croak 'provide an issue name when adding a precedes'
+        unless defined $precedes;
+
+    push @{$self->{data}{Precedes}}, $precedes;
+    $self->flag_as_updated();
+}
+
+sub LabelList {
     my ($self) = @_;
     return $self->{data}{Label};
 }
 
-sub Comments {
+sub CommentList {
     my ($self) = @_;
     return $self->{data}{Comment};
 }
 
-sub Attachments {
+sub AttachmentList {
     my ($self) = @_;
     return $self->{data}{Attachment};
 }
 
+sub DependsOnList {
+    my ($self) = @_;
+    return $self->{data}{DependsOn};
+}
+
+sub PrecedesList {
+    my ($self) = @_;
+    return $self->{data}{Precedes};
+}
+
 sub is_open {
     my ($self, $cil) = @_;