Revision: 76561
http://sourceforge.net/p/brlcad/code/76561
Author: starseeker
Date: 2020-07-28 19:39:32 +0000 (Tue, 28 Jul 2020)
Log Message:
-----------
First cut at incorporating the CVS generated information into commit messages.
Modified Paths:
--------------
brlcad/trunk/misc/repowork/README
brlcad/trunk/misc/repowork/commit.cpp
brlcad/trunk/misc/repowork/repowork.cpp
brlcad/trunk/misc/repowork/repowork.h
Modified: brlcad/trunk/misc/repowork/README
===================================================================
--- brlcad/trunk/misc/repowork/README 2020-07-28 15:30:19 UTC (rev 76560)
+++ brlcad/trunk/misc/repowork/README 2020-07-28 19:39:32 UTC (rev 76561)
@@ -38,3 +38,9 @@
* Enabling all features:
./repowork -t -w -n -r brlcad.git -e brlcad_map -s rev_map --cvs-ids
cvs_problem_sha1.txt --children children.txt ~/brlcad.fi final.fi
+
+* Adding CVS info:
+
+./repowork -t -n -r brlcad.git --keymap msgtime_sha1_map --cvs-auth-map
key_authormap --cvs-branch-map key_branchmap brlcad_input.
+fi test.fi
+
Modified: brlcad/trunk/misc/repowork/commit.cpp
===================================================================
--- brlcad/trunk/misc/repowork/commit.cpp 2020-07-28 15:30:19 UTC (rev
76560)
+++ brlcad/trunk/misc/repowork/commit.cpp 2020-07-28 19:39:32 UTC (rev
76561)
@@ -169,6 +169,9 @@
line.erase(0, 13); // Remove "original-oid " prefix
cd->id.sha1 = line;
cd->s->have_sha1s = true;
+ if (cd->s->sha12key.find(cd->id.sha1) != cd->s->sha12key.end()) {
+ std::cout << "Have CVS info for commit " << cd->id.sha1 << "\n";
+ }
return 0;
}
@@ -487,6 +490,25 @@
}
}
+ // Check for CVS information to add
+ if (c->s->sha12key.find(c->id.sha1) != c->s->sha12key.end()) {
+ std::string cvsmsg = nmsg;
+ std::string key = c->s->sha12key[c->id.sha1];
+ if (c->s->key2cvsbranch.find(key) != c->s->key2cvsbranch.end()) {
+ //std::cout << "Found branch: " << c->s->key2cvsbranch[key] << "\n";
+ cvsmsg.append("cvs:branch:");
+ cvsmsg.append(c->s->key2cvsbranch[key]);
+ cvsmsg.append("\n");
+ }
+ if (c->s->key2cvsauthor.find(key) != c->s->key2cvsauthor.end()) {
+ //std::cout << "Found author: " << c->s->key2cvsauthor[key] << "\n";
+ cvsmsg.append("cvs:account:");
+ cvsmsg.append(c->s->key2cvsauthor[key]);
+ cvsmsg.append("\n");
+ }
+ nmsg = cvsmsg;
+ }
+
return nmsg;
}
Modified: brlcad/trunk/misc/repowork/repowork.cpp
===================================================================
--- brlcad/trunk/misc/repowork/repowork.cpp 2020-07-28 15:30:19 UTC (rev
76560)
+++ brlcad/trunk/misc/repowork/repowork.cpp 2020-07-28 19:39:32 UTC (rev
76561)
@@ -227,6 +227,84 @@
}
void
+read_key_sha1_map(git_fi_data *s, std::string &keysha1file)
+{
+ std::ifstream infile(keysha1file, std::ifstream::binary);
+ if (!infile.good()) {
+ std::cerr << "Could not open file: " << keysha1file << "\n";
+ exit(-1);
+ }
+ std::string line;
+ while (std::getline(infile, line)) {
+ if (!line.length()) continue;
+ size_t cpos = line.find_first_of(":");
+ std::string key = line.substr(0, cpos);
+ std::string sha1 = line.substr(cpos+1, std::string::npos);
+ s->sha12key[sha1] = key;
+ s->key2sha1[key] = sha1;
+ }
+ infile.close();
+}
+
+void
+read_key_cvsbranch_map(
+ git_fi_data *s,
+ std::string &branchfile)
+{
+ std::map<std::string, std::string> key2branch;
+ std::ifstream infile(branchfile, std::ifstream::binary);
+ if (!infile.good()) {
+ std::cerr << "Could not open file: " << branchfile << "\n";
+ exit(-1);
+ }
+ std::string line;
+ while (std::getline(infile, line)) {
+ if (!line.length()) continue;
+ size_t cpos = line.find_first_of(":");
+ std::string key = line.substr(0, cpos);
+ std::string branch = line.substr(cpos+1, std::string::npos);
+ if (key2branch.find(key) != key2branch.end()) {
+ std::string oldbranch = key2branch[key];
+ if (oldbranch != branch) {
+ std::cout << "WARNING: non-unique key maps to both branch " <<
oldbranch << " and branch " << branch << ", overriding\n";
+ }
+ }
+ if (s->key2sha1.find(key) != s->key2sha1.end()) {
+ s->key2cvsbranch[key] = branch;
+ }
+ }
+ infile.close();
+}
+
+void
+read_key_cvsauthor_map( git_fi_data *s, std::string &authorfile)
+{
+ std::map<std::string, std::string> key2author;
+ std::ifstream infile(authorfile, std::ifstream::binary);
+ if (!infile.good()) {
+ std::cerr << "Could not open file: " << authorfile << "\n";
+ exit(-1);
+ }
+ std::string line;
+ while (std::getline(infile, line)) {
+ if (!line.length()) continue;
+ size_t cpos = line.find_first_of(":");
+ std::string key = line.substr(0, cpos);
+ std::string author = line.substr(cpos+1, std::string::npos);
+ if (key2author.find(key) != key2author.end()) {
+ std::string oldauthor = key2author[key];
+ if (oldauthor != author) {
+ std::cout << "WARNING: non-unique key maps to both author " <<
oldauthor << " and author " << author << ", overriding\n";
+ }
+ }
+ if (s->key2sha1.find(key) != s->key2sha1.end()) {
+ s->key2cvsauthor[key] = author;
+ }
+ }
+ infile.close();
+}
+
+void
process_ls_tree(std::string &sha1)
{
// read children
@@ -443,6 +521,9 @@
std::string repo_path;
std::string email_map;
std::string svn_map;
+ std::string cvs_auth_map;
+ std::string cvs_branch_map;
+ std::string keymap;
std::string children_file;
std::string cvs_id_file;
int cwidth = 72;
@@ -457,6 +538,10 @@
("e,email-map", "Specify replacement username+email mappings (one
map per line, format is commit-id-1;commit-id-2)",
cxxopts::value<std::vector<std::string>>(), "map file")
("s,svn-map", "Specify svn rev -> committer map (one mapping per
line, format is commit-rev name)", cxxopts::value<std::vector<std::string>>(),
"map file")
+ ("cvs-auth-map", "msg&time -> cvs author map (needs sha1->key
map)", cxxopts::value<std::vector<std::string>>(), "file")
+ ("cvs-branch-map", "msg&time -> cvs branch map (needs sha1->key
map)", cxxopts::value<std::vector<std::string>>(), "file")
+ ("keymap", "sha1 -> msg&time map (needs original-oid tags)",
cxxopts::value<std::vector<std::string>>(), "file")
+
("t,trim-whitespace", "Trim extra spaces and end-of-line characters
from the end of commit messages", cxxopts::value<bool>(trim_whitespace))
("w,wrap-commit-lines", "Wrap long commit lines to 72 cols (won't
wrap messages already having multiple non-empty lines)",
cxxopts::value<bool>(wrap_commit_lines))
("width", "Column wrapping width (if enabled)",
cxxopts::value<int>(), "N")
@@ -463,9 +548,9 @@
("r,repo", "Original git repository path (must support running git
log)", cxxopts::value<std::vector<std::string>>(), "path")
("n,collapse-notes", "Take any git-notes contents and append them
to regular commit messages.", cxxopts::value<bool>(collapse_notes))
-
+
("children", "File with output of \"git rev-list --children
--all\"", cxxopts::value<std::vector<std::string>>(), "file")
- ("cvs-ids", "Specify CVS era commits (revision number or SHA1) to
rebuild. Requires git-repo be set as well. Needs --show-original-ids
information in fast import file", cxxopts::value<std::vector<std::string>>(),
"file")
+ ("cvs-rebuild-ids", "Specify CVS era commits (revision number or
SHA1) to rebuild. Requires git-repo be set as well. Needs --show-original-ids
information in fast import file", cxxopts::value<std::vector<std::string>>(),
"file")
("h,help", "Print help")
;
@@ -502,12 +587,30 @@
children_file = ff[0];
}
- if (result.count("cvs-ids"))
+ if (result.count("cvs-rebuild-ids"))
{
- auto& ff = result["cvs-ids"].as<std::vector<std::string>>();
+ auto& ff = result["cvs-rebuild-ids"].as<std::vector<std::string>>();
cvs_id_file = ff[0];
}
+ if (result.count("cvs-auth-map"))
+ {
+ auto& ff = result["cvs-auth-map"].as<std::vector<std::string>>();
+ cvs_auth_map = ff[0];
+ }
+
+ if (result.count("cvs-branch-map"))
+ {
+ auto& ff = result["cvs-branch-map"].as<std::vector<std::string>>();
+ cvs_branch_map = ff[0];
+ }
+
+ if (result.count("keymap"))
+ {
+ auto& ff = result["keymap"].as<std::vector<std::string>>();
+ keymap = ff[0];
+ }
+
if (result.count("width"))
{
cwidth = result["width"].as<int>();
@@ -554,6 +657,26 @@
git_unpack_notes(&fi_data, infile, repo_path);
}
+ if (keymap.length()) {
+ read_key_sha1_map(&fi_data, keymap);
+ }
+
+ if (cvs_auth_map.length()) {
+ if (!keymap.length()) {
+ std::cerr << "CVS author map specified without key map\n";
+ return -1;
+ }
+ read_key_cvsauthor_map(&fi_data, cvs_auth_map);
+ }
+
+ if (cvs_branch_map.length()) {
+ if (!keymap.length()) {
+ std::cerr << "CVS branch map specified without key map\n";
+ return -1;
+ }
+ read_key_cvsbranch_map(&fi_data, cvs_branch_map);
+ }
+
if (email_map.length()) {
// Reset the input stream
infile.clear();
Modified: brlcad/trunk/misc/repowork/repowork.h
===================================================================
--- brlcad/trunk/misc/repowork/repowork.h 2020-07-28 15:30:19 UTC (rev
76560)
+++ brlcad/trunk/misc/repowork/repowork.h 2020-07-28 19:39:32 UTC (rev
76561)
@@ -99,6 +99,9 @@
// to the existing notes-based info to id SVN usernames
std::string svn_id;
std::string svn_committer;
+
+ std::string cvs_id;
+ std::string cvs_branch;
};
class git_tag_data {
@@ -180,6 +183,13 @@
// We also need to be able to translate SVN revs into sha1s
std::map<std::string, std::string> rev_to_sha1;
+
+ // Containers holding information specific to CVS
+ std::map<std::string, std::string> sha12key;
+ std::map<std::string, std::string> key2sha1;
+ std::map<std::string, std::string> key2cvsauthor;
+ std::map<std::string, std::string> key2cvsbranch;
+
private:
long mark = -1;
};
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits