def reorder(first, start, end, placeholder=300001): #pmig = phabdb.phdb(db=config.bzmigrate_db, # user=config.bzmigrate_user, # passwd=config.bzmigrate_passwd) # range of issues to renumber issues = range(int(start), int(end) + 1) first_issue = issues[0] # number to start new linear renumber at newid = int(first) print 'starting renumbering at %s with %s' % (first, first_issue) pphid = phabdb.get_task_phid_by_id(placeholder) if pphid: print "placeholder %s not empty (%s)" % (placeholder, pphid) return for t in issues: print "Reassigning reference: %s to %s" % (t, newid) # Find PHID of the first ticket in our lineup ref = bzlib.prepend + str(t) phid = phabdb.reference_ticket(ref) if len(phid) > 1 or not phid: newid += 1 print 'skipping phid %s' % (ref,) continue else: refphid = phid[0] print "Reference %s is %s" % (ref, refphid) tid = phabdb.get_task_id_by_phid(refphid) print "Reference %s is starting at id %s" % (ref, tid) existing_task = phabdb.get_task_phid_by_id(int(newid)) print "Existing task returns %s" % (existing_task,) if existing_task: print "Squatter task at %s is %s" % (newid, existing_task) print "Moving squatter %s to %s" % (existing_task, placeholder) phabdb.set_task_id(placeholder, existing_task) phabdb.set_task_id(newid, refphid) if existing_task: print "fixup setting squatter %s to %s" % (existing_task, tid) phabdb.set_task_id(tid, existing_task) newid += 1
if config.force_ids and len(phabdb.get_task_list()) > 0: print "You should not force task ID if there are still existing tasks in maniphest" sys.exit(-1) for issue in github_issues: print "Creating issue %d" % issue.id author_phid = api.get_phid_by_username(issue.author) assignee_phid = None if issue.assignee is None else api.get_phid_by_username(issue.assignee) description = "= Task migrated from github issue #%d which was available at %s =\n\n%s" % (issue.id, issue.url, issue.description) if config.have_db_access is False or author_phid is None: description = "> Issue originally made by **%s** on //%s//\n\n%s" % (issue.author, issue.created_at, description) new_task = api.task_create(issue.title, description, issue.id, 90, assignee_phid, [project_phid]) phid = new_task['phid'] if config.force_ids: phabdb.set_task_id(issue.id, phid) id = issue.id else: id = new_task['id'] if config.have_db_access: if author_phid: phabdb.set_task_author(author_phid, id) phabdb.set_task_ctime(phid, issue.created_at.strftime("%s")) phabdb.set_task_mtime(phid, issue.updated_at.strftime("%s")) if issue.state != "open": api.set_status(id, "resolved") if config.have_db_access: if issue.closed_at: tphid = phabdb.last_state_change(phid)
for issue in github_issues: print "Creating issue %d" % issue.id author_phid = api.get_phid_by_username(issue.author) assignee_phid = None if issue.assignee is None else api.get_phid_by_username( issue.assignee) description = "= Task migrated from github issue #%d which was available at %s =\n\n%s" % ( issue.id, issue.url, issue.description) if config.have_db_access is False or author_phid is None: description = "> Issue originally made by **%s** on //%s//\n\n%s" % ( issue.author, issue.created_at, description) new_task = api.task_create(issue.title, description, issue.id, 90, assignee_phid, [project_phid]) phid = new_task['phid'] if config.force_ids: phabdb.set_task_id(issue.id, phid) id = issue.id else: id = new_task['id'] if config.have_db_access: if author_phid: phabdb.set_task_author(author_phid, id) phabdb.set_task_ctime(phid, issue.created_at.strftime("%s")) phabdb.set_task_mtime(phid, issue.updated_at.strftime("%s")) if issue.state != "open": api.set_status(id, "resolved") if config.have_db_access: if issue.closed_at: tphid = phabdb.last_state_change(phid)