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 "FoldTags.h"
\r
21 #include "VisibleGraphNode.h"
\r
23 // that the line from node downward have any visible copy targets?
\r
25 bool CFoldTags::CopyTargetsVisibile (const CVisibleGraphNode* node) const
\r
27 for (; node != NULL; node = node->GetNext())
\r
28 if (node->GetFirstCopyTarget() != NULL)
\r
36 CFoldTags::CFoldTags (CRevisionGraphOptionList& list)
\r
41 // implement IModificationOption
\r
43 void CFoldTags::Apply (CVisibleGraph* graph, CVisibleGraphNode* node)
\r
45 // We will not remove tags that get copied to non-tags
\r
46 // that have not yet been removed from the graph.
\r
48 DWORD forbidden = CNodeClassification::COPIES_TO_TRUNK
\r
49 | CNodeClassification::COPIES_TO_BRANCH
\r
50 | CNodeClassification::COPIES_TO_OTHER;
\r
52 CNodeClassification classification = node->GetClassification();
\r
53 bool isTag = classification.Matches (CNodeClassification::IS_TAG, 0);
\r
54 bool isFinalTag = classification.Matches (CNodeClassification::IS_TAG, forbidden);
\r
56 // fold tags at the point of their creation
\r
60 // this is a node on some tag but maybe not the creation point
\r
61 // (e.g. if we don't want to fold a tag and that tag gets
\r
62 // modified in several revisions)
\r
64 if ( (node->GetCopySource() != NULL)
\r
65 || ( (node->GetPrevious() != NULL)
\r
66 && classification.Is (CNodeClassification::IS_RENAMED)))
\r
68 // this is the point where the tag got created / renamed
\r
69 // (CopyTargetsVisibile can be expensive -> don't do it
\r
70 // in the first "if" condition 4 lines above)
\r
72 if (isFinalTag || !CopyTargetsVisibile (node))
\r
74 // it does not copy to branch etc.
\r
75 // (if it copies to a tag, that one will be folded first
\r
76 // and we will fold this one only in the next iteration)
\r
78 node->FoldTag (graph);
\r