185 |
06 Sep 06 |
jari |
// $Id$ |
185 |
06 Sep 06 |
jari |
2 |
|
185 |
06 Sep 06 |
jari |
3 |
/* |
978 |
12 Dec 09 |
peter |
Copyright (C) 2006 Jari Häkkinen |
1635 |
30 Mar 23 |
peter |
Copyright (C) 2007 Peter Johansson |
1635 |
30 Mar 23 |
peter |
Copyright (C) 2008 Jari Häkkinen, Peter Johansson |
1635 |
30 Mar 23 |
peter |
Copyright (C) 2010, 2011, 2012, 2020, 2023 Peter Johansson |
185 |
06 Sep 06 |
jari |
8 |
|
687 |
04 Aug 08 |
peter |
This file is part of svndigest, http://dev.thep.lu.se/svndigest |
185 |
06 Sep 06 |
jari |
10 |
|
185 |
06 Sep 06 |
jari |
svndigest is free software; you can redistribute it and/or modify it |
185 |
06 Sep 06 |
jari |
under the terms of the GNU General Public License as published by |
693 |
11 Sep 08 |
jari |
the Free Software Foundation; either version 3 of the License, or |
185 |
06 Sep 06 |
jari |
(at your option) any later version. |
185 |
06 Sep 06 |
jari |
15 |
|
185 |
06 Sep 06 |
jari |
svndigest is distributed in the hope that it will be useful, but |
185 |
06 Sep 06 |
jari |
WITHOUT ANY WARRANTY; without even the implied warranty of |
185 |
06 Sep 06 |
jari |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
185 |
06 Sep 06 |
jari |
General Public License for more details. |
185 |
06 Sep 06 |
jari |
20 |
|
185 |
06 Sep 06 |
jari |
You should have received a copy of the GNU General Public License |
693 |
11 Sep 08 |
jari |
along with svndigest. If not, see <http://www.gnu.org/licenses/>. |
185 |
06 Sep 06 |
jari |
23 |
*/ |
185 |
06 Sep 06 |
jari |
24 |
|
1619 |
12 Mar 23 |
peter |
25 |
#include <config.h> |
1619 |
12 Mar 23 |
peter |
26 |
|
185 |
06 Sep 06 |
jari |
27 |
#include "SVNproperty.h" |
1144 |
24 Jul 10 |
peter |
28 |
|
1144 |
24 Jul 10 |
peter |
29 |
#include "Configuration.h" |
185 |
06 Sep 06 |
jari |
30 |
#include "SVN.h" |
1144 |
24 Jul 10 |
peter |
31 |
#include "utility.h" |
185 |
06 Sep 06 |
jari |
32 |
|
1454 |
23 Dec 11 |
peter |
33 |
#include "yat/Exception.h" |
1438 |
20 Dec 11 |
peter |
34 |
#include "yat/Segment.h" |
1438 |
20 Dec 11 |
peter |
35 |
#include "yat/utility.h" |
1438 |
20 Dec 11 |
peter |
36 |
|
1438 |
20 Dec 11 |
peter |
37 |
#include <limits> |
1454 |
23 Dec 11 |
peter |
38 |
#include <stdexcept> |
1454 |
23 Dec 11 |
peter |
39 |
#include <sstream> |
185 |
06 Sep 06 |
jari |
40 |
#include <string> |
185 |
06 Sep 06 |
jari |
41 |
|
185 |
06 Sep 06 |
jari |
42 |
namespace theplu { |
185 |
06 Sep 06 |
jari |
43 |
namespace svndigest { |
185 |
06 Sep 06 |
jari |
44 |
|
1478 |
29 May 12 |
peter |
45 |
using yat::utility::convert; |
185 |
06 Sep 06 |
jari |
46 |
|
185 |
06 Sep 06 |
jari |
47 |
SVNproperty::SVNproperty(const std::string& path) |
1478 |
29 May 12 |
peter |
48 |
: binary_(false), svncopyright_ignore_(false), svndigest_ignore_rev_(0) |
185 |
06 Sep 06 |
jari |
49 |
{ |
1356 |
17 May 11 |
peter |
50 |
typedef std::map<std::string, std::string> str_map; |
1356 |
17 May 11 |
peter |
51 |
str_map property; |
1356 |
17 May 11 |
peter |
52 |
SVN::instance()->client_proplist(path, property); |
1357 |
18 May 11 |
peter |
53 |
add(property.begin(), property.end()); |
1144 |
24 Jul 10 |
peter |
54 |
const Configuration& config = Configuration::instance(); |
1152 |
07 Aug 10 |
peter |
55 |
const str_map& props = config.svn_properties(file_name(path)); |
1357 |
18 May 11 |
peter |
56 |
add(props.begin(), props.end()); |
1357 |
18 May 11 |
peter |
57 |
} |
1357 |
18 May 11 |
peter |
58 |
|
1357 |
18 May 11 |
peter |
59 |
|
1438 |
20 Dec 11 |
peter |
60 |
void |
1357 |
18 May 11 |
peter |
61 |
SVNproperty::add(std::map<std::string, std::string>::const_iterator i, |
1357 |
18 May 11 |
peter |
62 |
std::map<std::string, std::string>::const_iterator last) |
1357 |
18 May 11 |
peter |
63 |
{ |
1438 |
20 Dec 11 |
peter |
64 |
for ( ; i!=last ; ++i) { |
1454 |
23 Dec 11 |
peter |
65 |
try { |
1454 |
23 Dec 11 |
peter |
66 |
if (i->first == "svndigest:ignore") |
1478 |
29 May 12 |
peter |
67 |
add_svndigest_ignore(i->second); |
1454 |
23 Dec 11 |
peter |
68 |
else if (i->first == "svncopyright:ignore") |
1454 |
23 Dec 11 |
peter |
69 |
add_svncopyright_ignore(i->second); |
1454 |
23 Dec 11 |
peter |
70 |
else |
1454 |
23 Dec 11 |
peter |
71 |
if ((i->first == "svn:mime-type") && |
1454 |
23 Dec 11 |
peter |
72 |
(svn_mime_type_is_binary(i->second.c_str()))) |
1454 |
23 Dec 11 |
peter |
73 |
binary_=true; |
1438 |
20 Dec 11 |
peter |
74 |
} |
1454 |
23 Dec 11 |
peter |
75 |
catch (yat::utility::runtime_error& e) { |
1454 |
23 Dec 11 |
peter |
76 |
std::ostringstream ss; |
1454 |
23 Dec 11 |
peter |
77 |
ss << "invalid value for property '" << i->first << "': '" |
1454 |
23 Dec 11 |
peter |
78 |
<< i->second << "'"; |
1454 |
23 Dec 11 |
peter |
79 |
throw std::runtime_error(ss.str()); |
1454 |
23 Dec 11 |
peter |
80 |
} |
1438 |
20 Dec 11 |
peter |
81 |
} |
1454 |
23 Dec 11 |
peter |
82 |
} |
185 |
06 Sep 06 |
jari |
83 |
|
185 |
06 Sep 06 |
jari |
84 |
|
1438 |
20 Dec 11 |
peter |
85 |
void SVNproperty::add_svncopyright_ignore(const std::string& value) |
1438 |
20 Dec 11 |
peter |
86 |
{ |
1438 |
20 Dec 11 |
peter |
// reset previous settings |
1438 |
20 Dec 11 |
peter |
88 |
svncopyright_ignore_ = false; |
1438 |
20 Dec 11 |
peter |
89 |
svncopyright_ignore_rev_.clear(); |
1438 |
20 Dec 11 |
peter |
90 |
|
1438 |
20 Dec 11 |
peter |
91 |
if (value.empty()) { |
1438 |
20 Dec 11 |
peter |
92 |
svncopyright_ignore_ = true; |
1438 |
20 Dec 11 |
peter |
93 |
return; |
1438 |
20 Dec 11 |
peter |
94 |
} |
1438 |
20 Dec 11 |
peter |
95 |
|
1438 |
20 Dec 11 |
peter |
96 |
std::istringstream ss(value); |
1438 |
20 Dec 11 |
peter |
97 |
std::string word; |
1438 |
20 Dec 11 |
peter |
// entries delimited by ';' |
1438 |
20 Dec 11 |
peter |
99 |
while (getline(ss, word, ';')) { |
1438 |
20 Dec 11 |
peter |
100 |
std::istringstream ss2(word); |
1438 |
20 Dec 11 |
peter |
101 |
std::string first; |
1438 |
20 Dec 11 |
peter |
102 |
getline(ss2, first, '-'); |
1608 |
14 Jul 20 |
peter |
103 |
bool found_dash = word.size()>first.size() && word[first.size()]=='-'; |
1438 |
20 Dec 11 |
peter |
104 |
trim(first); |
1438 |
20 Dec 11 |
peter |
105 |
std::string second; |
1608 |
14 Jul 20 |
peter |
106 |
getline(ss2, second); |
1453 |
23 Dec 11 |
peter |
107 |
trim(second); |
1438 |
20 Dec 11 |
peter |
108 |
yat::utility::Segment<svn_revnum_t> rev_interval; |
1438 |
20 Dec 11 |
peter |
109 |
if (!found_dash) { |
1438 |
20 Dec 11 |
peter |
110 |
rev_interval.begin() = convert<svn_revnum_t>(first); |
1438 |
20 Dec 11 |
peter |
111 |
rev_interval.end() = rev_interval.begin()+1; |
1438 |
20 Dec 11 |
peter |
112 |
} |
1438 |
20 Dec 11 |
peter |
113 |
else { |
1438 |
20 Dec 11 |
peter |
114 |
if (first.empty()) |
1438 |
20 Dec 11 |
peter |
115 |
rev_interval.begin() = 0; |
1438 |
20 Dec 11 |
peter |
116 |
else |
1438 |
20 Dec 11 |
peter |
117 |
rev_interval.begin() = convert<svn_revnum_t>(first); |
1438 |
20 Dec 11 |
peter |
118 |
if (second.empty()) |
1438 |
20 Dec 11 |
peter |
119 |
rev_interval.end() = std::numeric_limits<svn_revnum_t>::max(); |
1438 |
20 Dec 11 |
peter |
120 |
else |
1453 |
23 Dec 11 |
peter |
121 |
rev_interval.end() = convert<svn_revnum_t>(second)+1; |
1438 |
20 Dec 11 |
peter |
122 |
} |
1438 |
20 Dec 11 |
peter |
123 |
svncopyright_ignore_rev_.insert_merge(rev_interval); |
1438 |
20 Dec 11 |
peter |
124 |
} |
1438 |
20 Dec 11 |
peter |
125 |
} |
1438 |
20 Dec 11 |
peter |
126 |
|
1438 |
20 Dec 11 |
peter |
127 |
|
1478 |
29 May 12 |
peter |
128 |
void SVNproperty::add_svndigest_ignore(const std::string& value) |
1478 |
29 May 12 |
peter |
129 |
{ |
1478 |
29 May 12 |
peter |
130 |
if (value.empty() || value=="*") { |
1478 |
29 May 12 |
peter |
131 |
svndigest_ignore_rev_ = std::numeric_limits<svn_revnum_t>::max(); |
1478 |
29 May 12 |
peter |
132 |
return; |
1478 |
29 May 12 |
peter |
133 |
} |
1478 |
29 May 12 |
peter |
134 |
svndigest_ignore_rev_ = convert<svn_revnum_t>(value); |
1478 |
29 May 12 |
peter |
135 |
} |
1478 |
29 May 12 |
peter |
136 |
|
1478 |
29 May 12 |
peter |
137 |
|
1356 |
17 May 11 |
peter |
138 |
bool SVNproperty::binary(void) const |
1356 |
17 May 11 |
peter |
139 |
{ |
1356 |
17 May 11 |
peter |
140 |
return binary_; |
1356 |
17 May 11 |
peter |
141 |
} |
1356 |
17 May 11 |
peter |
142 |
|
1438 |
20 Dec 11 |
peter |
143 |
|
1356 |
17 May 11 |
peter |
144 |
bool SVNproperty::svndigest_ignore(void) const |
1356 |
17 May 11 |
peter |
145 |
{ |
1478 |
29 May 12 |
peter |
146 |
return svndigest_ignore_rev_==std::numeric_limits<svn_revnum_t>::max(); |
1356 |
17 May 11 |
peter |
147 |
} |
1356 |
17 May 11 |
peter |
148 |
|
1356 |
17 May 11 |
peter |
149 |
|
1478 |
29 May 12 |
peter |
150 |
svn_revnum_t SVNproperty::svndigest_ignore_rev(void) const |
1478 |
29 May 12 |
peter |
151 |
{ |
1478 |
29 May 12 |
peter |
152 |
return svndigest_ignore_rev_; |
1478 |
29 May 12 |
peter |
153 |
} |
1478 |
29 May 12 |
peter |
154 |
|
1478 |
29 May 12 |
peter |
155 |
|
1137 |
18 Jul 10 |
peter |
156 |
bool SVNproperty::svncopyright_ignore(void) const |
1137 |
18 Jul 10 |
peter |
157 |
{ |
1356 |
17 May 11 |
peter |
158 |
return svncopyright_ignore_; |
1137 |
18 Jul 10 |
peter |
159 |
} |
1137 |
18 Jul 10 |
peter |
160 |
|
1438 |
20 Dec 11 |
peter |
161 |
|
1438 |
20 Dec 11 |
peter |
162 |
const yat::utility::SegmentSet<svn_revnum_t>& |
1438 |
20 Dec 11 |
peter |
163 |
SVNproperty::svncopyright_ignore_rev(void) const |
1438 |
20 Dec 11 |
peter |
164 |
{ |
1438 |
20 Dec 11 |
peter |
165 |
return svncopyright_ignore_rev_; |
1438 |
20 Dec 11 |
peter |
166 |
} |
1438 |
20 Dec 11 |
peter |
167 |
|
185 |
06 Sep 06 |
jari |
168 |
}} // end of namespace svndigest and namespace theplu |