{"action":"created","comment":{"url":"https://api.github.com/repos/attic-labs/noms/pulls/comments/77892746","id":77892746,"diff_hunk":"@@ -91,6 +99,52 @@ func nomsMerge() error {\n \t}))\n }\n \n+func cliResolve(in io.Reader, out io.Writer, aType, bType types.DiffChangeType, a, b types.Value, path types.Path) (change types.DiffChangeType, merged types.Value, ok bool) {\n+\tstringer := func(v types.Value) (s string, success bool) {\n+\t\tswitch v := v.(type) {\n+\t\tcase types.Bool, types.Number, types.String:\n+\t\t\treturn fmt.Sprintf(\"%v\", v), true\n+\t\t}\n+\t\treturn \"\", false\n+\t}\n+\tleft, lOk := stringer(a)\n+\tright, rOk := stringer(b)\n+\tif !lOk || !rOk {\n+\t\treturn change, merged, false\n+\t}\n+\n+\t// TODO: Handle removes as well.\n+\tfmt.Fprintf(out, \"\\nConflict at: %s\\n\", path.String())\n+\tfmt.Fprintf(out, \"Left:  %s\\nRight: %s\\n\\n\", left, right)\n+\tvar choice rune\n+\tfor {\n+\t\tfmt.Fprintln(out, \"Enter 'l' to accept the left value, 'r' to accept the right value, or 'm' to mash them together\")\n+\t\t_, err := fmt.Fscanf(in, \"%c\\n\", &choice)\n+\t\td.PanicIfError(err)\n+\t\tswitch choice {\n+\t\tcase 'l', 'L':\n+\t\t\treturn aType, a, true\n+\t\tcase 'r', 'R':\n+\t\t\treturn bType, b, true\n+\t\tcase 'm', 'M':\n+\t\t\tif !a.Type().Equals(b.Type()) {\n+\t\t\t\tfmt.Fprintf(out, \"Sorry, can't merge a %s with a %s\\n\", a.Type().Describe(), b.Type().Describe())\n+\t\t\t\treturn change, merged, false\n+\t\t\t}\n+\t\t\tswitch a := a.(type) {\n+\t\t\tcase types.Bool:\n+\t\t\t\treturn aType, types.Bool(bool(a) || bool(b.(types.Bool))), true\n+\t\t\tcase types.Number:\n+\t\t\t\treturn aType, types.Number(float64(a) + float64(b.(types.Number))), true\n+\t\t\tcase types.String:\n+\t\t\t\tconcatenated := string(a) + string(b.(types.String))\n+\t\t\t\tfmt.Fprintln(out, \"Replacing with\", concatenated)","path":"samples/go/noms-merge/main.go","position":75,"original_position":75,"commit_id":"ecd1a3aa29403be5cbf7d6a9c63cd097710c1a91","original_commit_id":"ecd1a3aa29403be5cbf7d6a9c63cd097710c1a91","user":{"login":"kalman","id":657134,"avatar_url":"https://avatars.githubusercontent.com/u/657134?v=3","gravatar_id":"","url":"https://api.github.com/users/kalman","html_url":"https://github.com/kalman","followers_url":"https://api.github.com/users/kalman/followers","following_url":"https://api.github.com/users/kalman/following{/other_user}","gists_url":"https://api.github.com/users/kalman/gists{/gist_id}","starred_url":"https://api.github.com/users/kalman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kalman/subscriptions","organizations_url":"https://api.github.com/users/kalman/orgs","repos_url":"https://api.github.com/users/kalman/repos","events_url":"https://api.github.com/users/kalman/events{/privacy}","received_events_url":"https://api.github.com/users/kalman/received_events","type":"User","site_admin":false},"body":"Should this \"replacing with\" output be shown for bool/number as well?","created_at":"2016-09-07T19:59:42Z","updated_at":"2016-09-07T19:59:42Z","html_url":"https://github.com/attic-labs/noms/pull/2505#discussion_r77892746","pull_request_url":"https://api.github.com/repos/attic-labs/noms/pulls/2505","_links":{"self":{"href":"https://api.github.com/repos/attic-labs/noms/pulls/comments/77892746"},"html":{"href":"https://github.com/attic-labs/noms/pull/2505#discussion_r77892746"},"pull_request":{"href":"https://api.github.com/repos/attic-labs/noms/pulls/2505"}}},"pull_request":{"url":"https://api.github.com/repos/attic-labs/noms/pulls/2505","id":83728247,"html_url":"https://github.com/attic-labs/noms/pull/2505","diff_url":"https://github.com/attic-labs/noms/pull/2505.diff","patch_url":"https://github.com/attic-labs/noms/pull/2505.patch","issue_url":"https://api.github.com/repos/attic-labs/noms/issues/2505","number":2505,"state":"open","locked":false,"title":"Update merge.ThreeWay() to allow very basic custom conflict resolution","user":{"login":"cmasone-attic","id":13224090,"avatar_url":"https://avatars.githubusercontent.com/u/13224090?v=3","gravatar_id":"","url":"https://api.github.com/users/cmasone-attic","html_url":"https://github.com/cmasone-attic","followers_url":"https://api.github.com/users/cmasone-attic/followers","following_url":"https://api.github.com/users/cmasone-attic/following{/other_user}","gists_url":"https://api.github.com/users/cmasone-attic/gists{/gist_id}","starred_url":"https://api.github.com/users/cmasone-attic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmasone-attic/subscriptions","organizations_url":"https://api.github.com/users/cmasone-attic/orgs","repos_url":"https://api.github.com/users/cmasone-attic/repos","events_url":"https://api.github.com/users/cmasone-attic/events{/privacy}","received_events_url":"https://api.github.com/users/cmasone-attic/received_events","type":"User","site_admin":false},"body":"This patch modifies merge.ThreeWay() to take a callback that allows\r\nfor custom conflict resolution. The noms-merge command-line tool uses\r\nthis to inject a callback that accepts input from the console\r\ndictating whether to accept the value from the 'left' or 'right' merge\r\ncandidates.\r\n\r\nToward #2445","created_at":"2016-09-02T00:20:47Z","updated_at":"2016-09-07T19:59:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4ffb2f0eeabf61b29f0c1f3b5770d077505419f6","assignee":{"login":"kalman","id":657134,"avatar_url":"https://avatars.githubusercontent.com/u/657134?v=3","gravatar_id":"","url":"https://api.github.com/users/kalman","html_url":"https://github.com/kalman","followers_url":"https://api.github.com/users/kalman/followers","following_url":"https://api.github.com/users/kalman/following{/other_user}","gists_url":"https://api.github.com/users/kalman/gists{/gist_id}","starred_url":"https://api.github.com/users/kalman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kalman/subscriptions","organizations_url":"https://api.github.com/users/kalman/orgs","repos_url":"https://api.github.com/users/kalman/repos","events_url":"https://api.github.com/users/kalman/events{/privacy}","received_events_url":"https://api.github.com/users/kalman/received_events","type":"User","site_admin":false},"assignees":[{"login":"kalman","id":657134,"avatar_url":"https://avatars.githubusercontent.com/u/657134?v=3","gravatar_id":"","url":"https://api.github.com/users/kalman","html_url":"https://github.com/kalman","followers_url":"https://api.github.com/users/kalman/followers","following_url":"https://api.github.com/users/kalman/following{/other_user}","gists_url":"https://api.github.com/users/kalman/gists{/gist_id}","starred_url":"https://api.github.com/users/kalman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kalman/subscriptions","organizations_url":"https://api.github.com/users/kalman/orgs","repos_url":"https://api.github.com/users/kalman/repos","events_url":"https://api.github.com/users/kalman/events{/privacy}","received_events_url":"https://api.github.com/users/kalman/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/attic-labs/noms/pulls/2505/commits","review_comments_url":"https://api.github.com/repos/attic-labs/noms/pulls/2505/comments","review_comment_url":"https://api.github.com/repos/attic-labs/noms/pulls/comments{/number}","comments_url":"https://api.github.com/repos/attic-labs/noms/issues/2505/comments","statuses_url":"https://api.github.com/repos/attic-labs/noms/statuses/ecd1a3aa29403be5cbf7d6a9c63cd097710c1a91","head":{"label":"cmasone-attic:resolution","ref":"resolution","sha":"ecd1a3aa29403be5cbf7d6a9c63cd097710c1a91","user":{"login":"cmasone-attic","id":13224090,"avatar_url":"https://avatars.githubusercontent.com/u/13224090?v=3","gravatar_id":"","url":"https://api.github.com/users/cmasone-attic","html_url":"https://github.com/cmasone-attic","followers_url":"https://api.github.com/users/cmasone-attic/followers","following_url":"https://api.github.com/users/cmasone-attic/following{/other_user}","gists_url":"https://api.github.com/users/cmasone-attic/gists{/gist_id}","starred_url":"https://api.github.com/users/cmasone-attic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmasone-attic/subscriptions","organizations_url":"https://api.github.com/users/cmasone-attic/orgs","repos_url":"https://api.github.com/users/cmasone-attic/repos","events_url":"https://api.github.com/users/cmasone-attic/events{/privacy}","received_events_url":"https://api.github.com/users/cmasone-attic/received_events","type":"User","site_admin":false},"repo":{"id":64776588,"name":"noms","full_name":"cmasone-attic/noms","owner":{"login":"cmasone-attic","id":13224090,"avatar_url":"https://avatars.githubusercontent.com/u/13224090?v=3","gravatar_id":"","url":"https://api.github.com/users/cmasone-attic","html_url":"https://github.com/cmasone-attic","followers_url":"https://api.github.com/users/cmasone-attic/followers","following_url":"https://api.github.com/users/cmasone-attic/following{/other_user}","gists_url":"https://api.github.com/users/cmasone-attic/gists{/gist_id}","starred_url":"https://api.github.com/users/cmasone-attic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmasone-attic/subscriptions","organizations_url":"https://api.github.com/users/cmasone-attic/orgs","repos_url":"https://api.github.com/users/cmasone-attic/repos","events_url":"https://api.github.com/users/cmasone-attic/events{/privacy}","received_events_url":"https://api.github.com/users/cmasone-attic/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cmasone-attic/noms","description":"The versioned, forkable, syncable database","fork":true,"url":"https://api.github.com/repos/cmasone-attic/noms","forks_url":"https://api.github.com/repos/cmasone-attic/noms/forks","keys_url":"https://api.github.com/repos/cmasone-attic/noms/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cmasone-attic/noms/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cmasone-attic/noms/teams","hooks_url":"https://api.github.com/repos/cmasone-attic/noms/hooks","issue_events_url":"https://api.github.com/repos/cmasone-attic/noms/issues/events{/number}","events_url":"https://api.github.com/repos/cmasone-attic/noms/events","assignees_url":"https://api.github.com/repos/cmasone-attic/noms/assignees{/user}","branches_url":"https://api.github.com/repos/cmasone-attic/noms/branches{/branch}","tags_url":"https://api.github.com/repos/cmasone-attic/noms/tags","blobs_url":"https://api.github.com/repos/cmasone-attic/noms/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cmasone-attic/noms/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cmasone-attic/noms/git/refs{/sha}","trees_url":"https://api.github.com/repos/cmasone-attic/noms/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cmasone-attic/noms/statuses/{sha}","languages_url":"https://api.github.com/repos/cmasone-attic/noms/languages","stargazers_url":"https://api.github.com/repos/cmasone-attic/noms/stargazers","contributors_url":"https://api.github.com/repos/cmasone-attic/noms/contributors","subscribers_url":"https://api.github.com/repos/cmasone-attic/noms/subscribers","subscription_url":"https://api.github.com/repos/cmasone-attic/noms/subscription","commits_url":"https://api.github.com/repos/cmasone-attic/noms/commits{/sha}","git_commits_url":"https://api.github.com/repos/cmasone-attic/noms/git/commits{/sha}","comments_url":"https://api.github.com/repos/cmasone-attic/noms/comments{/number}","issue_comment_url":"https://api.github.com/repos/cmasone-attic/noms/issues/comments{/number}","contents_url":"https://api.github.com/repos/cmasone-attic/noms/contents/{+path}","compare_url":"https://api.github.com/repos/cmasone-attic/noms/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cmasone-attic/noms/merges","archive_url":"https://api.github.com/repos/cmasone-attic/noms/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cmasone-attic/noms/downloads","issues_url":"https://api.github.com/repos/cmasone-attic/noms/issues{/number}","pulls_url":"https://api.github.com/repos/cmasone-attic/noms/pulls{/number}","milestones_url":"https://api.github.com/repos/cmasone-attic/noms/milestones{/number}","notifications_url":"https://api.github.com/repos/cmasone-attic/noms/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cmasone-attic/noms/labels{/name}","releases_url":"https://api.github.com/repos/cmasone-attic/noms/releases{/id}","deployments_url":"https://api.github.com/repos/cmasone-attic/noms/deployments","created_at":"2016-08-02T17:13:26Z","updated_at":"2016-08-02T17:13:27Z","pushed_at":"2016-09-07T18:37:37Z","git_url":"git://github.com/cmasone-attic/noms.git","ssh_url":"git@github.com:cmasone-attic/noms.git","clone_url":"https://github.com/cmasone-attic/noms.git","svn_url":"https://github.com/cmasone-attic/noms","homepage":"","size":25555,"stargazers_count":0,"watchers_count":0,"language":"Go","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":"attic-labs:master","ref":"master","sha":"ace91a323dd612a3b88da45043b7e1856cb3c756","user":{"login":"attic-labs","id":12534679,"avatar_url":"https://avatars.githubusercontent.com/u/12534679?v=3","gravatar_id":"","url":"https://api.github.com/users/attic-labs","html_url":"https://github.com/attic-labs","followers_url":"https://api.github.com/users/attic-labs/followers","following_url":"https://api.github.com/users/attic-labs/following{/other_user}","gists_url":"https://api.github.com/users/attic-labs/gists{/gist_id}","starred_url":"https://api.github.com/users/attic-labs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/attic-labs/subscriptions","organizations_url":"https://api.github.com/users/attic-labs/orgs","repos_url":"https://api.github.com/users/attic-labs/repos","events_url":"https://api.github.com/users/attic-labs/events{/privacy}","received_events_url":"https://api.github.com/users/attic-labs/received_events","type":"Organization","site_admin":false},"repo":{"id":36778364,"name":"noms","full_name":"attic-labs/noms","owner":{"login":"attic-labs","id":12534679,"avatar_url":"https://avatars.githubusercontent.com/u/12534679?v=3","gravatar_id":"","url":"https://api.github.com/users/attic-labs","html_url":"https://github.com/attic-labs","followers_url":"https://api.github.com/users/attic-labs/followers","following_url":"https://api.github.com/users/attic-labs/following{/other_user}","gists_url":"https://api.github.com/users/attic-labs/gists{/gist_id}","starred_url":"https://api.github.com/users/attic-labs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/attic-labs/subscriptions","organizations_url":"https://api.github.com/users/attic-labs/orgs","repos_url":"https://api.github.com/users/attic-labs/repos","events_url":"https://api.github.com/users/attic-labs/events{/privacy}","received_events_url":"https://api.github.com/users/attic-labs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/attic-labs/noms","description":"The versioned, forkable, syncable database","fork":false,"url":"https://api.github.com/repos/attic-labs/noms","forks_url":"https://api.github.com/repos/attic-labs/noms/forks","keys_url":"https://api.github.com/repos/attic-labs/noms/keys{/key_id}","collaborators_url":"https://api.github.com/repos/attic-labs/noms/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/attic-labs/noms/teams","hooks_url":"https://api.github.com/repos/attic-labs/noms/hooks","issue_events_url":"https://api.github.com/repos/attic-labs/noms/issues/events{/number}","events_url":"https://api.github.com/repos/attic-labs/noms/events","assignees_url":"https://api.github.com/repos/attic-labs/noms/assignees{/user}","branches_url":"https://api.github.com/repos/attic-labs/noms/branches{/branch}","tags_url":"https://api.github.com/repos/attic-labs/noms/tags","blobs_url":"https://api.github.com/repos/attic-labs/noms/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/attic-labs/noms/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/attic-labs/noms/git/refs{/sha}","trees_url":"https://api.github.com/repos/attic-labs/noms/git/trees{/sha}","statuses_url":"https://api.github.com/repos/attic-labs/noms/statuses/{sha}","languages_url":"https://api.github.com/repos/attic-labs/noms/languages","stargazers_url":"https://api.github.com/repos/attic-labs/noms/stargazers","contributors_url":"https://api.github.com/repos/attic-labs/noms/contributors","subscribers_url":"https://api.github.com/repos/attic-labs/noms/subscribers","subscription_url":"https://api.github.com/repos/attic-labs/noms/subscription","commits_url":"https://api.github.com/repos/attic-labs/noms/commits{/sha}","git_commits_url":"https://api.github.com/repos/attic-labs/noms/git/commits{/sha}","comments_url":"https://api.github.com/repos/attic-labs/noms/comments{/number}","issue_comment_url":"https://api.github.com/repos/attic-labs/noms/issues/comments{/number}","contents_url":"https://api.github.com/repos/attic-labs/noms/contents/{+path}","compare_url":"https://api.github.com/repos/attic-labs/noms/compare/{base}...{head}","merges_url":"https://api.github.com/repos/attic-labs/noms/merges","archive_url":"https://api.github.com/repos/attic-labs/noms/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/attic-labs/noms/downloads","issues_url":"https://api.github.com/repos/attic-labs/noms/issues{/number}","pulls_url":"https://api.github.com/repos/attic-labs/noms/pulls{/number}","milestones_url":"https://api.github.com/repos/attic-labs/noms/milestones{/number}","notifications_url":"https://api.github.com/repos/attic-labs/noms/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/attic-labs/noms/labels{/name}","releases_url":"https://api.github.com/repos/attic-labs/noms/releases{/id}","deployments_url":"https://api.github.com/repos/attic-labs/noms/deployments","created_at":"2015-06-03T03:44:49Z","updated_at":"2016-09-07T16:01:07Z","pushed_at":"2016-09-07T19:52:23Z","git_url":"git://github.com/attic-labs/noms.git","ssh_url":"git@github.com:attic-labs/noms.git","clone_url":"https://github.com/attic-labs/noms.git","svn_url":"https://github.com/attic-labs/noms","homepage":"","size":29005,"stargazers_count":4220,"watchers_count":4220,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":107,"mirror_url":null,"open_issues_count":207,"forks":107,"open_issues":207,"watchers":4220,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/attic-labs/noms/pulls/2505"},"html":{"href":"https://github.com/attic-labs/noms/pull/2505"},"issue":{"href":"https://api.github.com/repos/attic-labs/noms/issues/2505"},"comments":{"href":"https://api.github.com/repos/attic-labs/noms/issues/2505/comments"},"review_comments":{"href":"https://api.github.com/repos/attic-labs/noms/pulls/2505/comments"},"review_comment":{"href":"https://api.github.com/repos/attic-labs/noms/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/attic-labs/noms/pulls/2505/commits"},"statuses":{"href":"https://api.github.com/repos/attic-labs/noms/statuses/ecd1a3aa29403be5cbf7d6a9c63cd097710c1a91"}}}}
{"actor":{"display_login":"kalman"}}