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 : CMultiArgCommand ("history", "Shows the history of a VSS physical file"),
18 m_bIncludeDeadRecords (false),
19 m_bIncludeLabels (false),
20 m_bIncludeActions (true)
24 po::options_description
CHistoryCommand::GetOptionsDescription () const
26 po::options_description
descr (CMultiArgCommand::GetOptionsDescription());
28 ("dead,d", "display only dead records\n"
29 "append [+|-] to include or exclude dead records in the output\n"
30 "by default dead records are not printed")
31 ("labels,l", "display only label records\n"
32 "append [+|-] to include or exclude label records in the output\n"
33 "by default label records are not printed");
37 po::options_description
CHistoryCommand::GetHiddenDescription () const
39 po::options_description
descr (CMultiArgCommand::GetHiddenDescription());
41 ("show-dead", po::value
<std::string
> ()->default_value ("exclude"), "internal option for --dead")
42 ("show-labels", po::value
<std::string
> ()->default_value ("include"), "internal option for --labels");
47 void CHistoryCommand::Execute (po::variables_map
const& options
, std::string
const& arg
)
49 m_bIncludeDeadRecords
= false;
50 bool m_bIncludeHealthyRecords
= true;
51 if (options
.count("show-dead"))
53 if (options
["show-dead"].as
<std::string
> () == "include")
54 m_bIncludeDeadRecords
= true;
55 else if (options
["show-dead"].as
<std::string
> () == "only")
57 m_bIncludeDeadRecords
= true;
58 m_bIncludeHealthyRecords
= false;
60 else if (options
["show-dead"].as
<std::string
> () == "exclude")
61 m_bIncludeDeadRecords
= true;
64 m_bIncludeActions
= true;
65 m_bIncludeLabels
= true;
66 if (options
.count("show-label"))
68 if (options
["show-dead"].as
<std::string
> () == "only")
69 m_bIncludeActions
= false;
70 else if (options
["show-dead"].as
<std::string
> () == "exclude")
71 m_bIncludeLabels
= false;
74 SSHistoryFile
file(arg
);
76 const CVersionFilter
* pFilter
= NULL
; // m_pOptions->GetVersionFilter ();
77 // std::auto_ptr <ISSObjectVisitor> pFormatter (CVssFormatterFactory::MakeFormatter());
79 SSVersionObject version
= file
.GetLastVersion();
82 bool bFiltered
= pFilter
? pFilter
->Filter(&version
) : false;
84 if (!m_bIncludeLabels
&& version
.GetActionID () == Labeled
)
87 if (!m_bIncludeActions
&& version
.GetActionID () != Labeled
)
91 GetFormatter()->Format (version
);
93 version
= file
.GetPrevVersion(version
);