{"action":"created","comment":{"url":"https://api.github.com/repos/puppetlabs/cpp-hocon/pulls/comments/49387371","id":49387371,"diff_hunk":"@@ -54,6 +57,171 @@ namespace hocon {\n         }\n     }\n \n+    shared_origin simple_config_origin::merge_origins(shared_origin a, shared_origin b) {\n+        return merge_two(dynamic_pointer_cast<const simple_config_origin>(a), dynamic_pointer_cast<const simple_config_origin>(b));\n+    }\n+\n+    shared_origin simple_config_origin::merge_origins(std::vector<shared_value> const& stack) {\n+        vector<shared_origin> origins;\n+        for (auto& v : stack) {\n+            origins.push_back(v->origin());\n+        }\n+\n+        return merge_origins(origins);\n+    }\n+\n+    shared_origin simple_config_origin::merge_origins(std::vector<shared_origin> const& stack) {\n+        if (stack.empty()) {\n+            throw config_exception(\"can't merge empty list of origins\");\n+        } else if (stack.size() == 1) {\n+            return stack.front();\n+        } else if (stack.size() == 2) {\n+            return(merge_two(dynamic_pointer_cast<const simple_config_origin>(stack[0]),\n+                             dynamic_pointer_cast<const simple_config_origin>(stack[1])));\n+        } else {\n+            vector<shared_origin> remaining;\n+            for (auto& o : stack) {\n+                remaining.push_back(dynamic_pointer_cast<const simple_config_origin>(o));\n+            }\n+            while (remaining.size() > 2) {\n+                auto c = dynamic_pointer_cast<const simple_config_origin>(remaining.back());\n+                remaining.pop_back();\n+                auto b = dynamic_pointer_cast<const simple_config_origin>(remaining.back());\n+                remaining.pop_back();\n+                auto a = dynamic_pointer_cast<const simple_config_origin>(remaining.back());\n+                remaining.pop_back();\n+\n+                shared_origin merged = merge_three(a, b, c);\n+                remaining.push_back(merged);\n+            }\n+\n+            //  should be down to either 1 or 2\n+            return merge_origins(remaining);\n+        }\n+    }\n+\n+    shared_ptr<const simple_config_origin> simple_config_origin::merge_two(shared_ptr<const simple_config_origin> a,\n+                                                                           shared_ptr<const simple_config_origin> b) {\n+        string merged_desc;\n+        int merged_start_line;\n+        int merged_end_line;\n+\n+        origin_type merged_type;\n+        if (a->_origin_type == b->_origin_type) {\n+            merged_type = a->_origin_type;\n+        } else {\n+            merged_type = origin_type::GENERIC;\n+        }\n+\n+        const string MERGE_OF_PREFIX { \"merge of \" };","path":"lib/src/simple_config_origin.cc","position":68,"original_position":68,"commit_id":"be3ed52b5ef4ce481b8f98ced87518bea6c1c6d9","original_commit_id":"be3ed52b5ef4ce481b8f98ced87518bea6c1c6d9","user":{"login":"MikaelSmith","id":8162496,"avatar_url":"https://avatars.githubusercontent.com/u/8162496?v=3","gravatar_id":"","url":"https://api.github.com/users/MikaelSmith","html_url":"https://github.com/MikaelSmith","followers_url":"https://api.github.com/users/MikaelSmith/followers","following_url":"https://api.github.com/users/MikaelSmith/following{/other_user}","gists_url":"https://api.github.com/users/MikaelSmith/gists{/gist_id}","starred_url":"https://api.github.com/users/MikaelSmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MikaelSmith/subscriptions","organizations_url":"https://api.github.com/users/MikaelSmith/orgs","repos_url":"https://api.github.com/users/MikaelSmith/repos","events_url":"https://api.github.com/users/MikaelSmith/events{/privacy}","received_events_url":"https://api.github.com/users/MikaelSmith/received_events","type":"User","site_admin":false},"body":"Might as well make it `static`, to match the original.","created_at":"2016-01-11T22:14:49Z","updated_at":"2016-01-11T22:14:49Z","html_url":"https://github.com/puppetlabs/cpp-hocon/pull/25#discussion_r49387371","pull_request_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/pulls/25","_links":{"self":{"href":"https://api.github.com/repos/puppetlabs/cpp-hocon/pulls/comments/49387371"},"html":{"href":"https://github.com/puppetlabs/cpp-hocon/pull/25#discussion_r49387371"},"pull_request":{"href":"https://api.github.com/repos/puppetlabs/cpp-hocon/pulls/25"}}},"pull_request":{"url":"https://api.github.com/repos/puppetlabs/cpp-hocon/pulls/25","id":54835267,"html_url":"https://github.com/puppetlabs/cpp-hocon/pull/25","diff_url":"https://github.com/puppetlabs/cpp-hocon/pull/25.diff","patch_url":"https://github.com/puppetlabs/cpp-hocon/pull/25.patch","issue_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/issues/25","number":25,"state":"open","locked":false,"title":"(HC-41) Port Merge-related classes and ConfigValue::merge* methods","user":{"login":"whopper","id":507621,"avatar_url":"https://avatars.githubusercontent.com/u/507621?v=3","gravatar_id":"","url":"https://api.github.com/users/whopper","html_url":"https://github.com/whopper","followers_url":"https://api.github.com/users/whopper/followers","following_url":"https://api.github.com/users/whopper/following{/other_user}","gists_url":"https://api.github.com/users/whopper/gists{/gist_id}","starred_url":"https://api.github.com/users/whopper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/whopper/subscriptions","organizations_url":"https://api.github.com/users/whopper/orgs","repos_url":"https://api.github.com/users/whopper/repos","events_url":"https://api.github.com/users/whopper/events{/privacy}","received_events_url":"https://api.github.com/users/whopper/received_events","type":"User","site_admin":false},"body":"The first of these commits ports skeletons of the configDelayedMergeObject\r\nand configDelayedMerge classes, as well as the mergeableValue\r\ninterface. These are all needed for the work in the second commit, which ports each of the config  merge-related methods of ConfigValue, which are needed by the ConfigConcatenation class. They include:\r\n\r\n```\r\nConfigValue::mergedWithTheUnmergeable,\r\nConfigValue::MergedWithObject,\r\nConfigValue::MergedWithNonObject,\r\nConfigValue::ConstructDelayedMerge,\r\nConfigValue::withFallback\r\n```\r\n\r\nAlso ported are various other things necessary for ConfigConcatenation, including:\r\n\r\n```\r\nSimpleConfigOrigin::mergeOrigins\r\nSimpleConfigOrigin::mergeTwo\r\nConfigObject::mergeOrigins\r\nConfigImplUtil class\r\n```","created_at":"2015-12-30T22:38:38Z","updated_at":"2016-01-11T22:14:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"443588539c7f90b7b99a020661e3d193a5bf778c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/pulls/25/commits","review_comments_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/pulls/25/comments","review_comment_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/pulls/comments{/number}","comments_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/issues/25/comments","statuses_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/statuses/be3ed52b5ef4ce481b8f98ced87518bea6c1c6d9","head":{"label":"whopper:HC-41/master/config_value_merge","ref":"HC-41/master/config_value_merge","sha":"be3ed52b5ef4ce481b8f98ced87518bea6c1c6d9","user":{"login":"whopper","id":507621,"avatar_url":"https://avatars.githubusercontent.com/u/507621?v=3","gravatar_id":"","url":"https://api.github.com/users/whopper","html_url":"https://github.com/whopper","followers_url":"https://api.github.com/users/whopper/followers","following_url":"https://api.github.com/users/whopper/following{/other_user}","gists_url":"https://api.github.com/users/whopper/gists{/gist_id}","starred_url":"https://api.github.com/users/whopper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/whopper/subscriptions","organizations_url":"https://api.github.com/users/whopper/orgs","repos_url":"https://api.github.com/users/whopper/repos","events_url":"https://api.github.com/users/whopper/events{/privacy}","received_events_url":"https://api.github.com/users/whopper/received_events","type":"User","site_admin":false},"repo":{"id":40024499,"name":"cpp-hocon","full_name":"whopper/cpp-hocon","owner":{"login":"whopper","id":507621,"avatar_url":"https://avatars.githubusercontent.com/u/507621?v=3","gravatar_id":"","url":"https://api.github.com/users/whopper","html_url":"https://github.com/whopper","followers_url":"https://api.github.com/users/whopper/followers","following_url":"https://api.github.com/users/whopper/following{/other_user}","gists_url":"https://api.github.com/users/whopper/gists{/gist_id}","starred_url":"https://api.github.com/users/whopper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/whopper/subscriptions","organizations_url":"https://api.github.com/users/whopper/orgs","repos_url":"https://api.github.com/users/whopper/repos","events_url":"https://api.github.com/users/whopper/events{/privacy}","received_events_url":"https://api.github.com/users/whopper/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/whopper/cpp-hocon","description":"A C++ port of the Typesafe Config library.","fork":true,"url":"https://api.github.com/repos/whopper/cpp-hocon","forks_url":"https://api.github.com/repos/whopper/cpp-hocon/forks","keys_url":"https://api.github.com/repos/whopper/cpp-hocon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/whopper/cpp-hocon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/whopper/cpp-hocon/teams","hooks_url":"https://api.github.com/repos/whopper/cpp-hocon/hooks","issue_events_url":"https://api.github.com/repos/whopper/cpp-hocon/issues/events{/number}","events_url":"https://api.github.com/repos/whopper/cpp-hocon/events","assignees_url":"https://api.github.com/repos/whopper/cpp-hocon/assignees{/user}","branches_url":"https://api.github.com/repos/whopper/cpp-hocon/branches{/branch}","tags_url":"https://api.github.com/repos/whopper/cpp-hocon/tags","blobs_url":"https://api.github.com/repos/whopper/cpp-hocon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/whopper/cpp-hocon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/whopper/cpp-hocon/git/refs{/sha}","trees_url":"https://api.github.com/repos/whopper/cpp-hocon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/whopper/cpp-hocon/statuses/{sha}","languages_url":"https://api.github.com/repos/whopper/cpp-hocon/languages","stargazers_url":"https://api.github.com/repos/whopper/cpp-hocon/stargazers","contributors_url":"https://api.github.com/repos/whopper/cpp-hocon/contributors","subscribers_url":"https://api.github.com/repos/whopper/cpp-hocon/subscribers","subscription_url":"https://api.github.com/repos/whopper/cpp-hocon/subscription","commits_url":"https://api.github.com/repos/whopper/cpp-hocon/commits{/sha}","git_commits_url":"https://api.github.com/repos/whopper/cpp-hocon/git/commits{/sha}","comments_url":"https://api.github.com/repos/whopper/cpp-hocon/comments{/number}","issue_comment_url":"https://api.github.com/repos/whopper/cpp-hocon/issues/comments{/number}","contents_url":"https://api.github.com/repos/whopper/cpp-hocon/contents/{+path}","compare_url":"https://api.github.com/repos/whopper/cpp-hocon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/whopper/cpp-hocon/merges","archive_url":"https://api.github.com/repos/whopper/cpp-hocon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/whopper/cpp-hocon/downloads","issues_url":"https://api.github.com/repos/whopper/cpp-hocon/issues{/number}","pulls_url":"https://api.github.com/repos/whopper/cpp-hocon/pulls{/number}","milestones_url":"https://api.github.com/repos/whopper/cpp-hocon/milestones{/number}","notifications_url":"https://api.github.com/repos/whopper/cpp-hocon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/whopper/cpp-hocon/labels{/name}","releases_url":"https://api.github.com/repos/whopper/cpp-hocon/releases{/id}","created_at":"2015-07-31T20:53:52Z","updated_at":"2015-07-31T20:53:53Z","pushed_at":"2016-01-11T21:47:20Z","git_url":"git://github.com/whopper/cpp-hocon.git","ssh_url":"git@github.com:whopper/cpp-hocon.git","clone_url":"https://github.com/whopper/cpp-hocon.git","svn_url":"https://github.com/whopper/cpp-hocon","homepage":null,"size":294,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"puppetlabs:master","ref":"master","sha":"20992c2901bb6d09ff9a9e57772831c71e724fb9","user":{"login":"puppetlabs","id":234268,"avatar_url":"https://avatars.githubusercontent.com/u/234268?v=3","gravatar_id":"","url":"https://api.github.com/users/puppetlabs","html_url":"https://github.com/puppetlabs","followers_url":"https://api.github.com/users/puppetlabs/followers","following_url":"https://api.github.com/users/puppetlabs/following{/other_user}","gists_url":"https://api.github.com/users/puppetlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/puppetlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/puppetlabs/subscriptions","organizations_url":"https://api.github.com/users/puppetlabs/orgs","repos_url":"https://api.github.com/users/puppetlabs/repos","events_url":"https://api.github.com/users/puppetlabs/events{/privacy}","received_events_url":"https://api.github.com/users/puppetlabs/received_events","type":"Organization","site_admin":false},"repo":{"id":39804492,"name":"cpp-hocon","full_name":"puppetlabs/cpp-hocon","owner":{"login":"puppetlabs","id":234268,"avatar_url":"https://avatars.githubusercontent.com/u/234268?v=3","gravatar_id":"","url":"https://api.github.com/users/puppetlabs","html_url":"https://github.com/puppetlabs","followers_url":"https://api.github.com/users/puppetlabs/followers","following_url":"https://api.github.com/users/puppetlabs/following{/other_user}","gists_url":"https://api.github.com/users/puppetlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/puppetlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/puppetlabs/subscriptions","organizations_url":"https://api.github.com/users/puppetlabs/orgs","repos_url":"https://api.github.com/users/puppetlabs/repos","events_url":"https://api.github.com/users/puppetlabs/events{/privacy}","received_events_url":"https://api.github.com/users/puppetlabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/puppetlabs/cpp-hocon","description":"A C++ port of the Typesafe Config library.","fork":false,"url":"https://api.github.com/repos/puppetlabs/cpp-hocon","forks_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/forks","keys_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/teams","hooks_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/hooks","issue_events_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/issues/events{/number}","events_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/events","assignees_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/assignees{/user}","branches_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/branches{/branch}","tags_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/tags","blobs_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/git/refs{/sha}","trees_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/statuses/{sha}","languages_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/languages","stargazers_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/stargazers","contributors_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/contributors","subscribers_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/subscribers","subscription_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/subscription","commits_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/commits{/sha}","git_commits_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/git/commits{/sha}","comments_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/comments{/number}","issue_comment_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/issues/comments{/number}","contents_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/contents/{+path}","compare_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/merges","archive_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/downloads","issues_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/issues{/number}","pulls_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/pulls{/number}","milestones_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/milestones{/number}","notifications_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/labels{/name}","releases_url":"https://api.github.com/repos/puppetlabs/cpp-hocon/releases{/id}","created_at":"2015-07-28T00:23:00Z","updated_at":"2016-01-11T21:43:36Z","pushed_at":"2016-01-11T21:47:20Z","git_url":"git://github.com/puppetlabs/cpp-hocon.git","ssh_url":"git@github.com:puppetlabs/cpp-hocon.git","clone_url":"https://github.com/puppetlabs/cpp-hocon.git","svn_url":"https://github.com/puppetlabs/cpp-hocon","homepage":null,"size":334,"stargazers_count":2,"watchers_count":2,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":3,"forks":7,"open_issues":3,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/puppetlabs/cpp-hocon/pulls/25"},"html":{"href":"https://github.com/puppetlabs/cpp-hocon/pull/25"},"issue":{"href":"https://api.github.com/repos/puppetlabs/cpp-hocon/issues/25"},"comments":{"href":"https://api.github.com/repos/puppetlabs/cpp-hocon/issues/25/comments"},"review_comments":{"href":"https://api.github.com/repos/puppetlabs/cpp-hocon/pulls/25/comments"},"review_comment":{"href":"https://api.github.com/repos/puppetlabs/cpp-hocon/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/puppetlabs/cpp-hocon/pulls/25/commits"},"statuses":{"href":"https://api.github.com/repos/puppetlabs/cpp-hocon/statuses/be3ed52b5ef4ce481b8f98ced87518bea6c1c6d9"}}}}