{"action":"created","comment":{"url":"https://api.github.com/repos/open-craft/problem-builder/pulls/comments/27791296","id":27791296,"diff_hunk":"@@ -148,15 +144,46 @@ def parse_xml_for_HtmlDescriptor(cls, node, runtime, keys, id_generator):\n     blocks_found = []\n \n     def find_mentoring_blocks(block):\n-        if isinstance(block, MentoringBlock) and block.xml_content:  # If it's a v1 block it will have xml_content\n+        \"\"\"\n+        Find mentoring and recently-upgraded blocks. We check the recently upgraded ones\n+        in case an error happened and we're re-running the upgrade.\n+        \"\"\"\n+        # If it's a v1 block or a recently upgraded block it will have xml_content:\n+        if isinstance(block, (MentoringBlock, NewMentoringBlock)) and block.xml_content:\n             blocks_found.append(block.scope_ids.usage_id)\n         elif block.has_children:\n             for child_id in block.children:\n                 find_mentoring_blocks(block.runtime.get_block(child_id))\n     find_mentoring_blocks(course)\n+\n     total = len(blocks_found)\n     print(\" ➔ Found {} mentoring blocks\".format(total))\n \n+    print(\" ➔ Doing a quick sanity check of the url_names\")\n+    url_names = set()\n+    stop = False\n+    for block_id in blocks_found:\n+        block = course.runtime.get_block(block_id)\n+        if block.url_name in url_names:\n+            print(u\" ➔ Mentoring block {} conflicts with another block using the same url_name\".format(block.url_name))\n+            print(u'   (display_name: \"{}\", parent {}: \"{}\")'.format(\n+                block.display_name, block.parent, block.get_parent().display_name\n+            ))\n+            stop = True\n+            continue\n+        if block.url_name != unicode(block_id.block_id):\n+            print(u\" ➔ Mentoring block {} has two different url_names assigned. Real url_name is {}\".format(\n+                unicode(block_id.block_id)\n+            ))\n+            print(u'   (display_name: \"{}\", parent: \"{}\")'.format(block.display_name, block.get_parent().display_name))\n+            print(u\"   (to fix, edit the XML and set the url_name to the real value given above).\")\n+            stop = True\n+        url_names.add(block.url_name)\n+\n+    if stop:\n+        print(\" ➔ Exiting due to errors preventing the upgrade.\")\n+        sys.exit(1)","path":"problem_builder/v1/upgrade.py","position":165,"original_position":165,"commit_id":"c31038aa1184c3437dcc8dfb54e62e379803ef1f","original_commit_id":"c31038aa1184c3437dcc8dfb54e62e379803ef1f","user":{"login":"e-kolpakov","id":3330048,"avatar_url":"https://avatars.githubusercontent.com/u/3330048?v=3","gravatar_id":"","url":"https://api.github.com/users/e-kolpakov","html_url":"https://github.com/e-kolpakov","followers_url":"https://api.github.com/users/e-kolpakov/followers","following_url":"https://api.github.com/users/e-kolpakov/following{/other_user}","gists_url":"https://api.github.com/users/e-kolpakov/gists{/gist_id}","starred_url":"https://api.github.com/users/e-kolpakov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/e-kolpakov/subscriptions","organizations_url":"https://api.github.com/users/e-kolpakov/orgs","repos_url":"https://api.github.com/users/e-kolpakov/repos","events_url":"https://api.github.com/users/e-kolpakov/events{/privacy}","received_events_url":"https://api.github.com/users/e-kolpakov/received_events","type":"User","site_admin":false},"body":"@bradenmacdonald nit: might make sense to merge the two lines into one:\r\n\r\n    sys.exit(\" ➔ Exiting due to errors preventing the upgrade.\")\r\n\r\nAccording to [docs](https://docs.python.org/2/library/sys.html#sys.exit) it would yeild the same exit code of 1.","created_at":"2015-04-06T10:07:20Z","updated_at":"2015-04-06T10:07:20Z","html_url":"https://github.com/open-craft/problem-builder/pull/2#discussion_r27791296","pull_request_url":"https://api.github.com/repos/open-craft/problem-builder/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/open-craft/problem-builder/pulls/comments/27791296"},"html":{"href":"https://github.com/open-craft/problem-builder/pull/2#discussion_r27791296"},"pull_request":{"href":"https://api.github.com/repos/open-craft/problem-builder/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/open-craft/problem-builder/pulls/2","id":32569807,"html_url":"https://github.com/open-craft/problem-builder/pull/2","diff_url":"https://github.com/open-craft/problem-builder/pull/2.diff","patch_url":"https://github.com/open-craft/problem-builder/pull/2.patch","issue_url":"https://api.github.com/repos/open-craft/problem-builder/issues/2","number":2,"state":"open","locked":false,"title":"Upgrade Script","user":{"login":"bradenmacdonald","id":945577,"avatar_url":"https://avatars.githubusercontent.com/u/945577?v=3","gravatar_id":"","url":"https://api.github.com/users/bradenmacdonald","html_url":"https://github.com/bradenmacdonald","followers_url":"https://api.github.com/users/bradenmacdonald/followers","following_url":"https://api.github.com/users/bradenmacdonald/following{/other_user}","gists_url":"https://api.github.com/users/bradenmacdonald/gists{/gist_id}","starred_url":"https://api.github.com/users/bradenmacdonald/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bradenmacdonald/subscriptions","organizations_url":"https://api.github.com/users/bradenmacdonald/orgs","repos_url":"https://api.github.com/users/bradenmacdonald/repos","events_url":"https://api.github.com/users/bradenmacdonald/events{/privacy}","received_events_url":"https://api.github.com/users/bradenmacdonald/received_events","type":"User","site_admin":false},"body":"When testing the upgrade path from mentoring v1 to problem builder (mentoring v2), I found a few bugs in the upgrade script:\r\n* if `<tip>` elements had a `width` or `height`, they wouldn't work\r\n* Warnings from the XML upgrade script were not displayed to the user\r\n* Did not convert the actual block type from `mentoring` to `problem-builder`\r\n\r\nI also added a check for multiple blocks that have the same `url_name`, since that should not happen but it is the case on some courses I worked with.\r\n\r\nNote:\r\n* This is based on PR #1 so ignore the many changes coming from that\r\n* This is irrelevant to new courses - it only affects upgrading an old course.","created_at":"2015-04-03T04:45:10Z","updated_at":"2015-04-06T10:07:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4ee0a4ba4857cc35e6ee64f14d3a4326b5df55b6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/open-craft/problem-builder/pulls/2/commits","review_comments_url":"https://api.github.com/repos/open-craft/problem-builder/pulls/2/comments","review_comment_url":"https://api.github.com/repos/open-craft/problem-builder/pulls/comments{/number}","comments_url":"https://api.github.com/repos/open-craft/problem-builder/issues/2/comments","statuses_url":"https://api.github.com/repos/open-craft/problem-builder/statuses/c31038aa1184c3437dcc8dfb54e62e379803ef1f","head":{"label":"open-craft:mcka-upgrade-bug-fix","ref":"mcka-upgrade-bug-fix","sha":"c31038aa1184c3437dcc8dfb54e62e379803ef1f","user":{"login":"open-craft","id":7414786,"avatar_url":"https://avatars.githubusercontent.com/u/7414786?v=3","gravatar_id":"","url":"https://api.github.com/users/open-craft","html_url":"https://github.com/open-craft","followers_url":"https://api.github.com/users/open-craft/followers","following_url":"https://api.github.com/users/open-craft/following{/other_user}","gists_url":"https://api.github.com/users/open-craft/gists{/gist_id}","starred_url":"https://api.github.com/users/open-craft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/open-craft/subscriptions","organizations_url":"https://api.github.com/users/open-craft/orgs","repos_url":"https://api.github.com/users/open-craft/repos","events_url":"https://api.github.com/users/open-craft/events{/privacy}","received_events_url":"https://api.github.com/users/open-craft/received_events","type":"Organization","site_admin":false},"repo":{"id":33264452,"name":"problem-builder","full_name":"open-craft/problem-builder","owner":{"login":"open-craft","id":7414786,"avatar_url":"https://avatars.githubusercontent.com/u/7414786?v=3","gravatar_id":"","url":"https://api.github.com/users/open-craft","html_url":"https://github.com/open-craft","followers_url":"https://api.github.com/users/open-craft/followers","following_url":"https://api.github.com/users/open-craft/following{/other_user}","gists_url":"https://api.github.com/users/open-craft/gists{/gist_id}","starred_url":"https://api.github.com/users/open-craft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/open-craft/subscriptions","organizations_url":"https://api.github.com/users/open-craft/orgs","repos_url":"https://api.github.com/users/open-craft/repos","events_url":"https://api.github.com/users/open-craft/events{/privacy}","received_events_url":"https://api.github.com/users/open-craft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/open-craft/problem-builder","description":"An XBlock for posing questions to students","fork":false,"url":"https://api.github.com/repos/open-craft/problem-builder","forks_url":"https://api.github.com/repos/open-craft/problem-builder/forks","keys_url":"https://api.github.com/repos/open-craft/problem-builder/keys{/key_id}","collaborators_url":"https://api.github.com/repos/open-craft/problem-builder/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/open-craft/problem-builder/teams","hooks_url":"https://api.github.com/repos/open-craft/problem-builder/hooks","issue_events_url":"https://api.github.com/repos/open-craft/problem-builder/issues/events{/number}","events_url":"https://api.github.com/repos/open-craft/problem-builder/events","assignees_url":"https://api.github.com/repos/open-craft/problem-builder/assignees{/user}","branches_url":"https://api.github.com/repos/open-craft/problem-builder/branches{/branch}","tags_url":"https://api.github.com/repos/open-craft/problem-builder/tags","blobs_url":"https://api.github.com/repos/open-craft/problem-builder/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/open-craft/problem-builder/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/open-craft/problem-builder/git/refs{/sha}","trees_url":"https://api.github.com/repos/open-craft/problem-builder/git/trees{/sha}","statuses_url":"https://api.github.com/repos/open-craft/problem-builder/statuses/{sha}","languages_url":"https://api.github.com/repos/open-craft/problem-builder/languages","stargazers_url":"https://api.github.com/repos/open-craft/problem-builder/stargazers","contributors_url":"https://api.github.com/repos/open-craft/problem-builder/contributors","subscribers_url":"https://api.github.com/repos/open-craft/problem-builder/subscribers","subscription_url":"https://api.github.com/repos/open-craft/problem-builder/subscription","commits_url":"https://api.github.com/repos/open-craft/problem-builder/commits{/sha}","git_commits_url":"https://api.github.com/repos/open-craft/problem-builder/git/commits{/sha}","comments_url":"https://api.github.com/repos/open-craft/problem-builder/comments{/number}","issue_comment_url":"https://api.github.com/repos/open-craft/problem-builder/issues/comments{/number}","contents_url":"https://api.github.com/repos/open-craft/problem-builder/contents/{+path}","compare_url":"https://api.github.com/repos/open-craft/problem-builder/compare/{base}...{head}","merges_url":"https://api.github.com/repos/open-craft/problem-builder/merges","archive_url":"https://api.github.com/repos/open-craft/problem-builder/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/open-craft/problem-builder/downloads","issues_url":"https://api.github.com/repos/open-craft/problem-builder/issues{/number}","pulls_url":"https://api.github.com/repos/open-craft/problem-builder/pulls{/number}","milestones_url":"https://api.github.com/repos/open-craft/problem-builder/milestones{/number}","notifications_url":"https://api.github.com/repos/open-craft/problem-builder/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/open-craft/problem-builder/labels{/name}","releases_url":"https://api.github.com/repos/open-craft/problem-builder/releases{/id}","created_at":"2015-04-01T18:18:42Z","updated_at":"2015-04-03T20:47:06Z","pushed_at":"2015-04-03T23:35:07Z","git_url":"git://github.com/open-craft/problem-builder.git","ssh_url":"git@github.com:open-craft/problem-builder.git","clone_url":"https://github.com/open-craft/problem-builder.git","svn_url":"https://github.com/open-craft/problem-builder","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"open-craft:master","ref":"master","sha":"700f1834c0e8249ce9273c58ad074a1391939cd5","user":{"login":"open-craft","id":7414786,"avatar_url":"https://avatars.githubusercontent.com/u/7414786?v=3","gravatar_id":"","url":"https://api.github.com/users/open-craft","html_url":"https://github.com/open-craft","followers_url":"https://api.github.com/users/open-craft/followers","following_url":"https://api.github.com/users/open-craft/following{/other_user}","gists_url":"https://api.github.com/users/open-craft/gists{/gist_id}","starred_url":"https://api.github.com/users/open-craft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/open-craft/subscriptions","organizations_url":"https://api.github.com/users/open-craft/orgs","repos_url":"https://api.github.com/users/open-craft/repos","events_url":"https://api.github.com/users/open-craft/events{/privacy}","received_events_url":"https://api.github.com/users/open-craft/received_events","type":"Organization","site_admin":false},"repo":{"id":33264452,"name":"problem-builder","full_name":"open-craft/problem-builder","owner":{"login":"open-craft","id":7414786,"avatar_url":"https://avatars.githubusercontent.com/u/7414786?v=3","gravatar_id":"","url":"https://api.github.com/users/open-craft","html_url":"https://github.com/open-craft","followers_url":"https://api.github.com/users/open-craft/followers","following_url":"https://api.github.com/users/open-craft/following{/other_user}","gists_url":"https://api.github.com/users/open-craft/gists{/gist_id}","starred_url":"https://api.github.com/users/open-craft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/open-craft/subscriptions","organizations_url":"https://api.github.com/users/open-craft/orgs","repos_url":"https://api.github.com/users/open-craft/repos","events_url":"https://api.github.com/users/open-craft/events{/privacy}","received_events_url":"https://api.github.com/users/open-craft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/open-craft/problem-builder","description":"An XBlock for posing questions to students","fork":false,"url":"https://api.github.com/repos/open-craft/problem-builder","forks_url":"https://api.github.com/repos/open-craft/problem-builder/forks","keys_url":"https://api.github.com/repos/open-craft/problem-builder/keys{/key_id}","collaborators_url":"https://api.github.com/repos/open-craft/problem-builder/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/open-craft/problem-builder/teams","hooks_url":"https://api.github.com/repos/open-craft/problem-builder/hooks","issue_events_url":"https://api.github.com/repos/open-craft/problem-builder/issues/events{/number}","events_url":"https://api.github.com/repos/open-craft/problem-builder/events","assignees_url":"https://api.github.com/repos/open-craft/problem-builder/assignees{/user}","branches_url":"https://api.github.com/repos/open-craft/problem-builder/branches{/branch}","tags_url":"https://api.github.com/repos/open-craft/problem-builder/tags","blobs_url":"https://api.github.com/repos/open-craft/problem-builder/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/open-craft/problem-builder/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/open-craft/problem-builder/git/refs{/sha}","trees_url":"https://api.github.com/repos/open-craft/problem-builder/git/trees{/sha}","statuses_url":"https://api.github.com/repos/open-craft/problem-builder/statuses/{sha}","languages_url":"https://api.github.com/repos/open-craft/problem-builder/languages","stargazers_url":"https://api.github.com/repos/open-craft/problem-builder/stargazers","contributors_url":"https://api.github.com/repos/open-craft/problem-builder/contributors","subscribers_url":"https://api.github.com/repos/open-craft/problem-builder/subscribers","subscription_url":"https://api.github.com/repos/open-craft/problem-builder/subscription","commits_url":"https://api.github.com/repos/open-craft/problem-builder/commits{/sha}","git_commits_url":"https://api.github.com/repos/open-craft/problem-builder/git/commits{/sha}","comments_url":"https://api.github.com/repos/open-craft/problem-builder/comments{/number}","issue_comment_url":"https://api.github.com/repos/open-craft/problem-builder/issues/comments{/number}","contents_url":"https://api.github.com/repos/open-craft/problem-builder/contents/{+path}","compare_url":"https://api.github.com/repos/open-craft/problem-builder/compare/{base}...{head}","merges_url":"https://api.github.com/repos/open-craft/problem-builder/merges","archive_url":"https://api.github.com/repos/open-craft/problem-builder/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/open-craft/problem-builder/downloads","issues_url":"https://api.github.com/repos/open-craft/problem-builder/issues{/number}","pulls_url":"https://api.github.com/repos/open-craft/problem-builder/pulls{/number}","milestones_url":"https://api.github.com/repos/open-craft/problem-builder/milestones{/number}","notifications_url":"https://api.github.com/repos/open-craft/problem-builder/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/open-craft/problem-builder/labels{/name}","releases_url":"https://api.github.com/repos/open-craft/problem-builder/releases{/id}","created_at":"2015-04-01T18:18:42Z","updated_at":"2015-04-03T20:47:06Z","pushed_at":"2015-04-03T23:35:07Z","git_url":"git://github.com/open-craft/problem-builder.git","ssh_url":"git@github.com:open-craft/problem-builder.git","clone_url":"https://github.com/open-craft/problem-builder.git","svn_url":"https://github.com/open-craft/problem-builder","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/open-craft/problem-builder/pulls/2"},"html":{"href":"https://github.com/open-craft/problem-builder/pull/2"},"issue":{"href":"https://api.github.com/repos/open-craft/problem-builder/issues/2"},"comments":{"href":"https://api.github.com/repos/open-craft/problem-builder/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/open-craft/problem-builder/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/open-craft/problem-builder/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/open-craft/problem-builder/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/open-craft/problem-builder/statuses/c31038aa1184c3437dcc8dfb54e62e379803ef1f"}}}}