1 // TortoiseSVN - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "RemoveSimpleChanges.h"
21 #include "FullGraphNode.h"
22 #include "VisibleGraphNode.h"
26 CRemoveSimpleChanges::CRemoveSimpleChanges (CRevisionGraphOptionList
& list
)
31 // implement IRevisionGraphOption: This option is negated.
33 bool CRemoveSimpleChanges::IsActive() const
38 // implement ICopyFilterOption (pre-filter most nodes)
40 ICopyFilterOption::EResult
41 CRemoveSimpleChanges::ShallRemove (const CFullGraphNode
* node
) const
43 // "M", not a branch point and will not become one due to removed copy-froms
45 bool nodeIsModificationOnly
46 = (node
->GetClassification().Is (CNodeClassification::IS_MODIFIED
))
47 && (node
->GetFirstCopyTarget() == NULL
);
49 const CFullGraphNode
* next
= node
->GetNext();
50 bool nextIsModificationOnly
52 && (next
->GetClassification().Is (CNodeClassification::IS_MODIFIED
))
53 && (next
->GetFirstCopyTarget() == NULL
);
55 return nodeIsModificationOnly
&& nextIsModificationOnly
56 ? ICopyFilterOption::REMOVE_NODE
57 : ICopyFilterOption::KEEP_NODE
;
60 // implement IModificationOption (post-filter unused copy-from nodes)
62 void CRemoveSimpleChanges::Apply (CVisibleGraph
* graph
, CVisibleGraphNode
* node
)
64 // "M", not a branch point, not the HEAD
66 if ( (node
->GetClassification().Matches
67 ( CNodeClassification::IS_MODIFIED
68 , static_cast<DWORD
>(CNodeClassification::MUST_BE_PRESERVED
)))
69 && (node
->GetFirstTag() == NULL
)
70 && (node
->GetFirstCopyTarget() == NULL
))
72 node
->DropNode (graph
, true);