1 // HistoryCommand.cpp: implementation of the CHistoryCommand class.
3 //////////////////////////////////////////////////////////////////////
6 #include "HistoryCommand.h"
7 #include "VersionFilter.h"
9 #include <SSPhysLib\SSItemInfoObject.h>
11 //////////////////////////////////////////////////////////////////////
12 // Construction/Destruction
13 //////////////////////////////////////////////////////////////////////
15 //---------------------------------------------------------------------------
16 CHistoryCommand::CHistoryCommand ()
17 : CCommand ("history"),
18 m_bIncludeDeadRecords (false),
19 m_bIncludeLabels (false),
20 m_bIncludeActions (true)
24 COptionInfoList
CHistoryCommand::GetOptionsInfo () const
26 COptionInfoList options
= CCommand::GetOptionsInfo();
27 options
.push_back (COptionInfo ('d', 'd', "dead", "include dead records", COptionInfo::tristateArgument
));
28 options
.push_back (COptionInfo ('l', 'l', "label", "include label records", COptionInfo::tristateArgument
));
32 bool CHistoryCommand::SetOption (const COption
& option
)
37 m_bIncludeDeadRecords
= true;
38 m_bOnlyDeadRecords
&= option
.value
.pTristateValue
;
41 m_bIncludeLabels
= true;
42 if (option
.value
.pTristateValue
== set
)
43 m_bIncludeActions
= false;
44 else if (option
.value
.pTristateValue
== cleared
)
45 m_bIncludeLabels
= false;
53 bool CHistoryCommand::SetArguments (CArguments
& args
)
56 throw SSException ("no argument");
58 m_PhysFile
= args
.front ();
63 void CHistoryCommand::Execute ()
65 SSHistoryFile
file(m_PhysFile
);
67 const CVersionFilter
* pFilter
= NULL
; // m_pOptions->GetVersionFilter ();
68 // std::auto_ptr <ISSObjectVisitor> pFormatter (CVssFormatterFactory::MakeFormatter());
70 SSVersionObject version
= file
.GetLastVersion();
73 bool bFiltered
= pFilter
? pFilter
->Filter(&version
) : false;
75 if (!m_bIncludeLabels
&& version
.GetActionID () == Labeled
)
78 if (!m_bIncludeActions
&& version
.GetActionID () != Labeled
)
82 g_pFormatter
->Format (version
);
84 version
= file
.GetPrevVersion(version
);