#uses "CtrlPv2Admin"
int versionColumn, statusColumn,
tagdateColumn;
string tmpFile;
main()
{
string
configFile = getPath(CONFIG_REL_PATH, "config");
string
vcs;
paCfgReadValue(configFile,
"ui", "versionControl", vcs);
paCfgReadValue(configFile,
"ui", "versionControlDiff", diffProgram);
if
( vcs != "CVS" ) return;
pvConnect("CVS_log",
"CVS log");
pvAddSeparator();
pvConnect("CVS_status",
"CVS status");
pvConnect("CVS_update",
"CVS update", "cvs_update");
versionColumn
= pvAddColumn("Version");
statusColumn
= pvAddColumn("Status");
tagdateColumn
= pvAddColumn("Tag/Date");
reload();
}
//----------------------------------------------------------------------
void reload()
{
CVS_entries(getPath(PANELS_REL_PATH));
CVS_entries(getPath(SCRIPTS_REL_PATH));
CVS_entries(getPath(LIBS_REL_PATH));
CVS_entries(getPath(PICTURES_REL_PATH));
CVS_entries(getPath(COLORDB_REL_PATH));
}
//----------------------------------------------------------------------
setTmpNam()
{
tmpFile
= tmpnam();
}
//----------------------------------------------------------------------
CVS_log(string fileName)
{
setTmpNam();
CVS_command("log
-N", fileName);
showResult(fileName);
}
//----------------------------------------------------------------------
CVS_update(string fileName)
{
setTmpNam();
CVS_command("update",
fileName);
showResult(fileName);
CVS_status(fileName);
}
//----------------------------------------------------------------------
CVS_status(string fileName)
{
bool
isDir = isDirectory(fileName);
setTmpNam();
CVS_command("status
-l", fileName); // non recursive as we only
get
filenames without path
file
fd = fopen(tmpFile, "r");
string
line, currentFile, version, status;
int
pos;
bool
gotFile = false;
while
( ! feof(fd) && (fgets(line, 1000, fd) > 0) )
{
if
( !gotFile )
{
if
( line[0] == '?' ) // file not in CVS
{
currentFile
= baseName(substr(line, 2));
pvSetItemText(fileName
+ (isDir ? ("/" + currentFile) : ""),
statusColumn, "not in CVS");
continue;
}
pos
= strpos(line, "File: ");
if
( pos != 0 ) continue;
gotFile
= true;
sscanf(line,
"File: %s", currentFile);
pos
= strpos(line, "Status:");
status
= substr(line, pos + strlen("Status:"));
pvSetItemText(fileName
+ (isDir ? ("/" + currentFile) : ""),
statusColumn, status);
}
pos
= strpos(line, "Working revision:");
if
( pos == -1 ) continue;
sscanf(substr(line,
pos+strlen("Working revision:")), "%s", version);
if
( version == "No" ) // No entry for ...
{
pvSetItemText(fileName
+ (isDir ? ("/" + currentFile) : ""),
statusColumn, "not in CVS");
}
else
{
pvSetItemText(fileName
+ (isDir ? ("/" + currentFile) : ""),
versionColumn, version);
gotFile
= false;
}
}
fclose(fd);
remove(tmpFile);
if
( isDir ) // recursion
{
dyn_string
files = getFileNamesRev(fileName, "CVS", FILTER_DIRS);
for
(int i = 1; i <= dynlen(files); i++)
if
( (files[i] != ".") && (files[i] != "..")
)
CVS_status(fileName
+ "/" + files[i]);
}
|