eigen_gen_credits.cpp File Reference
#include <string>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <map>
#include <list>

Classes

struct  contributor
 

Functions

std::string contributor_name (const std::string &line)
 
map< string, intcontributors_map_from_churn_output (const char *filename)
 
string lastname (const string &name)
 
void add_online_info_into_contributors_list (list< contributor > &contributors_list, const char *filename)
 
int main ()
 

Function Documentation

◆ add_online_info_into_contributors_list()

void add_online_info_into_contributors_list ( list< contributor > &  contributors_list,
const char filename 
)
120  {
121  string line;
122  ifstream online_info;
123  online_info.open(filename, ios::in);
124  while (!getline(online_info, line).eof()) {
125  string hgname, realname, url, misc;
126 
127  size_t last_bar = line.find_last_of('|');
128  if (last_bar == string::npos) continue;
129  if (last_bar < line.length()) misc = line.substr(last_bar + 1);
130  line.erase(last_bar);
131 
132  last_bar = line.find_last_of('|');
133  if (last_bar == string::npos) continue;
134  if (last_bar < line.length()) url = line.substr(last_bar + 1);
135  line.erase(last_bar);
136 
137  last_bar = line.find_last_of('|');
138  if (last_bar == string::npos) continue;
139  if (last_bar < line.length()) realname = line.substr(last_bar + 1);
140  line.erase(last_bar);
141 
142  hgname = line;
143 
144  // remove the example line
145  if (hgname.find("MercurialName") != string::npos) continue;
146 
147  list<contributor>::iterator it;
148  for (it = contributors_list.begin(); it != contributors_list.end() && it->name != hgname; ++it) {
149  }
150 
151  if (it == contributors_list.end()) {
152  contributor c;
153  c.name = realname;
154  c.url = url;
155  c.misc = misc;
156  contributors_list.push_back(c);
157  } else {
158  it->name = realname;
159  it->url = url;
160  it->misc = misc;
161  }
162  }
163 }
string filename
Definition: MergeRestartFiles.py:39
int c
Definition: calibrate.py:100
line
Definition: calibrate.py:103
Definition: eigen_gen_credits.cpp:108

References calibrate::c, MergeRestartFiles::filename, and calibrate::line.

Referenced by main().

◆ contributor_name()

std::string contributor_name ( const std::string &  line)
13  {
14  string result;
15 
16  // let's first take care of the case of isolated email addresses, like
17  // "user@localhost.localdomain" entries
18  if (line.find("markb@localhost.localdomain") != string::npos) {
19  return "Mark Borgerding";
20  }
21 
22  if (line.find("kayhman@contact.intra.cea.fr") != string::npos) {
23  return "Guillaume Saupin";
24  }
25 
26  // from there on we assume that we have a entry of the form
27  // either:
28  // Bla bli Blurp
29  // or:
30  // Bla bli Blurp <bblurp@email.com>
31 
32  size_t position_of_email_address = line.find_first_of('<');
33  if (position_of_email_address != string::npos) {
34  // there is an e-mail address in <...>.
35 
36  // Hauke once committed as "John Smith", fix that.
37  if (line.find("hauke.heibel") != string::npos)
38  result = "Hauke Heibel";
39  else {
40  // just remove the e-mail address
41  result = line.substr(0, position_of_email_address);
42  }
43  } else {
44  // there is no e-mail address in <...>.
45 
46  if (line.find("convert-repo") != string::npos)
47  result = "";
48  else
49  result = line;
50  }
51 
52  // remove trailing spaces
53  size_t length = result.length();
54  while (length >= 1 && result[length - 1] == ' ') result.erase(--length);
55 
56  return result;
57 }

References calibrate::line.

Referenced by contributors_map_from_churn_output().

◆ contributors_map_from_churn_output()

map<string, int> contributors_map_from_churn_output ( const char filename)
60  {
61  map<string, int> contributors_map;
62 
63  string line;
64  ifstream churn_out;
65  churn_out.open(filename, ios::in);
66  while (!getline(churn_out, line).eof()) {
67  // remove the histograms "******" that hg churn may draw at the end of some lines
68  size_t first_star = line.find_first_of('*');
69  if (first_star != string::npos) line.erase(first_star);
70 
71  // remove trailing spaces
72  size_t length = line.length();
73  while (length >= 1 && line[length - 1] == ' ') line.erase(--length);
74 
75  // now the last space indicates where the number starts
76  size_t last_space = line.find_last_of(' ');
77 
78  // get the number (of changesets or of modified lines for each contributor)
79  int number;
80  istringstream(line.substr(last_space + 1)) >> number;
81 
82  // get the name of the contributor
83  line.erase(last_space);
84  string name = contributor_name(line);
85 
86  map<string, int>::iterator it = contributors_map.find(name);
87  // if new contributor, insert
88  if (it == contributors_map.end()) contributors_map.insert(pair<string, int>(name, number));
89  // if duplicate, just add the number
90  else
91  it->second += number;
92  }
93  churn_out.close();
94 
95  return contributors_map;
96 }
std::string contributor_name(const std::string &line)
Definition: eigen_gen_credits.cpp:13
string name
Definition: plotDoE.py:33

References contributor_name(), MergeRestartFiles::filename, calibrate::line, and plotDoE::name.

Referenced by main().

◆ lastname()

string lastname ( const string &  name)
100  {
101  size_t last_space = name.find_last_of(' ');
102  if (last_space >= name.length() - 1)
103  return name;
104  else
105  return name.substr(last_space + 1);
106 }

References plotDoE::name.

Referenced by contributor::operator<().

◆ main()

int main ( )
165  {
166  // parse the hg churn output files
167  map<string, int> contributors_map_for_changedlines = contributors_map_from_churn_output("churn-changedlines.out");
168  // map<string,int> contributors_map_for_changesets = contributors_map_from_churn_output("churn-changesets.out");
169 
170  // merge into the contributors list
171  list<contributor> contributors_list;
172  map<string, int>::iterator it;
173  for (it = contributors_map_for_changedlines.begin(); it != contributors_map_for_changedlines.end(); ++it) {
174  contributor c;
175  c.name = it->first;
176  c.changedlines = it->second;
177  c.changesets = 0; // contributors_map_for_changesets.find(it->first)->second;
178  contributors_list.push_back(c);
179  }
180 
181  add_online_info_into_contributors_list(contributors_list, "online-info.out");
182 
183  contributors_list.sort();
184 
185  cout << "{| cellpadding=\"5\"\n";
186  cout << "!\n";
187  cout << "! Lines changed\n";
188  cout << "!\n";
189 
190  list<contributor>::iterator itc;
191  int i = 0;
192  for (itc = contributors_list.begin(); itc != contributors_list.end(); ++itc) {
193  if (itc->name.length() == 0) continue;
194  if (i % 2)
195  cout << "|-\n";
196  else
197  cout << "|- style=\"background:#FFFFD0\"\n";
198  if (itc->url.length())
199  cout << "| [" << itc->url << " " << itc->name << "]\n";
200  else
201  cout << "| " << itc->name << "\n";
202  if (itc->changedlines)
203  cout << "| " << itc->changedlines << "\n";
204  else
205  cout << "| (no information)\n";
206  cout << "| " << itc->misc << "\n";
207  i++;
208  }
209  cout << "|}" << endl;
210 }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
map< string, int > contributors_map_from_churn_output(const char *filename)
Definition: eigen_gen_credits.cpp:60
void add_online_info_into_contributors_list(list< contributor > &contributors_list, const char *filename)
Definition: eigen_gen_credits.cpp:120

References add_online_info_into_contributors_list(), calibrate::c, contributors_map_from_churn_output(), and i.