1 //
2 //      aegis - project change supervisor
3 //      Copyright (C) 1999, 2002-2008, 2012 Peter Miller
4 //
5 //      This program is free software; you can redistribute it and/or modify
6 //      it under the terms of the GNU General Public License as published by
7 //      the Free Software Foundation; either version 3 of the License, or
8 //      (at your option) any later version.
9 //
10 //      This program is distributed in the hope that it will be useful,
11 //      but WITHOUT ANY WARRANTY; without even the implied warranty of
12 //      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 //      GNU General Public License for more details.
14 //
15 //      You should have received a copy of the GNU General Public License
16 //      along with this program. If not, see
17 //      <http://www.gnu.org/licenses/>.
18 //
19 
20 #include <common/ac/assert.h>
21 
22 #include <common/trace.h>
23 #include <common/uuidentifier.h>
24 #include <libaegis/change/cstate/improve.h>
25 
26 
27 void
change_cstate_improve(cstate_ty * d)28 change_cstate_improve(cstate_ty *d)
29 {
30     trace(("improve(d = %p)\n{\n", d));
31     if (!d->history)
32     {
33         d->history = (cstate_history_list_ty *)cstate_history_list_type.alloc();
34     }
35     assert(!d->src);
36     if (!(d->mask & cstate_regression_test_exempt_mask))
37     {
38         d->regression_test_exempt =
39             (
40                 d->cause != change_cause_internal_improvement
41             &&
42                 d->cause != change_cause_external_improvement
43             );
44     }
45     if (!d->architecture)
46     {
47         d->architecture =
48             (cstate_architecture_list_ty *)
49             cstate_architecture_list_type.alloc();
50     }
51     if (!d->architecture->length)
52     {
53         meta_type               *type_p;
54         string_ty       **str_p;
55 
56         str_p =
57             (string_ty **)
58             cstate_architecture_list_type.list_parse(d->architecture, &type_p);
59         assert(type_p == &string_type);
60         *str_p = str_from_c("unspecified");
61     }
62     if (d->branch)
63     {
64         if (!(d->branch->mask & cstate_branch_umask_mask))
65             d->branch->umask = DEFAULT_UMASK;
66         d->branch->umask = (d->branch->umask & 5) | 022;
67         if (d->branch->umask == 023)
68             d->branch->umask = 022;
69         // 022, 026 and 027 are OK
70 
71         if (!(d->branch->mask & cstate_branch_reuse_change_numbers_mask))
72         {
73             d->branch->reuse_change_numbers = true;
74             d->branch->mask |= cstate_branch_reuse_change_numbers_mask;
75         }
76 
77         if (!(d->branch->mask &
78             cstate_branch_default_test_regression_exemption_mask))
79         {
80             d->branch->default_test_regression_exemption = true;
81             d->branch->mask |=
82                 cstate_branch_default_test_regression_exemption_mask;
83         }
84     }
85     switch (d->state)
86     {
87     case cstate_state_awaiting_development:
88     case cstate_state_being_developed:
89     case cstate_state_awaiting_review:
90     case cstate_state_being_reviewed:
91     case cstate_state_awaiting_integration:
92         break;
93 
94     case cstate_state_being_integrated:
95     case cstate_state_completed:
96         if (!d->delta_uuid)
97         {
98             //
99             // This is for backwards compatibility.  If anything causes
100             // the change set to be written out, this will stick.  On
101             // the other hand, if the change set isn't written back, the
102             // change will have a different delta_uuid every time.  In
103             // some cases users may notice this randomness, but they
104             // probably will not.
105             //
106             d->delta_uuid = universal_unique_identifier();
107         }
108         break;
109     }
110     trace(("}\n"));
111 }
112 
113 
114 // vim: set ts=8 sw=4 et :
115