def update(bugid): pmig = phabdb.phdb(db=config.bzmigrate_db, user=config.bzmigrate_user, passwd=config.bzmigrate_passwd) epriority = pmig.sql_x("SELECT priority from task_relations where id = %s", bugid) if epriority and epriority[0] == ipriority['update_success']: log('skipping %s as blockers already updated' % (bugid,)) return True hq = "SELECT header FROM bugzilla_meta WHERE id = %s" header = pmig.sql_x(hq, (bugid,)) if not header: elog('no header found for %s' % (bugid,)) return False def extref(ticket): refid = phabdb.reference_ticket("%s%s" % (bzlib.prepend, ticket)) if not refid: return '' return refid[0] blocker_ref = extref(bugid) tinfo = json.loads(header[0][0]) if not tinfo['blocks']: log("%s doesn't block anything" % (str(bugid),)) return True for b in tinfo["blocks"]: blocked_ref = extref(b) log("%s is blocking %s" % (blocker_ref, blocked_ref)) if blocked_ref: log(phabdb.set_blocked_task(blocker_ref, blocked_ref)) else: log('%s is missing blocker %s' % (blocked_ref, blocker_ref)) blocks = phabdb.get_tasks_blocked(blocker_ref) vlog('%s is blocking %s' % (blocker_ref, str(blocks))) current = pmig.sql_x("SELECT * from task_relations where id = %s", bugid) if current: pmig.sql_x("UPDATE task_relations SET priority=%s, blocks=%s, modified=%s WHERE id = %s", (ipriority['update_success'], json.dumps(blocks), now(), bugid)) else: sql = "INSERT INTO task_relations (id, priority, blocks, modified) VALUES (%s, %s, %s, %s)" pmig.sql_x(sql, (bugid, ipriority['update_success'], json.dumps(blocks), now())) pmig.close() return True
def update(id): fabdb = phabdb.phdb(db='fab_migration') epriority = fabdb.sql_x("SELECT priority from task_relations where id = %s", id) if epriority and epriority[0] == ipriority['creation_success']: log('Skipping %s as blockers already updated' % (id,)) return True hq = "SELECT header FROM fab_meta WHERE id = %s" header = fabdb.sql_x(hq, (id,)) if not header: vlog('no header found for %s' % (id,)) return True def extref(ticket): refid = phabdb.reference_ticket("%s%s" % (fablib.prepend, ticket)) if not refid: return '' return refid[0] blocker_ref = extref(id) tinfo = json.loads(header[0]) vlog(tinfo) for b in tinfo['xblocking']: blocked_ref = extref(b) log("%s is blocking %s" % (blocker_ref, blocked_ref)) if blocked_ref: log(phabdb.set_blocked_task(blocker_ref, blocked_ref)) else: log('%s is missing blocker %s' % (blocked_ref, blocker_ref)) blocks = phabdb.get_tasks_blocked(blocker_ref) log('%s is blocking %s' % (blocker_ref, str(blocks))) current = fabdb.sql_x("SELECT * from task_relations where id = %s", id) if current: fabdb.sql_x("UPDATE task_relations SET priority=%s, blocks=%s, modified=%s WHERE id = %s", (ipriority['creation_success'], json.dumps(blocks), now(), id)) else: sql = "INSERT INTO task_relations (id, priority, blocks, modified) VALUES (%s, %s, %s, %s)" fabdb.sql_x(sql, (id, ipriority['creation_success'], json.dumps(blocks), now())) fabdb.close() return True
def update(bugid): pmig = phabdb.phdb(db=config.rtmigrate_db) epriority = pmig.sql_x("SELECT priority \ from task_relations \ where id = %s", bugid) if epriority and epriority[0] == ipriority['update_success']: log('skipping %s as blockers already updated' % (bugid,)) return True query = "SELECT header FROM rt_meta WHERE id = %s" header = pmig.sql_x(query, (bugid,)) if not header: elog('no header found for %s' % (bugid,)) return 'missing' def extref(ticket): refid = phabdb.reference_ticket("%s%s" % (rtlib.prepend, ticket)) if not refid: return '' return refid[0] blocker_ref = extref(bugid) tinfo = json.loads(header[0][0]) upstream = [] if 'parent' in tinfo['links']: upstream += tinfo['links']['parent'] if 'blocks' in tinfo['links']: upstream += tinfo['links']['blocks'] if upstream: for b in upstream: blocked_ref = extref(b) log("%s is blocking %s" % (blocker_ref, blocked_ref)) if blocked_ref: log(phabdb.set_blocked_task(blocker_ref, blocked_ref)) else: log('%s is missing blocker %s' % (blocked_ref, blocker_ref)) blocks = phabdb.get_tasks_blocked(blocker_ref) vlog('%s is blocking %s' % (blocker_ref, str(blocks))) current = pmig.sql_x("SELECT * \ from task_relations \ WHERE id = %s", bugid) if current: pmig.sql_x("UPDATE task_relations \ SET priority=%s, blocks=%s, modified=%s \ WHERE id = %s", (ipriority['update_success'], json.dumps(blocks), now(), bugid)) else: sql = "INSERT INTO task_relations \ (id, priority, blocks, modified) \ VALUES (%s, %s, %s, %s)" pmig.sql_x(sql, (bugid, ipriority['update_success'], json.dumps(blocks), now())) pmig.close() return True