Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorIlya Zverev <zverik@textual.ru>2016-03-24 13:23:10 +0300
committerIlya Zverev <zverik@textual.ru>2016-03-24 13:23:10 +0300
commit24b65aac4290d6a1377679ea6e7be65aad23c648 (patch)
tree7ef9371d876839f5b7a8d11645c21dcf72865357 /editor
parent99fec047b33e0ae7c2ec379e531c1492faef8b09 (diff)
[editor] Review fixes
Diffstat (limited to 'editor')
-rw-r--r--editor/changeset_wrapper.cpp15
-rw-r--r--editor/changeset_wrapper.hpp6
-rw-r--r--editor/editor_tests/server_api_test.cpp4
-rw-r--r--editor/server_api.cpp2
-rw-r--r--editor/server_api.hpp1
5 files changed, 20 insertions, 8 deletions
diff --git a/editor/changeset_wrapper.cpp b/editor/changeset_wrapper.cpp
index c8b7d26a5e..94c06f813e 100644
--- a/editor/changeset_wrapper.cpp
+++ b/editor/changeset_wrapper.cpp
@@ -255,26 +255,27 @@ void ChangesetWrapper::Delete(XMLFeature node)
// Changeset id should be updated for every OSM server commit.
node.SetAttribute("changeset", strings::to_string(m_changesetId));
m_api.DeleteElement(node);
+ m_deleted_types[GetTypeForFeature(node)]++;
}
-string ChangesetWrapper::TypeCountToString(TTypeCount const & typeCount) const
+string ChangesetWrapper::TypeCountToString(TTypeCount const & typeCount)
{
if (typeCount.empty())
return string();
// Convert map to vector and sort pairs by count, descending.
- vector<pair<string, uint16_t>> items;
+ vector<pair<string, size_t>> items;
for (auto const & tc : typeCount)
items.push_back(tc);
sort(items.begin(), items.end(),
- [](pair<string, uint16_t> const & a, pair<string, uint16_t> const & b)
+ [](pair<string, size_t> const & a, pair<string, size_t> const & b)
{
return a.second > b.second;
});
ostringstream ss;
- auto const limit = items.size() > 3 ? 3 : items.size();
+ auto const limit = min(3UL, items.size());
for (auto i = 0; i < limit; ++i)
{
if (i > 0)
@@ -321,6 +322,12 @@ string ChangesetWrapper::GetDescription() const
result += "; ";
result += "Updated " + TypeCountToString(m_modified_types);
}
+ if (!m_deleted_types.empty())
+ {
+ if (!result.empty())
+ result += "; ";
+ result += "Deleted " + TypeCountToString(m_deleted_types);
+ }
return result;
}
diff --git a/editor/changeset_wrapper.hpp b/editor/changeset_wrapper.hpp
index c1d0d5583c..b199d8f095 100644
--- a/editor/changeset_wrapper.hpp
+++ b/editor/changeset_wrapper.hpp
@@ -19,7 +19,7 @@ struct ClientToken;
class ChangesetWrapper
{
- using TTypeCount = map<string, uint16_t>;
+ using TTypeCount = map<string, size_t>;
public:
DECLARE_EXCEPTION(ChangesetWrapperException, RootException);
@@ -64,10 +64,10 @@ private:
static constexpr uint64_t kInvalidChangesetId = 0;
uint64_t m_changesetId = kInvalidChangesetId;
- // No m_deleted_types here, since we do not delete features.
TTypeCount m_modified_types;
TTypeCount m_created_types;
- string TypeCountToString(TTypeCount const & typeCount) const;
+ TTypeCount m_deleted_types;
+ static string TypeCountToString(TTypeCount const & typeCount);
string GetDescription() const;
};
diff --git a/editor/editor_tests/server_api_test.cpp b/editor/editor_tests/server_api_test.cpp
index 83d6e652f9..4962155e2c 100644
--- a/editor/editor_tests/server_api_test.cpp
+++ b/editor/editor_tests/server_api_test.cpp
@@ -95,6 +95,10 @@ UNIT_TEST(OSM_ServerAPI_ChangesetAndNode)
// After modification, node version increases in ModifyElement.
TEST_EQUAL(node.GetAttribute("version"), "2", ());
+ // All tags must be specified, because there is no merging of old and new tags.
+ api.UpdateChangeSet(changeSetId, {{"created_by", "MAPS.ME Unit Test"},
+ {"comment", "For test purposes only (updated)."}});
+
// To retrieve created node, changeset should be closed first.
// It is done here via Scope Guard.
}
diff --git a/editor/server_api.cpp b/editor/server_api.cpp
index 513fb04a02..1f5fb6b8d4 100644
--- a/editor/server_api.cpp
+++ b/editor/server_api.cpp
@@ -107,7 +107,7 @@ void ServerApi06::UpdateChangeSet(uint64_t changesetId, TKeyValueTags const & kv
{
OsmOAuth::Response const response = m_auth.Request("/changeset/" + strings::to_string(changesetId), "PUT", KeyValueTagsToXML(kvTags));
if (response.first != OsmOAuth::HTTP::OK)
- MYTHROW(CreateChangeSetHasFailed, ("UpdateChangeSet request has failed:", response));
+ MYTHROW(UpdateChangeSetHasFailed, ("UpdateChangeSet request has failed:", response));
}
void ServerApi06::CloseChangeSet(uint64_t changesetId) const
diff --git a/editor/server_api.hpp b/editor/server_api.hpp
index 57027d0462..59bc82c4c7 100644
--- a/editor/server_api.hpp
+++ b/editor/server_api.hpp
@@ -34,6 +34,7 @@ public:
DECLARE_EXCEPTION(NotAuthorized, ServerApi06Exception);
DECLARE_EXCEPTION(CantParseServerResponse, ServerApi06Exception);
DECLARE_EXCEPTION(CreateChangeSetHasFailed, ServerApi06Exception);
+ DECLARE_EXCEPTION(UpdateChangeSetHasFailed, ServerApi06Exception);
DECLARE_EXCEPTION(CreateElementHasFailed, ServerApi06Exception);
DECLARE_EXCEPTION(ModifiedElementHasNoIdAttribute, ServerApi06Exception);
DECLARE_EXCEPTION(ModifyElementHasFailed, ServerApi06Exception);