/*
* aegis - project change supervisor
* Copyright (C) 1998 Peter Miller;
* All rights reserved.
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
*
* MANIFEST: report the historical change cause against files
*/
auto script_name;
script_name = getenv("SCRIPT_NAME");
if (script_name == "")
script_name = "http://localhost/cgi-bin/aegis.cgi";
auto cause_map;
cause_map =
{
chain = "255+0+0";
internal_bug = "255+255+0";
external_bug = "192+192+0";
internal_enhancement = "0+255+0";
external_enhancement = "0+192+0";
internal_improvement = "0+255+255";
external_improvement = "0+192+192";
};
auto size_map;
size_map =
{
create = 12;
modify = 16;
remove = 8;
};
/*
* use the file prefix named on the command line
* or the top level if not specified
*/
auto prefix;
if (count(arg) == 0)
prefix = "";
else
prefix = arg[0] ## "/";
columns({width = 1000;});
print("Content-Type: text/html");
print("");
print("
");
print("Change Density by File");
print("");
print("Project ``" ## quote_html(project_name()) ## "'',");
print("
Change Density by File");
if (prefix != "")
print("
Directory ``" ## quote_html(prefix) ## "'',");
print("
");
auto ps;
ps = project[project_name()].state;
/*
* This will hold the cumulative statistics
* history[filename].is_a_directory
* history[filename].count[cause][action]
*/
auto remember;
remember = {};
/*
* scan the project files for context
*/
auto ph, cs, cf, max, filename, is_a_directory;
for (cf in ps.src)
{
if (cf.usage == build)
continue;
filename = cf.file_name;
if (prefix != "")
{
if (substr(filename, 0, length(prefix)) != prefix)
continue;
filename = substr(filename, length(prefix), 99999);
}
filename = split(filename, "/");
is_a_directory = (count(filename) > 1);
filename = filename[0];
if (typeof(remember[filename]) == "nul")
remember[filename] = { count = {}; total = 0; };
if (is_a_directory)
remember[filename].is_a_directory = true;
}
/*
* scan all completed changes
* for any of the named files
*/
max = 1;
for (ph in ps.branch.history)
{
cs = ps.branch.change[ph.change_number];
for (cf in cs.src)
{
if (cf.usage == build && cf.action == modify)
continue;
filename = cf.file_name;
if (prefix != "")
{
if (substr(filename, 0, length(prefix)) != prefix)
continue;
filename = substr(filename, length(prefix), 99999);
}
filename = split(filename, "/");
is_a_directory = (count(filename) > 1);
filename = filename[0];
if (typeof(remember[filename]) == "nul")
remember[filename] = { count = {}; total = 0; };
if (is_a_directory)
remember[filename].is_a_directory = true;
if (typeof(remember[filename].count[cs.cause]) == "nul")
remember[filename].count[cs.cause] = { total = 0; };
remember[filename].count[cs.cause].total++;
remember[filename].count[cs.cause][cf.action]++;
remember[filename].total++;
if (remember[filename].total > max)
max = remember[filename].total;
}
}
/*
* print the accumulated history
*/
max = 300.0 / max;
auto href;
auto cause, action;
auto width, height, clr;
print("");
for (filename in sort(keys(remember)))
{
cf = remember[filename];
if (cf.is_a_directory)
href = "densi";
else
href = "menu";
href = script_name ## "?file@file_" ## href ## "+" ##
quote_url(prefix ## filename) ## "+project@" ##
quote_url(project_name());
print("");
print("");
print("" ## quote_html(filename) ## "" ##
(cf.is_a_directory ? "/" : ""));
print(" | ");
print(cf.total);
print(" | ");
for (cause in [chain, internal_bug, internal_enhancement,
internal_improvement, external_bug, external_enhancement,
external_improvement])
{
for (action in [create, modify, remove])
{
clr = cause_map[cause];
if (clr == "")
clr = "191+191+191";
if (typeof(cf.count[cause]) == "nul")
cf.count[cause] = {};
width = cf.count[cause][action];
if (width <= 0)
continue;
width = round(width * max);
if (width < 3)
width = 3;
height = size_map[action];
if (height < 3)
height = 3;
href = script_name ## "?file@rect+" ## width ## "+" ##
height ## "+color+" ## clr;
print(" ");
}
}
print(" |
");
}
print("
");
print("
");
print("Legend
");
print("");
print("Create | Modify | Remove | Cause |
");
for (cause in [chain, internal_bug, internal_enhancement,
internal_improvement, external_bug, external_enhancement,
external_improvement])
{
print("");
clr = cause_map[cause];
width = 30;
for (action in [create, modify, remove])
{
print("");
height = size_map[action];
href = script_name ## "?file@rect+" ## width ## "+" ##
height ## "+color+" ## clr;
print(" ");
print(" | ");
}
print("");
print(cause);
print(" |
");
}
print("
");
print("
");
print("This page was generated " ## now() ## ".");
print("");