{"action":"created","comment":{"url":"https://api.github.com/repos/pulp/pulp_docker/pulls/comments/49343580","id":49343580,"diff_hunk":"@@ -180,106 +184,148 @@ def import_units(self, source_repo, dest_repo, import_conduit, config, units=Non\n         :return: list of Unit instances that were saved to the destination repository\n         :rtype:  list\n         \"\"\"\n-        units_added = []\n-        units_added.extend(DockerImporter._import_images(import_conduit, units))\n-        units_added.extend(DockerImporter._import_manifests(import_conduit, units))\n-        return units_added\n+        if units is None:\n+            criteria = UnitAssociationCriteria(\n+                type_ids=[constants.IMAGE_TYPE_ID, constants.TAG_TYPE_ID,\n+                          constants.MANIFEST_TYPE_ID, constants.BLOB_TYPE_ID])\n+            units = import_conduit.get_source_units(criteria=criteria)\n+\n+        unit_importers = {\n+            models.Image: DockerImporter._import_image,\n+            models.Tag: DockerImporter._import_tag,\n+            models.Manifest: DockerImporter._import_manifest,\n+            models.Blob: DockerImporter._import_blob\n+        }\n+\n+        units_added = set()\n+        for unit in units:\n+            units_added |= set(unit_importers[type(unit)](import_conduit, unit, dest_repo.repo_obj))\n+\n+        return list(units_added)\n \n     @staticmethod\n-    def _import_images(conduit, units):\n+    def _import_image(conduit, unit, dest_repo):\n         \"\"\"\n-        Import images and referenced images.\n+        Import the Image and the Images it references.\n \n-        :param conduit: provides access to relevant Pulp functionality\n-        :type conduit: pulp.plugins.conduits.unit_import.ImportUnitConduit\n-        :param units: optional list of pre-filtered units to import\n-        :type  units: list of pulp.plugins.model.Unit\n-        :return: list of units that were copied to the destination repository\n-        :rtype:  list\n+        :param conduit:   provides access to relevant Pulp functionality\n+        :type  conduit:   pulp.plugins.conduits.unit_import.ImportUnitConduit\n+        :param unit:      The Image to import\n+        :type  unit:      pulp_docker.plugins.models.Image\n+        :param dest_repo: The destination repository that the Manifest is being imported to.\n+        :type  dest_repo: pulp.plugins.model.Repository\n+        :return:          set of Images that were copied to the destination repository\n+        :rtype:           set\n         \"\"\"\n-        # Determine which units are being copied\n-        if units is None:\n-            criteria = UnitAssociationCriteria(type_ids=[constants.IMAGE_TYPE_ID])\n-            units = conduit.get_source_units(criteria=criteria)\n-\n         # Associate to the new repository\n         known_units = set()\n-        units_added = []\n+        units_added = set()\n+        # The loop below expects a list of units as it recurses\n+        units = [unit]\n \n         while True:\n             units_to_add = set()\n \n             # Associate the units to the repository\n             for u in units:\n-                if u.type_id != constants.IMAGE_TYPE_ID:\n-                    continue\n-                conduit.associate_unit(u)\n-                units_added.append(u)\n+                repository.associate_single_unit(dest_repo, u)\n+                units_added.add(u)\n                 known_units.add(u.unit_key['image_id'])\n-                parent_id = u.metadata.get('parent_id')\n+                parent_id = u.parent_id\n                 if parent_id:\n                     units_to_add.add(parent_id)\n             # Filter out units we have already added\n             units_to_add.difference_update(known_units)\n             # Find any new units to add to the repository\n             if units_to_add:\n-                unit_filter = {'image_id': {'$in': list(units_to_add)}}\n-                criteria = UnitAssociationCriteria(type_ids=[constants.IMAGE_TYPE_ID],\n-                                                   unit_filters=unit_filter)\n-                units = conduit.get_source_units(criteria=criteria)\n+                units = models.Image.objects.filter(image_id__in=list(units_to_add))","path":"plugins/pulp_docker/plugins/importers/importer.py","position":119,"original_position":119,"commit_id":"88a01370b753b061c716cf217772e4eb5eaf13e4","original_commit_id":"88a01370b753b061c716cf217772e4eb5eaf13e4","user":{"login":"mhrivnak","id":53091,"avatar_url":"https://avatars.githubusercontent.com/u/53091?v=3","gravatar_id":"","url":"https://api.github.com/users/mhrivnak","html_url":"https://github.com/mhrivnak","followers_url":"https://api.github.com/users/mhrivnak/followers","following_url":"https://api.github.com/users/mhrivnak/following{/other_user}","gists_url":"https://api.github.com/users/mhrivnak/gists{/gist_id}","starred_url":"https://api.github.com/users/mhrivnak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhrivnak/subscriptions","organizations_url":"https://api.github.com/users/mhrivnak/orgs","repos_url":"https://api.github.com/users/mhrivnak/repos","events_url":"https://api.github.com/users/mhrivnak/events{/privacy}","received_events_url":"https://api.github.com/users/mhrivnak/received_events","type":"User","site_admin":false},"body":"+1 I love mongoengine.","created_at":"2016-01-11T16:42:27Z","updated_at":"2016-01-11T16:42:27Z","html_url":"https://github.com/pulp/pulp_docker/pull/116#discussion_r49343580","pull_request_url":"https://api.github.com/repos/pulp/pulp_docker/pulls/116","_links":{"self":{"href":"https://api.github.com/repos/pulp/pulp_docker/pulls/comments/49343580"},"html":{"href":"https://github.com/pulp/pulp_docker/pull/116#discussion_r49343580"},"pull_request":{"href":"https://api.github.com/repos/pulp/pulp_docker/pulls/116"}}},"pull_request":{"url":"https://api.github.com/repos/pulp/pulp_docker/pulls/116","id":55641725,"html_url":"https://github.com/pulp/pulp_docker/pull/116","diff_url":"https://github.com/pulp/pulp_docker/pull/116.diff","patch_url":"https://github.com/pulp/pulp_docker/pull/116.patch","issue_url":"https://api.github.com/repos/pulp/pulp_docker/issues/116","number":116,"state":"open","locked":false,"title":"Add a formal Tag Unit model to track repository tags.","user":{"login":"rbarlow","id":354506,"avatar_url":"https://avatars.githubusercontent.com/u/354506?v=3","gravatar_id":"","url":"https://api.github.com/users/rbarlow","html_url":"https://github.com/rbarlow","followers_url":"https://api.github.com/users/rbarlow/followers","following_url":"https://api.github.com/users/rbarlow/following{/other_user}","gists_url":"https://api.github.com/users/rbarlow/gists{/gist_id}","starred_url":"https://api.github.com/users/rbarlow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rbarlow/subscriptions","organizations_url":"https://api.github.com/users/rbarlow/orgs","repos_url":"https://api.github.com/users/rbarlow/repos","events_url":"https://api.github.com/users/rbarlow/events{/privacy}","received_events_url":"https://api.github.com/users/rbarlow/received_events","type":"User","site_admin":false},"body":"This commit creates a new Tag model that is used to mark which Manifests are tagged in a repository. Users\r\ncan upload, synchronize, and associate tags which allows them greater control over tags than was afforded in\r\nthe v1 code.\r\n\r\nhttps://pulp.plan.io/issues/1375\r\n\r\nfixes #1375\r\n\r\nThis pull request depends on the change in https://github.com/pulp/pulp/pull/2311 so will not pass Jenkies tests.","created_at":"2016-01-11T16:11:53Z","updated_at":"2016-01-11T16:42:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2c50988bd1a969be22e8a9fa21c55c3d9c1be597","assignee":{"login":"dkliban","id":294339,"avatar_url":"https://avatars.githubusercontent.com/u/294339?v=3","gravatar_id":"","url":"https://api.github.com/users/dkliban","html_url":"https://github.com/dkliban","followers_url":"https://api.github.com/users/dkliban/followers","following_url":"https://api.github.com/users/dkliban/following{/other_user}","gists_url":"https://api.github.com/users/dkliban/gists{/gist_id}","starred_url":"https://api.github.com/users/dkliban/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dkliban/subscriptions","organizations_url":"https://api.github.com/users/dkliban/orgs","repos_url":"https://api.github.com/users/dkliban/repos","events_url":"https://api.github.com/users/dkliban/events{/privacy}","received_events_url":"https://api.github.com/users/dkliban/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/pulp/pulp_docker/pulls/116/commits","review_comments_url":"https://api.github.com/repos/pulp/pulp_docker/pulls/116/comments","review_comment_url":"https://api.github.com/repos/pulp/pulp_docker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pulp/pulp_docker/issues/116/comments","statuses_url":"https://api.github.com/repos/pulp/pulp_docker/statuses/88a01370b753b061c716cf217772e4eb5eaf13e4","head":{"label":"rbarlow:1375","ref":"1375","sha":"88a01370b753b061c716cf217772e4eb5eaf13e4","user":{"login":"rbarlow","id":354506,"avatar_url":"https://avatars.githubusercontent.com/u/354506?v=3","gravatar_id":"","url":"https://api.github.com/users/rbarlow","html_url":"https://github.com/rbarlow","followers_url":"https://api.github.com/users/rbarlow/followers","following_url":"https://api.github.com/users/rbarlow/following{/other_user}","gists_url":"https://api.github.com/users/rbarlow/gists{/gist_id}","starred_url":"https://api.github.com/users/rbarlow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rbarlow/subscriptions","organizations_url":"https://api.github.com/users/rbarlow/orgs","repos_url":"https://api.github.com/users/rbarlow/repos","events_url":"https://api.github.com/users/rbarlow/events{/privacy}","received_events_url":"https://api.github.com/users/rbarlow/received_events","type":"User","site_admin":false},"repo":{"id":24904550,"name":"pulp_docker","full_name":"rbarlow/pulp_docker","owner":{"login":"rbarlow","id":354506,"avatar_url":"https://avatars.githubusercontent.com/u/354506?v=3","gravatar_id":"","url":"https://api.github.com/users/rbarlow","html_url":"https://github.com/rbarlow","followers_url":"https://api.github.com/users/rbarlow/followers","following_url":"https://api.github.com/users/rbarlow/following{/other_user}","gists_url":"https://api.github.com/users/rbarlow/gists{/gist_id}","starred_url":"https://api.github.com/users/rbarlow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rbarlow/subscriptions","organizations_url":"https://api.github.com/users/rbarlow/orgs","repos_url":"https://api.github.com/users/rbarlow/repos","events_url":"https://api.github.com/users/rbarlow/events{/privacy}","received_events_url":"https://api.github.com/users/rbarlow/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rbarlow/pulp_docker","description":"","fork":true,"url":"https://api.github.com/repos/rbarlow/pulp_docker","forks_url":"https://api.github.com/repos/rbarlow/pulp_docker/forks","keys_url":"https://api.github.com/repos/rbarlow/pulp_docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rbarlow/pulp_docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rbarlow/pulp_docker/teams","hooks_url":"https://api.github.com/repos/rbarlow/pulp_docker/hooks","issue_events_url":"https://api.github.com/repos/rbarlow/pulp_docker/issues/events{/number}","events_url":"https://api.github.com/repos/rbarlow/pulp_docker/events","assignees_url":"https://api.github.com/repos/rbarlow/pulp_docker/assignees{/user}","branches_url":"https://api.github.com/repos/rbarlow/pulp_docker/branches{/branch}","tags_url":"https://api.github.com/repos/rbarlow/pulp_docker/tags","blobs_url":"https://api.github.com/repos/rbarlow/pulp_docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rbarlow/pulp_docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rbarlow/pulp_docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/rbarlow/pulp_docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rbarlow/pulp_docker/statuses/{sha}","languages_url":"https://api.github.com/repos/rbarlow/pulp_docker/languages","stargazers_url":"https://api.github.com/repos/rbarlow/pulp_docker/stargazers","contributors_url":"https://api.github.com/repos/rbarlow/pulp_docker/contributors","subscribers_url":"https://api.github.com/repos/rbarlow/pulp_docker/subscribers","subscription_url":"https://api.github.com/repos/rbarlow/pulp_docker/subscription","commits_url":"https://api.github.com/repos/rbarlow/pulp_docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/rbarlow/pulp_docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/rbarlow/pulp_docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/rbarlow/pulp_docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/rbarlow/pulp_docker/contents/{+path}","compare_url":"https://api.github.com/repos/rbarlow/pulp_docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rbarlow/pulp_docker/merges","archive_url":"https://api.github.com/repos/rbarlow/pulp_docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rbarlow/pulp_docker/downloads","issues_url":"https://api.github.com/repos/rbarlow/pulp_docker/issues{/number}","pulls_url":"https://api.github.com/repos/rbarlow/pulp_docker/pulls{/number}","milestones_url":"https://api.github.com/repos/rbarlow/pulp_docker/milestones{/number}","notifications_url":"https://api.github.com/repos/rbarlow/pulp_docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rbarlow/pulp_docker/labels{/name}","releases_url":"https://api.github.com/repos/rbarlow/pulp_docker/releases{/id}","created_at":"2014-10-07T18:15:50Z","updated_at":"2015-03-12T13:40:17Z","pushed_at":"2016-01-11T16:11:16Z","git_url":"git://github.com/rbarlow/pulp_docker.git","ssh_url":"git@github.com:rbarlow/pulp_docker.git","clone_url":"https://github.com/rbarlow/pulp_docker.git","svn_url":"https://github.com/rbarlow/pulp_docker","homepage":null,"size":470,"stargazers_count":0,"watchers_count":0,"language":"Python","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":"pulp:master","ref":"master","sha":"6f522fb641ffc63b91a336447e17f350d0f9563e","user":{"login":"pulp","id":2103606,"avatar_url":"https://avatars.githubusercontent.com/u/2103606?v=3","gravatar_id":"","url":"https://api.github.com/users/pulp","html_url":"https://github.com/pulp","followers_url":"https://api.github.com/users/pulp/followers","following_url":"https://api.github.com/users/pulp/following{/other_user}","gists_url":"https://api.github.com/users/pulp/gists{/gist_id}","starred_url":"https://api.github.com/users/pulp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pulp/subscriptions","organizations_url":"https://api.github.com/users/pulp/orgs","repos_url":"https://api.github.com/users/pulp/repos","events_url":"https://api.github.com/users/pulp/events{/privacy}","received_events_url":"https://api.github.com/users/pulp/received_events","type":"Organization","site_admin":false},"repo":{"id":18303696,"name":"pulp_docker","full_name":"pulp/pulp_docker","owner":{"login":"pulp","id":2103606,"avatar_url":"https://avatars.githubusercontent.com/u/2103606?v=3","gravatar_id":"","url":"https://api.github.com/users/pulp","html_url":"https://github.com/pulp","followers_url":"https://api.github.com/users/pulp/followers","following_url":"https://api.github.com/users/pulp/following{/other_user}","gists_url":"https://api.github.com/users/pulp/gists{/gist_id}","starred_url":"https://api.github.com/users/pulp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pulp/subscriptions","organizations_url":"https://api.github.com/users/pulp/orgs","repos_url":"https://api.github.com/users/pulp/repos","events_url":"https://api.github.com/users/pulp/events{/privacy}","received_events_url":"https://api.github.com/users/pulp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pulp/pulp_docker","description":"","fork":false,"url":"https://api.github.com/repos/pulp/pulp_docker","forks_url":"https://api.github.com/repos/pulp/pulp_docker/forks","keys_url":"https://api.github.com/repos/pulp/pulp_docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pulp/pulp_docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pulp/pulp_docker/teams","hooks_url":"https://api.github.com/repos/pulp/pulp_docker/hooks","issue_events_url":"https://api.github.com/repos/pulp/pulp_docker/issues/events{/number}","events_url":"https://api.github.com/repos/pulp/pulp_docker/events","assignees_url":"https://api.github.com/repos/pulp/pulp_docker/assignees{/user}","branches_url":"https://api.github.com/repos/pulp/pulp_docker/branches{/branch}","tags_url":"https://api.github.com/repos/pulp/pulp_docker/tags","blobs_url":"https://api.github.com/repos/pulp/pulp_docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pulp/pulp_docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pulp/pulp_docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/pulp/pulp_docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pulp/pulp_docker/statuses/{sha}","languages_url":"https://api.github.com/repos/pulp/pulp_docker/languages","stargazers_url":"https://api.github.com/repos/pulp/pulp_docker/stargazers","contributors_url":"https://api.github.com/repos/pulp/pulp_docker/contributors","subscribers_url":"https://api.github.com/repos/pulp/pulp_docker/subscribers","subscription_url":"https://api.github.com/repos/pulp/pulp_docker/subscription","commits_url":"https://api.github.com/repos/pulp/pulp_docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/pulp/pulp_docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/pulp/pulp_docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/pulp/pulp_docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/pulp/pulp_docker/contents/{+path}","compare_url":"https://api.github.com/repos/pulp/pulp_docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pulp/pulp_docker/merges","archive_url":"https://api.github.com/repos/pulp/pulp_docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pulp/pulp_docker/downloads","issues_url":"https://api.github.com/repos/pulp/pulp_docker/issues{/number}","pulls_url":"https://api.github.com/repos/pulp/pulp_docker/pulls{/number}","milestones_url":"https://api.github.com/repos/pulp/pulp_docker/milestones{/number}","notifications_url":"https://api.github.com/repos/pulp/pulp_docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pulp/pulp_docker/labels{/name}","releases_url":"https://api.github.com/repos/pulp/pulp_docker/releases{/id}","created_at":"2014-03-31T18:34:47Z","updated_at":"2015-10-12T01:12:24Z","pushed_at":"2016-01-11T16:11:55Z","git_url":"git://github.com/pulp/pulp_docker.git","ssh_url":"git@github.com:pulp/pulp_docker.git","clone_url":"https://github.com/pulp/pulp_docker.git","svn_url":"https://github.com/pulp/pulp_docker","homepage":"","size":488,"stargazers_count":10,"watchers_count":10,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":22,"mirror_url":null,"open_issues_count":3,"forks":22,"open_issues":3,"watchers":10,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pulp/pulp_docker/pulls/116"},"html":{"href":"https://github.com/pulp/pulp_docker/pull/116"},"issue":{"href":"https://api.github.com/repos/pulp/pulp_docker/issues/116"},"comments":{"href":"https://api.github.com/repos/pulp/pulp_docker/issues/116/comments"},"review_comments":{"href":"https://api.github.com/repos/pulp/pulp_docker/pulls/116/comments"},"review_comment":{"href":"https://api.github.com/repos/pulp/pulp_docker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pulp/pulp_docker/pulls/116/commits"},"statuses":{"href":"https://api.github.com/repos/pulp/pulp_docker/statuses/88a01370b753b061c716cf217772e4eb5eaf13e4"}}}}