bool RepositoryUtility::CommitChangeLog(void)
{
- GetChangeLog(boost::bind(RepositoryUtility::CommitChange, _1));
+ GetChangeLog(boost::bind(RepositoryUtility::CommitChange, _1, _2));
return true;
}
}
-bool RepositoryUtility::GetChangeLog(const boost::function<void (const Dictionary::Ptr&)>& callback)
+bool RepositoryUtility::GetChangeLog(const boost::function<void (const Dictionary::Ptr&, const String&)>& callback)
{
std::vector<String> changelog;
String path = GetRepositoryChangeLogPath() + "/";
std::sort(changelog.begin(), changelog.end());
BOOST_FOREACH(const String& entry, changelog) {
- Dictionary::Ptr change = GetObjectFromRepositoryChangeLog(path + entry + ".change");
+ String file = path + entry + ".change";
+ Dictionary::Ptr change = GetObjectFromRepositoryChangeLog(file);
Log(LogInformation, "cli")
<< "Collecting entry " << entry << "\n";
if (change)
- callback(change);
+ callback(change, file);
}
return true;
changelog.push_back(file);
}
-void RepositoryUtility::CommitChange(const Dictionary::Ptr& change)
+void RepositoryUtility::CommitChange(const Dictionary::Ptr& change, const String& path)
{
Log(LogInformation, "cli")
<< "Got change " << change->Get("name");
attr = change->Get("attr");
}
+ bool success = false;
+
if (command == "add") {
- AddObjectInternal(name, type, attr);
+ success = AddObjectInternal(name, type, attr);
}
else if (command == "remove") {
- RemoveObjectInternal(name, type, attr);
+ success = RemoveObjectInternal(name, type, attr);
+ }
+
+ if (success) {
+ Log(LogInformation, "cli")
+ << "Removing changelog file '" << path << "'.";
+ RemoveObjectFileInternal(path);
}
}
static bool WriteObjectToRepositoryChangeLog(const String& path, const Dictionary::Ptr& item);
static Dictionary::Ptr GetObjectFromRepositoryChangeLog(const String& filename);
- static bool GetChangeLog(const boost::function<void (const Dictionary::Ptr&)>& callback);
- static void CommitChange(const Dictionary::Ptr& change);
+ static bool GetChangeLog(const boost::function<void (const Dictionary::Ptr&, const String&)>& callback);
+ static void CommitChange(const Dictionary::Ptr& change, const String& path);
static void CollectChange(const Dictionary::Ptr& change, Array::Ptr& changes);
/* config print helpers */