//
// aegis - project change supervisor
// Copyright (C) 2004-2008, 2012, 2014 Peter Miller
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
//
#include
#include
#include
#include
#include
#include
#include
#include
#include
void
change_identifier_subset::set_change_number(long number)
{
trace(("change_identifier_subset::set_change_number(%ld)\n{\n", number));
change_identifier_subset::invalidate_meta_data();
change_number = number;
trace(("}\n"));
}
void
change_identifier_subset::create_new_change_set(void)
{
create_new_change_set_flag = true;
}
void
change_identifier_subset::set_change(void)
{
trace(("change_identifier_subset::set_change()\n{\n"));
assert(!cp);
if (baseline)
{
cp = pid.get_pp()->change_get();
trace(("baseline\n"));
trace(("}\n"));
return;
}
if (create_new_change_set_flag)
{
if
(
change_number == 0
||
project_change_number_in_use(pid.get_pp(), change_number)
)
{
change_number = project_next_change_number(pid.get_pp(), true);
}
cp = change::create(pid.get_pp(), change_number);
cp->bind_new();
cstate_ty *cstate_data = cp->cstate_get();
cstate_data->state = cstate_state_awaiting_development;
return;
}
//
// it is an error if the delta does not exist
//
if (!delta_name.empty())
{
change_number =
project_history_change_by_name
(
pid.get_pp(),
delta_name.get_ref(),
0
);
trace(("delta \"%s\" == change %ld\n", delta_name.c_str(),
change_number));
delta_name = "";
}
if (delta_date != NO_TIME_SET)
{
//
// If the time is in the future, you could get a different
// answer for the same input at some point in the future.
//
// This is the "time safe" quality first described by
// Damon Poole
//
if (delta_date > now())
project_error(pid.get_pp(), 0, i18n("date in the future"));
//
// Now find the change number corresponding.
//
change_number =
project_history_change_by_timestamp(pid.get_pp(), delta_date);
trace(("delta date %ld == change %ld\n", (long)delta_date,
change_number));
}
if (delta_number >= 0)
{
// does not return if no such delta number
change_number =
project_history_change_by_delta(pid.get_pp(), delta_number);
trace(("delta %ld == change %ld\n", delta_number, change_number));
delta_number = 0;
}
//
// locate change data
//
if (!change_number)
{
change_number = get_up()->default_change(get_pp());
trace(("change %ld\n", change_number));
}
cp = change::create(pid.get_pp(), change_number);
cp->bind_existing();
trace(("}\n"));
}
// vim: set ts=8 sw=4 et :