1225 |
17 Oct 10 |
peter |
1 |
#ifndef _theplu_svndigest_copyright_visitor_ |
1225 |
17 Oct 10 |
peter |
2 |
#define _theplu_svndigest_copyright_visitor_ |
1225 |
17 Oct 10 |
peter |
3 |
|
1225 |
17 Oct 10 |
peter |
// $Id$ |
1225 |
17 Oct 10 |
peter |
5 |
|
1225 |
17 Oct 10 |
peter |
6 |
/* |
1635 |
30 Mar 23 |
peter |
Copyright (C) 2010, 2011 Peter Johansson |
1225 |
17 Oct 10 |
peter |
8 |
|
1225 |
17 Oct 10 |
peter |
This file is part of svndigest, http://dev.thep.lu.se/svndigest |
1225 |
17 Oct 10 |
peter |
10 |
|
1225 |
17 Oct 10 |
peter |
svndigest is free software; you can redistribute it and/or modify it |
1225 |
17 Oct 10 |
peter |
under the terms of the GNU General Public License as published by |
1225 |
17 Oct 10 |
peter |
the Free Software Foundation; either version 3 of the License, or |
1225 |
17 Oct 10 |
peter |
(at your option) any later version. |
1225 |
17 Oct 10 |
peter |
15 |
|
1225 |
17 Oct 10 |
peter |
svndigest is distributed in the hope that it will be useful, but |
1225 |
17 Oct 10 |
peter |
WITHOUT ANY WARRANTY; without even the implied warranty of |
1225 |
17 Oct 10 |
peter |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1225 |
17 Oct 10 |
peter |
General Public License for more details. |
1225 |
17 Oct 10 |
peter |
20 |
|
1225 |
17 Oct 10 |
peter |
You should have received a copy of the GNU General Public License |
1225 |
17 Oct 10 |
peter |
along with svndigest. If not, see <http://www.gnu.org/licenses/>. |
1225 |
17 Oct 10 |
peter |
23 |
*/ |
1225 |
17 Oct 10 |
peter |
24 |
|
1225 |
17 Oct 10 |
peter |
25 |
#include "Alias.h" |
1225 |
17 Oct 10 |
peter |
26 |
#include "NodeVisitor.h" |
1225 |
17 Oct 10 |
peter |
27 |
|
1451 |
22 Dec 11 |
peter |
28 |
#include "yat/SegmentSet.h" |
1451 |
22 Dec 11 |
peter |
29 |
|
1237 |
23 Oct 10 |
peter |
30 |
#include <subversion-1/svn_types.h> |
1237 |
23 Oct 10 |
peter |
31 |
|
1225 |
17 Oct 10 |
peter |
32 |
#include <map> |
1239 |
23 Oct 10 |
peter |
33 |
#include <set> |
1225 |
17 Oct 10 |
peter |
34 |
#include <string> |
1376 |
14 Jun 11 |
peter |
35 |
#include <vector> |
1225 |
17 Oct 10 |
peter |
36 |
|
1225 |
17 Oct 10 |
peter |
37 |
namespace theplu{ |
1225 |
17 Oct 10 |
peter |
38 |
namespace svndigest{ |
1225 |
17 Oct 10 |
peter |
39 |
|
1225 |
17 Oct 10 |
peter |
40 |
class Directory; |
1225 |
17 Oct 10 |
peter |
41 |
class File; |
1225 |
17 Oct 10 |
peter |
42 |
|
1225 |
17 Oct 10 |
peter |
43 |
/** |
1228 |
17 Oct 10 |
peter |
Visitor for updating copyright in files. |
1225 |
17 Oct 10 |
peter |
45 |
*/ |
1225 |
17 Oct 10 |
peter |
46 |
class CopyrightVisitor : public NodeVisitor |
1225 |
17 Oct 10 |
peter |
47 |
{ |
1225 |
17 Oct 10 |
peter |
48 |
public: |
1225 |
17 Oct 10 |
peter |
49 |
CopyrightVisitor(std::map<std::string, Alias>&, bool verbose, |
1227 |
17 Oct 10 |
peter |
50 |
const std::map<int, svn_revnum_t>& year2rev, |
1227 |
17 Oct 10 |
peter |
51 |
bool ignore_cache); |
1225 |
17 Oct 10 |
peter |
52 |
|
1225 |
17 Oct 10 |
peter |
53 |
/** |
1451 |
22 Dec 11 |
peter |
\return false if dir.svncopyright_ignore |
1225 |
17 Oct 10 |
peter |
55 |
*/ |
1225 |
17 Oct 10 |
peter |
56 |
bool enter(Directory& dir); |
1225 |
17 Oct 10 |
peter |
57 |
|
1225 |
17 Oct 10 |
peter |
58 |
/** |
1239 |
23 Oct 10 |
peter |
Doing nothing |
1225 |
17 Oct 10 |
peter |
60 |
*/ |
1225 |
17 Oct 10 |
peter |
61 |
void leave(Directory& dir); |
1225 |
17 Oct 10 |
peter |
62 |
|
1225 |
17 Oct 10 |
peter |
63 |
/** |
1451 |
22 Dec 11 |
peter |
Updating copyright in \a file |
1225 |
17 Oct 10 |
peter |
65 |
*/ |
1239 |
23 Oct 10 |
peter |
66 |
void visit(File& file); |
1225 |
17 Oct 10 |
peter |
67 |
|
1225 |
17 Oct 10 |
peter |
68 |
private: |
1225 |
17 Oct 10 |
peter |
69 |
std::map<std::string, Alias>& alias_; |
1225 |
17 Oct 10 |
peter |
70 |
bool verbose_; |
1225 |
17 Oct 10 |
peter |
71 |
const std::map<int, svn_revnum_t>& year2rev_; |
1227 |
17 Oct 10 |
peter |
72 |
bool ignore_cache_; |
1456 |
24 Dec 11 |
peter |
73 |
typedef yat::utility::SegmentSet<svn_revnum_t> RevisionSet; |
1456 |
24 Dec 11 |
peter |
74 |
std::map<std::string, RevisionSet> path2ignore_; |
1239 |
23 Oct 10 |
peter |
75 |
|
1239 |
23 Oct 10 |
peter |
76 |
/** |
1456 |
24 Dec 11 |
peter |
add set \a b to set \a a |
1456 |
24 Dec 11 |
peter |
78 |
*/ |
1456 |
24 Dec 11 |
peter |
79 |
void add(RevisionSet& a, const RevisionSet& b) const; |
1456 |
24 Dec 11 |
peter |
80 |
|
1456 |
24 Dec 11 |
peter |
81 |
/** |
1239 |
23 Oct 10 |
peter |
\return copyright block |
1239 |
23 Oct 10 |
peter |
83 |
|
1239 |
23 Oct 10 |
peter |
Create a Copyright block from \a year2auth and prefix each line |
1239 |
23 Oct 10 |
peter |
with \a prefix. |
1239 |
23 Oct 10 |
peter |
86 |
*/ |
1239 |
23 Oct 10 |
peter |
87 |
std::string copyright_block(const std::map<int, std::set<Alias> >& year2auth, |
1239 |
23 Oct 10 |
peter |
88 |
const std::string& prefix) const; |
1239 |
23 Oct 10 |
peter |
89 |
|
1239 |
23 Oct 10 |
peter |
90 |
|
1239 |
23 Oct 10 |
peter |
91 |
/** |
1376 |
14 Jun 11 |
peter |
Look for copyright block in file \a path. |
1239 |
23 Oct 10 |
peter |
93 |
|
1239 |
23 Oct 10 |
peter |
\param path file to look for copyright |
1239 |
23 Oct 10 |
peter |
\param block found copyright block |
1239 |
23 Oct 10 |
peter |
\param start_at_line line number of first line in found block |
1239 |
23 Oct 10 |
peter |
\param end_at_line line number of first line after found block |
1239 |
23 Oct 10 |
peter |
98 |
|
1239 |
23 Oct 10 |
peter |
\return true if Copyright block is found |
1239 |
23 Oct 10 |
peter |
100 |
*/ |
1513 |
23 Sep 12 |
peter |
101 |
bool detect_copyright(const std::string& path, std::string& block, |
1513 |
23 Sep 12 |
peter |
102 |
size_t& start_at_line, size_t& end_at_line, |
1239 |
23 Oct 10 |
peter |
103 |
std::string& prefix) const; |
1239 |
23 Oct 10 |
peter |
104 |
|
1239 |
23 Oct 10 |
peter |
105 |
|
1239 |
23 Oct 10 |
peter |
106 |
/** |
1239 |
23 Oct 10 |
peter |
Update the copyright in \a file. |
1239 |
23 Oct 10 |
peter |
108 |
*/ |
1239 |
23 Oct 10 |
peter |
109 |
void update_copyright(const File& file); |
1239 |
23 Oct 10 |
peter |
110 |
|
1239 |
23 Oct 10 |
peter |
111 |
/** |
1239 |
23 Oct 10 |
peter |
Doing the actual print of copyright statement |
1239 |
23 Oct 10 |
peter |
113 |
|
1239 |
23 Oct 10 |
peter |
\param path to file |
1239 |
23 Oct 10 |
peter |
\param block new copyright block |
1239 |
23 Oct 10 |
peter |
\param start_at_line line number of first line in old block |
1239 |
23 Oct 10 |
peter |
\param end_at_line line number of first line after old block |
1239 |
23 Oct 10 |
peter |
118 |
*/ |
1239 |
23 Oct 10 |
peter |
119 |
void update_copyright(const std::string& path, const std::string& block, |
1239 |
23 Oct 10 |
peter |
120 |
size_t start_at_line, size_t end_at_line) const; |
1376 |
14 Jun 11 |
peter |
121 |
|
1376 |
14 Jun 11 |
peter |
122 |
|
1376 |
14 Jun 11 |
peter |
123 |
/** |
1376 |
14 Jun 11 |
peter |
Translating a set of users to a set of aliases using mapping in alias_ |
1376 |
14 Jun 11 |
peter |
125 |
*/ |
1376 |
14 Jun 11 |
peter |
126 |
void translate(const std::set<std::string>&, std::set<Alias>&); |
1376 |
14 Jun 11 |
peter |
127 |
|
1376 |
14 Jun 11 |
peter |
128 |
/** |
1376 |
14 Jun 11 |
peter |
Translating each year |
1376 |
14 Jun 11 |
peter |
130 |
*/ |
1376 |
14 Jun 11 |
peter |
131 |
void translate(const std::map<int, std::set<std::string> >& year2user, |
1376 |
14 Jun 11 |
peter |
132 |
std::map<int, std::set<Alias> >& year2alias); |
1376 |
14 Jun 11 |
peter |
133 |
|
1376 |
14 Jun 11 |
peter |
134 |
|
1225 |
17 Oct 10 |
peter |
135 |
}; |
1225 |
17 Oct 10 |
peter |
136 |
}} // end of namespace svndigest and namespace theplu |
1225 |
17 Oct 10 |
peter |
137 |
|
1225 |
17 Oct 10 |
peter |
138 |
#endif |