1 // TortoiseSVN - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2003-2008 - TortoiseSVN
\r
5 // This program is free software; you can redistribute it and/or
\r
6 // modify it under the terms of the GNU General Public License
\r
7 // as published by the Free Software Foundation; either version 2
\r
8 // of the License, or (at your option) any later version.
\r
10 // This program is distributed in the hope that it will be useful,
\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 // GNU General Public License for more details.
\r
15 // You should have received a copy of the GNU General Public License
\r
16 // along with this program; if not, write to the Free Software Foundation,
\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
20 #include "RemovePathsBySubString.h"
\r
21 #include "FullGraphNode.h"
\r
25 CRemovePathsBySubString::CRemovePathsBySubString (CRevisionGraphOptionList& list)
\r
32 /// access to the sub-string container
\r
34 const std::set<std::string>& CRemovePathsBySubString::GetFilterPaths() const
\r
39 std::set<std::string>& CRemovePathsBySubString::GetFilterPaths()
\r
44 // implement ICopyFilterOption
\r
46 ICopyFilterOption::EResult
\r
47 CRemovePathsBySubString::ShallRemove (const CFullGraphNode* node) const
\r
51 if (filterPaths.empty())
\r
52 return ICopyFilterOption::KEEP_NODE;
\r
56 const CDictionaryBasedPath& path = node->GetRealPath();
\r
58 // ensure the index is valid within classification cache
\r
60 if (pathClassification.size() <= path.GetIndex())
\r
62 size_t newSize = max (8, pathClassification.size()) * 2;
\r
63 while (newSize <= path.GetIndex())
\r
66 pathClassification.resize (newSize, UNKNOWN);
\r
69 // auto-calculate the entry
\r
71 PathClassification& classification = pathClassification[path.GetIndex()];
\r
72 if (classification == UNKNOWN)
\r
74 std::string fullPath = path.GetPath();
\r
76 classification = KEEP;
\r
77 for ( std::set<std::string>::const_iterator iter = filterPaths.begin()
\r
78 , end = filterPaths.end()
\r
82 if (fullPath.find (*iter) != std::string::npos)
\r
84 classification = REMOVE;
\r
90 // return the result
\r
92 return classification == REMOVE
\r
93 ? ICopyFilterOption::REMOVE_NODE
\r
94 : ICopyFilterOption::KEEP_NODE;
\r
97 void CRemovePathsBySubString::Prepare()
\r
99 pathClassification.clear();
\r