* Path for renames during restore and renames during share (thanks to Bryan Aldrich...
[vss2svn.git] / ssphys / SSPhys / HistoryCommand.cpp
blob697a1ad347276c7b5690636674738650c8d84388
1 // HistoryCommand.cpp: implementation of the CHistoryCommand class.
2 //
3 //////////////////////////////////////////////////////////////////////
5 #include "StdAfx.h"
6 #include "HistoryCommand.h"
7 #include "VersionFilter.h"
8 #include "Formatter.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());
27 descr.add_options ()
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");
34 return descr;
37 po::options_description CHistoryCommand::GetHiddenDescription () const
39 po::options_description descr (CMultiArgCommand::GetHiddenDescription());
40 descr.add_options ()
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");
43 return descr;
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();
80 while (version)
82 bool bFiltered = pFilter ? pFilter->Filter(&version) : false;
84 if (!m_bIncludeLabels && version.GetActionID () == Labeled)
85 bFiltered = true;
87 if (!m_bIncludeActions && version.GetActionID () != Labeled)
88 bFiltered = true;
90 if (!bFiltered)
91 GetFormatter()->Format (version);
93 version = file.GetPrevVersion(version);