<s> import api <EOL> import jsonapi <EOL> @ jsonapi . PrimaryResource <EOL> class Rebases ( object ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> contexts = ( None , "<STR_LIT>" ) <EOL> value_class = api . log . rebase . Rebase <EOL> exceptions = api . log . rebase . InvalidRebaseId <EOL> @ staticmethod <EOL> def json ( value , parameters , linked ) : <EOL> """<STR_LIT>""" <EOL> old_head = value . old_head <EOL> new_head = value . new_head <EOL> data = { "<STR_LIT:id>" : value . id , <EOL> "<STR_LIT>" : value . review . id , <EOL> "<STR_LIT>" : value . creator . id , <EOL> "<STR_LIT>" : old_head . id , <EOL> "<STR_LIT>" : new_head . id } <EOL> linked_commits = set ( [ old_head , new_head ] ) <EOL> if isinstance ( value , api . log . rebase . HistoryRewrite ) : <EOL> data . update ( { "<STR_LIT:type>" : "<STR_LIT>" } ) <EOL> else : <EOL> old_upstream = value . old_upstream <EOL> new_upstream = value . new_upstream <EOL> linked_commits . update ( [ old_upstream , new_upstream ] ) <EOL> equivalent_merge = value . equivalent_merge <EOL> if equivalent_merge : <EOL> linked_commits . add ( equivalent_merge ) <EOL> equivalent_merge = equivalent_merge . id <EOL> replayed_rebase = value . replayed_rebase <EOL> if replayed_rebase : <EOL> linked_commits . add ( replayed_rebase ) <EOL> replayed_rebase = replayed_rebase . id <EOL> data . update ( { "<STR_LIT:type>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : old_upstream . id , <EOL> "<STR_LIT>" : new_upstream . id , <EOL> "<STR_LIT>" : equivalent_merge , <EOL> "<STR_LIT>" : replayed_rebase } ) <EOL> linked . add ( jsonapi . v1 . reviews . Reviews , value . review ) <EOL> linked . add ( jsonapi . v1 . users . Users , value . creator ) <EOL> linked . add ( jsonapi . v1 . commits . Commits , * linked_commits ) <EOL> return parameters . filtered ( "<STR_LIT>" , data ) <EOL> @ staticmethod <EOL> def single ( critic , argument , parameters ) : <EOL> """<STR_LIT>""" <EOL> return Rebases . setAsContext ( parameters , api . log . rebase . fetch ( <EOL> critic , rebase_id = jsonapi . numeric_id ( argument ) ) ) <EOL> @ staticmethod <EOL> def multiple ( critic , parameters ) : <EOL> """<STR_LIT>""" <EOL> review = jsonapi . v1 . reviews . Reviews . deduce ( critic , parameters ) <EOL> return api . log . rebase . fetchAll ( critic , review = review ) <EOL> @ staticmethod <EOL> def setAsContext ( parameters , rebase ) : <EOL> parameters . setContext ( Rebases . name , rebase ) <EOL> jsonapi . v1 . reviews . Reviews . setAsContext ( parameters , rebase . review ) <EOL> return rebase </s>
