summaryrefslogtreecommitdiff
path: root/cpp/src/IcePatch2Lib/ClientUtil.cpp
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2013-01-24 23:10:22 +0100
committerJose <jose@zeroc.com>2013-01-24 23:10:22 +0100
commit47cc21ee10c01fee3f5643a54baa9fff6e1f2cc0 (patch)
treec32cc6957025399fb9b202e61f44f844bc890811 /cpp/src/IcePatch2Lib/ClientUtil.cpp
parentFix VS2010 compilation warning (diff)
downloadice-47cc21ee10c01fee3f5643a54baa9fff6e1f2cc0.tar.bz2
ice-47cc21ee10c01fee3f5643a54baa9fff6e1f2cc0.tar.xz
ice-47cc21ee10c01fee3f5643a54baa9fff6e1f2cc0.zip
Fixed (ICE-4993) - Inconsistent naming of IcePatch2 properties
Diffstat (limited to 'cpp/src/IcePatch2Lib/ClientUtil.cpp')
-rw-r--r--cpp/src/IcePatch2Lib/ClientUtil.cpp115
1 files changed, 110 insertions, 5 deletions
diff --git a/cpp/src/IcePatch2Lib/ClientUtil.cpp b/cpp/src/IcePatch2Lib/ClientUtil.cpp
index 3e829cc3867..6d50a9215b0 100644
--- a/cpp/src/IcePatch2Lib/ClientUtil.cpp
+++ b/cpp/src/IcePatch2Lib/ClientUtil.cpp
@@ -145,12 +145,117 @@ private:
}
+namespace
+{
+
+string
+getDataDir(const CommunicatorPtr& communicator, const string& defaultValue)
+{
+ const string property = "IcePatch2Client.Directory";
+ const string deprecatedProperty = "IcePatch2.Directory";
+
+ if(communicator->getProperties()->getProperty(property).empty() &&
+ communicator->getProperties()->getProperty(deprecatedProperty).empty())
+ {
+ return defaultValue;
+ }
+
+ string value = communicator->getProperties()->getProperty(property);
+ if(value.empty())
+ {
+ value = communicator->getProperties()->getProperty(deprecatedProperty);
+ ostringstream os;
+ os << "The property " << deprecatedProperty << " is deprecated, use " << property << " instead.";
+ communicator->getLogger()->warning(os.str());
+ }
+ assert(!value.empty());
+ return value;
+}
+
+int
+getThorough(const CommunicatorPtr& communicator, int defaultValue)
+{
+ const string property = "IcePatch2Client.Thorough";
+ const string deprecatedProperty = "IcePatch2.Thorough";
+
+ if(communicator->getProperties()->getProperty(property).empty() &&
+ communicator->getProperties()->getProperty(deprecatedProperty).empty())
+ {
+ return defaultValue;
+ }
+
+ if(!communicator->getProperties()->getProperty(property).empty())
+ {
+ return communicator->getProperties()->getPropertyAsInt(property);
+ }
+ else
+ {
+ ostringstream os;
+ os << "The property " << deprecatedProperty << " is deprecated, use " << property << " instead.";
+ communicator->getLogger()->warning(os.str());
+ return communicator->getProperties()->getPropertyAsInt(deprecatedProperty);
+ }
+}
+
+int
+getChunkSize(const CommunicatorPtr& communicator, int defaultValue)
+{
+ const string property = "IcePatch2Client.ChunkSize";
+ const string deprecatedProperty = "IcePatch2.ChunkSize";
+
+ if(communicator->getProperties()->getProperty(property).empty() &&
+ communicator->getProperties()->getProperty(deprecatedProperty).empty())
+ {
+ return defaultValue;
+ }
+
+ if(!communicator->getProperties()->getProperty(property).empty())
+ {
+ return communicator->getProperties()->getPropertyAsInt(property);
+ }
+ else
+ {
+ ostringstream os;
+ os << "The property " << deprecatedProperty << " is deprecated, use " << property << " instead.";
+ communicator->getLogger()->warning(os.str());
+ return communicator->getProperties()->getPropertyAsInt(deprecatedProperty);
+ }
+}
+
+int
+getRemove(const CommunicatorPtr& communicator, int defaultValue)
+{
+ const string property = "IcePatch2Client.Remove";
+ const string deprecatedProperty = "IcePatch2.Remove";
+
+ if(communicator->getProperties()->getProperty(property).empty() &&
+ communicator->getProperties()->getProperty(deprecatedProperty).empty())
+ {
+ return defaultValue;
+ }
+
+ if(!communicator->getProperties()->getProperty(property).empty())
+ {
+ return communicator->getProperties()->getPropertyAsInt(property);
+ }
+ else
+ {
+ ostringstream os;
+ os << "The property " << deprecatedProperty << " is deprecated, use " << property << " instead.";
+ communicator->getLogger()->warning(os.str());
+ return communicator->getProperties()->getPropertyAsInt(deprecatedProperty);
+ }
+}
+
+}
+
+
IcePatch2::Patcher::Patcher(const CommunicatorPtr& communicator, const PatcherFeedbackPtr& feedback) :
_feedback(feedback),
- _dataDir(communicator->getProperties()->getPropertyWithDefault("IcePatch2.Directory", ".")),
- _thorough(communicator->getProperties()->getPropertyAsInt("IcePatch2.Thorough") > 0),
- _chunkSize(communicator->getProperties()->getPropertyAsIntWithDefault("IcePatch2.ChunkSize", 100)),
- _remove(communicator->getProperties()->getPropertyAsIntWithDefault("IcePatch2.Remove", 1)),
+ _dataDir(getDataDir(communicator, ".")),
+ _thorough(getThorough(communicator, 0) > 0),
+ _chunkSize(getChunkSize(communicator, 100)),
+ _remove(getRemove(communicator, 1)),
_log(0)
{
const PropertiesPtr properties = communicator->getProperties();
@@ -601,7 +706,7 @@ IcePatch2::Patcher::removeFiles(const FileInfoSeq& files)
}
catch(...)
{
- if(_remove < 2) // We ignore errors if IcePatch2.Remove >= 2.
+ if(_remove < 2) // We ignore errors if IcePatch2Client.Remove >= 2.
{
throw;
}