) #, proxy_info = httplib2.ProxyInfo(socks.PROXY_TYPE_HTTP, 'localhost', 8888) #reset connections to avoid disconnections user_importer.resetConnections(source, target) link_importer.resetConnections(target) # copy project, subsystems, versions project = source.getProject(projectId) link_importer.addAvailableIssuesFrom(projectId) project_custom_fields = source.getProjectCustomFields(projectId) # create bundles and additional values for pcf_ref in project_custom_fields: pcf = source.getProjectCustomField(projectId, pcf_ref.name) if hasattr(pcf, "bundle"): create_bundle_from_bundle(source, target, pcf.bundle, source.getCustomField(pcf.name).type, user_importer) target_project_fields = [ pcf.name for pcf in target.getProjectCustomFields(projectId) ] for field in project_custom_fields: if field.name in target_project_fields: if hasattr(field, 'bundle'): if field.bundle != target.getProjectCustomField( projectId, field.name).bundle: target.deleteProjectCustomField(projectId, field.name) create_project_custom_field(target, field, projectId) else: create_project_custom_field(target, field, projectId)
def youtrack2youtrack(source_url, source_login, source_password, target_url, target_login, target_password, project_ids, query='', source_token=None, target_token=None, params=None): if not len(project_ids): print("You should sign at least one project to import") return if params is None: params = {} source = Connection(source_url, source_login, source_password) if (source_token is None) else Connection(source_url, token=source_token) target = Connection(target_url, target_login, target_password) if (target_token is None) else Connection(target_url, token=target_token) # , proxy_info = httplib2.ProxyInfo(socks.PROXY_TYPE_HTTP, 'localhost', 8888) print("Import issue link types") for ilt in source.getIssueLinkTypes(): try: print(target.createIssueLinkType(ilt)) except youtrack.YouTrackException as e: print(e.message) user_importer = UserImporter(source, target, caching_users=params.get('enable_user_caching', True)) link_importer = LinkImporter(target) # create all projects with minimum info and project lead set created_projects = [] for project_id in project_ids: created = create_project_stub(source, target, project_id, user_importer) created_projects.append(created) # save created project ids to create correct group roles afterwards user_importer.addCreatedProjects([project.id for project in created_projects]) # import project leads with group they are included and roles assigned to these groups user_importer.importUsersRecursively([target.getUser(project.lead) for project in created_projects]) # afterwards in a script any user import imply recursive import cf_names_to_import = set([]) # names of cf prototypes that should be imported for project_id in project_ids: cf_names_to_import.update([pcf.name.capitalize() for pcf in source.getProjectCustomFields(project_id)]) target_cf_names = [pcf.name.capitalize() for pcf in target.getCustomFields()] period_cf_names = [] for cf_name in cf_names_to_import: source_cf = source.getCustomField(cf_name) if source_cf.type.lower() == 'period': period_cf_names.append(source_cf.name.lower()) print("Processing custom field '%s'" % utf8encode(cf_name)) if cf_name in target_cf_names: target_cf = target.getCustomField(cf_name) if not (target_cf.type == source_cf.type): print("In your target and source YT instances you have field with name [ %s ]" % utf8encode(cf_name)) print("They have different types. Source field type [ %s ]. Target field type [ %s ]" % (source_cf.type, target_cf.type)) print("exiting...") exit() else: if hasattr(source_cf, "defaultBundle"): create_bundle_from_bundle(source, target, source_cf.defaultBundle, source_cf.type, user_importer) target.createCustomField(source_cf) failed_commands = [] for projectId in project_ids: source = Connection(source_url, source_login, source_password) if (source_token is None) else Connection( source_url, token=source_token) target = Connection(target_url, target_login, target_password) if (target_token is None) else Connection( target_url, token=target_token) # , proxy_info = httplib2.ProxyInfo(socks.PROXY_TYPE_HTTP, 'localhost', 8888) # reset connections to avoid disconnections user_importer.resetConnections(source, target) link_importer.resetConnections(target) # copy project, subsystems, versions project = source.getProject(projectId) link_importer.addAvailableIssuesFrom(projectId) project_custom_fields = source.getProjectCustomFields(projectId) # create bundles and additional values for pcf_ref in project_custom_fields: pcf = source.getProjectCustomField(projectId, pcf_ref.name) if hasattr(pcf, "bundle"): try: create_bundle_from_bundle(source, target, pcf.bundle, source.getCustomField(pcf.name).type, user_importer) except youtrack.YouTrackException as e: if e.response.status != 409: raise e else: print(e) target_project_fields = [pcf.name.lower() for pcf in target.getProjectCustomFields(projectId)] for field in project_custom_fields: if field.name.lower() in target_project_fields: if hasattr(field, 'bundle'): if field.bundle != target.getProjectCustomField(projectId, field.name).bundle: target.deleteProjectCustomField(projectId, field.name) create_project_custom_field(target, field, projectId) else: try: create_project_custom_field(target, field, projectId) except youtrack.YouTrackException as e: if e.response.status != 409: raise e else: print(e) # copy issues start = 0 max = 20 sync_workitems = enable_time_tracking(source, target, projectId) tt_settings = target.getProjectTimeTrackingSettings(projectId) print("Import issues") last_created_issue_number = 0 while True: try: print("Get issues from " + str(start) + " to " + str(start + max)) issues = source.getIssues(projectId, query, start, max) if len(issues) <= 0: break if convert_period_values and period_cf_names: for issue in issues: for pname in period_cf_names: for fname in issue.__dict__: if fname.lower() != pname: continue issue[fname] = period_to_minutes(issue[fname]) users = set([]) for issue in issues: print("Collect users for issue [%s]" % issue.id) users.add(issue.getReporter()) if issue.hasAssignee(): if isinstance(issue.Assignee, (list, tuple)): users.update(issue.getAssignee()) else: users.add(issue.getAssignee()) # TODO: http://youtrack.jetbrains.net/issue/JT-6100 users.add(issue.getUpdater()) if issue.hasVoters(): users.update(issue.getVoters()) for comment in issue.getComments(): users.add(comment.getAuthor()) print("Collect links for issue [%s]" % issue.id) link_importer.collectLinks(issue.getLinks(True)) # links.extend(issue.getLinks(True)) # fix problem with comment.text for comment in issue.getComments(): if not hasattr(comment, "text") or (len(comment.text.strip()) == 0): setattr(comment, 'text', 'no text') user_importer.importUsersRecursively(users) print("Create issues [" + str(len(issues)) + "]") if params.get('create_new_issues'): create_issues(target, issues, last_created_issue_number) else: print(target.importIssues(projectId, project.name + ' Assignees', issues)) link_importer.addAvailableIssues(issues) for issue in issues: try: target_issue = target.getIssue(issue.id) except youtrack.YouTrackException as e: print("Cannot get target issue") print(e) continue if params.get('sync_tags') and issue.tags: try: for tag in issue.tags: tag = re.sub(r'[,&<>]', '_', tag) try: target.executeCommand(issue.id, 'tag ' + tag, disable_notifications=True) except youtrack.YouTrackException: tag = re.sub(r'[\s-]', '_', tag) target.executeCommand(issue.id, 'tag ' + tag, disable_notifications=True) except youtrack.YouTrackException as e: print("Cannot sync tags for issue " + issue.id) print(e) if params.get('add_new_comments'): target_comments = dict() max_id = 0 for c in target_issue.getComments(): target_comments[c.created] = c if max_id < c.created: max_id = c.created for c in issue.getComments(): if c.created > max_id or c.created not in target_comments: group = None if hasattr(c, 'permittedGroup'): group = c.permittedGroup try: target.executeCommand(issue.id, 'comment', c.text, group, c.author, disable_notifications=True) except youtrack.YouTrackException as e: print('Cannot add comment to issue') print(e) if params.get('sync_custom_fields'): skip_fields = [] if tt_settings and tt_settings.Enabled and tt_settings.TimeSpentField: skip_fields.append(tt_settings.TimeSpentField) skip_fields = [name.lower() for name in skip_fields] for pcf in [pcf for pcf in project_custom_fields if pcf.name.lower() not in skip_fields]: target_cf_value = None if pcf.name in target_issue: target_cf_value = target_issue[pcf.name] if isinstance(target_cf_value, (list, tuple)): target_cf_value = set(target_cf_value) elif target_cf_value == target.getProjectCustomField(projectId, pcf.name).emptyText: target_cf_value = None source_cf_value = None if pcf.name in issue: source_cf_value = issue[pcf.name] if isinstance(source_cf_value, (list, tuple)): source_cf_value = set(source_cf_value) elif source_cf_value == source.getProjectCustomField(projectId, pcf.name).emptyText: source_cf_value = None if source_cf_value == target_cf_value: continue if isinstance(source_cf_value, set) or isinstance(target_cf_value, set): if source_cf_value is None: source_cf_value = set([]) elif not isinstance(source_cf_value, set): source_cf_value = set([source_cf_value]) if target_cf_value is None: target_cf_value = set([]) elif not isinstance(target_cf_value, set): target_cf_value = set([target_cf_value]) for v in target_cf_value: if v not in source_cf_value: target.executeCommand(issue.id, 'remove %s %s' % (pcf.name, v), disable_notifications=True) for v in source_cf_value: if v not in target_cf_value: target.executeCommand(issue.id, 'add %s %s' % (pcf.name, v), disable_notifications=True) else: if source_cf_value is None: source_cf_value = target.getProjectCustomField(projectId, pcf.name).emptyText if pcf.type.lower() == 'date': m = re.match(r'(\d{10})(?:\d{3})?', str(source_cf_value)) if m: source_cf_value = datetime.datetime.fromtimestamp( int(m.group(1))).strftime('%Y-%m-%d') elif pcf.type.lower() == 'period': source_cf_value = '%sm' % source_cf_value command = '%s %s' % (pcf.name, source_cf_value) try: target.executeCommand(issue.id, command, disable_notifications=True) except youtrack.YouTrackException as e: if e.response.status == 412 and e.response.reason.find('Precondition Failed') > -1: print('WARN: Some workflow blocks following command: %s' % command) failed_commands.append((issue.id, command)) if sync_workitems: workitems = source.getWorkItems(issue.id) if workitems: existing_workitems = dict() target_workitems = target.getWorkItems(issue.id) if target_workitems: for w in target_workitems: _id = '%s\n%s\n%s' % (w.date, w.authorLogin, w.duration) if hasattr(w, 'description'): _id += '\n%s' % w.description existing_workitems[_id] = w new_workitems = [] for w in workitems: _id = '%s\n%s\n%s' % (w.date, w.authorLogin, w.duration) if hasattr(w, 'description'): _id += '\n%s' % w.description if _id not in existing_workitems: new_workitems.append(w) if new_workitems: print("Process workitems for issue [ " + issue.id + "]") try: user_importer.importUsersRecursively( [source.getUser(w.authorLogin) for w in new_workitems]) target.importWorkItems(issue.id, new_workitems) except youtrack.YouTrackException as e: if e.response.status == 404: print("WARN: Target YouTrack doesn't support workitems importing.") print("WARN: Workitems won't be imported.") sync_workitems = False else: print("ERROR: Skipping workitems because of error:" + str(e)) print("Process attachments for issue [%s]" % issue.id) existing_attachments = dict() try: for a in target.getAttachments(issue.id): existing_attachments[a.name + '\n' + a.created] = a except youtrack.YouTrackException as e: if e.response.status == 404: print("Skip importing attachments because issue %s doesn't exist" % issue.id) continue raise e attachments = [] users = set([]) for a in issue.getAttachments(): if a.name + '\n' + a.created in existing_attachments and not params.get('replace_attachments'): a.name = utf8encode(a.name) try: print("Skip attachment '%s' (created: %s) because it's already exists" % (utf8encode(a.name), utf8encode(a.created))) except Exception: pass continue attachments.append(a) author = a.getAuthor() if author is not None: users.add(author) user_importer.importUsersRecursively(users) for a in attachments: print("Transfer attachment of " + utf8encode(issue.id) + ": " + utf8encode(a.name)) # TODO: add authorLogin to workaround http://youtrack.jetbrains.net/issue/JT-6082 # a.authorLogin = target_login try: target.createAttachmentFromAttachment(issue.id, a) except BaseException as e: print("Cant import attachment [ %s ]" % utf8encode(a.name)) print(repr(e)) continue if params.get('replace_attachments'): try: old_attachment = existing_attachments.get(a.name + '\n' + a.created) if old_attachment: print('Deleting old attachment') target.deleteAttachment(issue.id, old_attachment.id) except BaseException as e: print("Cannot delete attachment '%s' from issue %s" % ( utf8encode(a.name), utf8encode(issue.id))) print(e) except Exception as e: print('Cant process issues from ' + str(start) + ' to ' + str(start + max)) traceback.print_exc() raise e start += max print("Import issue links") link_importer.importCollectedLinks() print("Trying to execute failed commands once again") for issue_id, command in failed_commands: try: print('Executing command on issue %s: %s' % (issue_id, command)) target.executeCommand(issue_id, command, disable_notifications=True) except youtrack.YouTrackException as e: print('Failed to execute command for issue #%s: %s' % (issue_id, command)) print(e)
target = Connection(target_url, target_login, target_password) #, proxy_info = httplib2.ProxyInfo(socks.PROXY_TYPE_HTTP, 'localhost', 8888) #reset connections to avoid disconnections user_importer.resetConnections(source, target) link_importer.resetConnections(target) # copy project, subsystems, versions project = source.getProject(projectId) link_importer.addAvailableIssuesFrom(projectId) project_custom_fields = source.getProjectCustomFields(projectId) # create bundles and additional values for pcf_ref in project_custom_fields: pcf = source.getProjectCustomField(projectId, pcf_ref.name) if hasattr(pcf, "bundle"): create_bundle_from_bundle(source, target, pcf.bundle, source.getCustomField(pcf.name).type, user_importer) target_project_fields = [pcf.name for pcf in target.getProjectCustomFields(projectId)] for field in project_custom_fields: if field.name in target_project_fields: if hasattr(field, 'bundle'): if field.bundle != target.getProjectCustomField(projectId, field.name).bundle: target.deleteProjectCustomField(projectId, field.name) create_project_custom_field(target, field, projectId) else: create_project_custom_field(target, field, projectId) # copy issues start = 0 max = 20
def main(a_pat, yt_url, yt_login, yt_pass): """ Creates connections to Asana and your YouTrack site, then migrates tasks """ a_conn = asana.Client.access_token(a_pat) yt_conn = Connection(yt_url, yt_login, yt_pass) print 'Logged in with Asana User {} and YouTrack User {}'.format( a_conn.users.me()['name'], yt_conn.getUser(yt_login).login) # Get list of Asana Workspaces to migrate - all except Personal Projects a_workspaces = [ w for w in a_conn.workspaces.find_all() if w['name'] != "Personal Projects" ] print "Found Asana Workspaces (excluding Personal Projects): {}".format( [a['name'] for a in a_workspaces]) yt_projects = [yt_conn.getProject(p) for p in yt_conn.getProjects()] print "Found existing YouTrack Projects: {}".format( [y.name for y in yt_projects]) for a_work in a_workspaces: if a_work['name'] not in [p.name for p in yt_projects]: print "Creating YouTrack Project from {} Workspace".format( a_work['name']) yt_proj = None for p in yt_projects: if p.name == a_work['name']: yt_proj = p break if yt_proj is None: yt_proj = yt.Project() yt_proj.name = a_work['name'] yt_proj.id = a_work['name'].replace(' ', '').upper() yt_proj.lead = yt_login print yt_conn.createProject(yt_proj) field_name = 'AsanaID' cf = yt.CustomField() cf.name = field_name cf.type = 'string' cf.isPrivate = False cf.visibleByDefault = False # print "Existing Project Fields: {}".format(yt_conn.getProjectCustomFields(yt_proj.id)) try: asana_id_exists = yt_conn.getCustomField(field_name) except: asana_id_exists = False if not asana_id_exists: print 'Creating YouTrack Custom Field to save our Asana ID in' yt_conn.createCustomField(cf) try: asana_id_exists = yt_conn.getProjectCustomField( yt_proj.id, 'Due Date') except: asana_id_exists = None if not asana_id_exists: print 'Adding YouTrack Due Date Field to {} Project'.format( yt_proj.id) yt_conn.createProjectCustomFieldDetailed(yt_proj.id, 'Due Date', '') try: asana_id_exists = yt_conn.getProjectCustomField( yt_proj.id, field_name) except: asana_id_exists = False if not asana_id_exists: print 'Adding YouTrack Custom Field {} to {} Project'.format( field_name, yt_proj.id) yt_conn.createProjectCustomFieldDetailed(yt_proj.id, field_name, '') # Migrate users and save our list for later so we can assign people migrate_workspace_users(a_conn, yt_conn, a_work) migrate_projects_to_subsystems(a_conn, yt_conn, a_work, yt_proj) migrate_tasks_to_issues(a_conn, yt_conn, a_work, yt_proj, yt_login)
) # , proxy_info = httplib2.ProxyInfo(socks.PROXY_TYPE_HTTP, 'localhost', 8888) # reset connections to avoid disconnections user_importer.resetConnections(source, target) link_importer.resetConnections(target) # copy project, subsystems, versions project = source.getProject(projectId) link_importer.addAvailableIssuesFrom(projectId) project_custom_fields = source.getProjectCustomFields(projectId) # create bundles and additional values for pcf_ref in project_custom_fields: pcf = source.getProjectCustomField(projectId, pcf_ref.name) if hasattr(pcf, "bundle"): create_bundle_from_bundle( source, target, pcf.bundle, source.getCustomField(pcf.name).type, user_importer ) target_project_fields = [pcf.name for pcf in target.getProjectCustomFields(projectId)] for field in project_custom_fields: if field.name in target_project_fields: if hasattr(field, "bundle"): if field.bundle != target.getProjectCustomField(projectId, field.name).bundle: target.deleteProjectCustomField(projectId, field.name) create_project_custom_field(target, field, projectId) else: create_project_custom_field(target, field, projectId) # TODO: copy assignees # copy issues
def mantis2youtrack( target_url, target_login, target_pass, mantis_db_name, mantis_db_host, mantis_db_port, mantis_db_login, mantis_db_pass, mantis_project_names, ): print "target_url : " + target_url print "target_login : "******"target_pass : "******"mantis_db_name : " + mantis_db_name print "mantis_db_host : " + mantis_db_host print "mantis_db_port : " + mantis_db_port print "mantis_db_login : "******"mantis_db_pass : "******"mantis_project_names : " + repr(mantis_project_names) # connacting to yt target = Connection(target_url, target_login, target_pass) # connacting to mantis client = MantisClient( mantis_db_host, int(mantis_db_port), mantis_db_login, mantis_db_pass, mantis_db_name, mantis.CHARSET ) if not len(mantis_project_names): print "You should declarer at least one project to import" sys.exit() value_sets = dict([]) print "Importing users" yt_users = [] value_sets["user"] = set([]) for user in client.get_mantis_users(): print "Processing user [ %s ]" % user.user_name value_sets["user"].add(user.user_name) yt_users.append(to_yt_user(user)) target.importUsers(yt_users) print "Importing users finished" print "Creating custom fields definitions" value_sets.update(create_custom_fields(target, u"priority", mantis.PRIORITY_VALUES.values())) value_sets.update(create_custom_fields(target, u"severity", mantis.SEVERITY_VALUES.values())) value_sets.update(create_custom_fields(target, u"category", ["No subsystem"], "1")) value_sets.update(create_custom_fields(target, u"version", [], "1")) value_sets.update(create_custom_fields(target, u"fixed_in_version", [], "1")) value_sets.update(create_custom_fields(target, u"build", [], "1")) value_sets.update(create_custom_fields(target, u"platform")) value_sets.update(create_custom_fields(target, u"os")) value_sets.update(create_custom_fields(target, u"os_build")) value_sets.update(create_custom_fields(target, u"due_date")) value_sets.update(create_custom_fields(target, u"Reproducibility", mantis.REPRODUCIBILITY_VALUES.values())) # create custom field for target version field = None try: field = target.getCustomField("Fix versions") except YouTrackException: pass if field is not None: if hasattr(field, "defaultBundle"): bundle = field.defaultBundle for name in get_yt_cf_name_from_mantis_cf_name("target_version"): try: target.createCustomFieldDetailed( name, mantis.FIELD_TYPES[name], False, True, True, {"defaultBundle": bundle, "attachBundlePolicy": "1"}, ) except YouTrackException: pass value_sets.update( create_auto_attached_bundle_custom_fields( target, u"status", mantis.STATUS_VALUES.values(), lambda status, bundle, value_mapping: to_yt_state(status, bundle, value_mapping), ) ) value_sets.update( create_auto_attached_bundle_custom_fields( target, u"resolution", mantis.RESOLUTION_VALUES.values(), lambda resolution, bundle, value_mapping: to_yt_state(resolution, bundle, value_mapping), ) ) if mantis.CREATE_CF_FOR_SUBPROJECT: value_sets.update(create_custom_fields(target, u"subproject", [], "1")) handler_field_name = u"handler" value_sets.update(create_custom_fields(target, handler_field_name, [], "1")) for name in get_yt_cf_name_from_mantis_cf_name(handler_field_name): value_sets[name] = value_sets["user"] # adding some custom fields that are predefined in mantis project_ids = [] for name in mantis_project_names: project_ids.append(client.get_project_id_by_name(name)) custom_fields = client.get_mantis_custom_fields(project_ids) for cf_def in custom_fields: print "Processing custom field [ %s ]" % cf_def.name.encode("utf-8") value_sets.update(process_mantis_custom_field(target, cf_def)) print "Creating custom fields definitions finished" for name in mantis_project_names: project_id = int(client.get_project_id_by_name(name)) print "Creating project [ %s ] with name [ %s ]" % (project_id, name) try: target.getProject(str(project_id)) except YouTrackException: target.createProjectDetailed( str(project_id), name, client.get_project_description(project_id), target_login ) print "Importing components to project [ %s ]" % project_id value_sets.update( add_values_to_fields( target, project_id, u"category", client.get_mantis_categories(project_id), lambda component, yt_bundle, value_mapping: to_yt_subsystem(component, yt_bundle, value_mapping), ) ) print "Importing components to project [ %s ] finished" % project_id print "Importing versions to project [ %s ]" % project_id mantis_versions = client.get_mantis_versions(project_id) value_sets.update( add_values_to_fields( target, project_id, u"version", mantis_versions, lambda version, yt_bundle, value_mapping: to_yt_version(version, yt_bundle, value_mapping), ) ) value_sets.update( add_values_to_fields( target, project_id, u"fixed_in_version", mantis_versions, lambda version, yt_bundle, value_mapping: to_yt_version(version, yt_bundle, value_mapping), ) ) for name in get_yt_cf_name_from_mantis_cf_name("target_version"): value_sets[name] = value_sets["Fix versions"] print "Importing versions to project [ %s ] finished" % project_id print "Attaching custom fields to project [ %s ]" % project_id cf_ids = client.get_custom_fields_attached_to_project(project_id) ignore = [] for cf in custom_fields: if cf.field_id in cf_ids: attach_field_to_project(target, project_id, cf.name) else: ignore.append(cf.name) if mantis.CREATE_CF_FOR_SUBPROJECT: value_sets.update( add_values_to_fields( target, project_id, u"subproject", client.get_mantis_subprojects(project_id), lambda sp_name, yt_bundle, value_mapping: yt_bundle.createElement(sp_name) if sp_name not in value_mapping else yt_bundle.createElement(value_sets[sp_name]), ) ) print "Attaching custom fields to project [ %s ] finished" % project_id print "Importing issues to project [ %s ]" % project_id mantis_issues = client.get_mantis_issues(project_id) yt_issues = [] max_count = 100 for issue in mantis_issues: # print "Processing issue [ %s ]" % str(issue.id) yt_issues.append(to_yt_issue(issue, value_sets, ignore)) if len(yt_issues) >= max_count: print target.importIssues(str(project_id), name + "Assignees", yt_issues) yt_issues = [] target.importIssues(str(project_id), str(project_id) + "Assignees", yt_issues) print "Importing issues to project [ %s ] finished" % project_id print "Importing issue attachments to project [ %s ]" % project_id mantis_attachments = client.get_mantis_attachments(project_id) for attachment in mantis_attachments: print "Processing issue attachment [ %s ]" % str(attachment.id) content = StringIO(attachment.content) authorLogin = client.get_user_name_by_id(attachment.user_id) target.createAttachment( "%s-%s" % (project_id, attachment.bug_id), attachment.filename, content, authorLogin, attachment.file_type, None, str(attachment.date_added * 1000), ) print "Importing issue attachments to project [ %s ] finished" % project_id print "Importing tags to issues from project [ %s ]" % project_id for issue in mantis_issues: print "Processing tags for issue [ %s ]" % str(issue.id) for tag in issue.tags: print "Processing tag [ %s ]" % tag.encode("utf8") target.executeCommand(str(project_id) + "-" + str(issue.id), "tag " + tag.encode("utf8")) print "Importing tags to issues from project [ %s ] finished" % project_id print "Importing issue links" mantis_issue_links = client.get_issue_links() yt_issue_links = [] for link in mantis_issue_links: print "Processing issue link for source issue [ %s ]" % str(link.source) yt_issue_links.append(to_yt_link(link)) print target.importLinks(yt_issue_links) print "Importing issue links finished"
user_importer.resetConnections(source, target) link_importer.resetConnections(target) # copy project, subsystems, versions project = source.getProject(projectId) link_importer.addAvailableIssuesFrom(projectId) project_custom_fields = source.getProjectCustomFields(projectId) # create bundles and additional values for pcf_ref in project_custom_fields: pcf = source.getProjectCustomField(projectId, pcf_ref.name) if hasattr(pcf, "bundle"): try: create_bundle_from_bundle( source, target, pcf.bundle, source.getCustomField(pcf.name).type, user_importer) except youtrack.YouTrackException, e: if e.response.status != 409: raise e else: print e target_project_fields = [ pcf.name.lower() for pcf in target.getProjectCustomFields(projectId) ] for field in project_custom_fields: if field.name.lower() in target_project_fields: if hasattr(field, 'bundle'): if field.bundle != target.getProjectCustomField( projectId, field.name).bundle: