<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> from __future__ import division <EOL> from __future__ import print_function <EOL> import os <EOL> import shutil <EOL> import stat <EOL> import phlsys_fs <EOL> import phlsys_git <EOL> import phlsys_web <EOL> import atet_worker <EOL> _PRE_RECEIVE_HOLD_DEV_ARCYD_REFS = """<STR_LIT>""" . lstrip ( ) <EOL> class SharedRepo ( object ) : <EOL> def __init__ ( <EOL> self , <EOL> root_dir , <EOL> barc_cmd_path , <EOL> arcyon_cmd_path , <EOL> phab_uri , <EOL> alice , <EOL> bob ) : <EOL> self . _root_dir = root_dir <EOL> self . central_path = os . path . join ( self . _root_dir , '<STR_LIT>' ) <EOL> os . makedirs ( self . central_path ) <EOL> self . _central_repo = phlsys_git . Repo ( self . central_path ) <EOL> self . _central_repo ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . web_port = phlsys_web . pick_free_port ( ) <EOL> shutil . move ( <EOL> os . path . join ( self . central_path , '<STR_LIT>' ) , <EOL> os . path . join ( self . central_path , '<STR_LIT>' ) ) <EOL> self . _command_hold_path = os . path . join ( <EOL> self . central_path , '<STR_LIT>' ) <EOL> pre_receive_path = os . path . join ( self . central_path , '<STR_LIT>' ) <EOL> phlsys_fs . write_text_file ( <EOL> pre_receive_path , <EOL> _PRE_RECEIVE_HOLD_DEV_ARCYD_REFS ) <EOL> mode = os . stat ( pre_receive_path ) . st_mode <EOL> os . chmod ( pre_receive_path , mode | stat . S_IEXEC ) <EOL> self . _web = phlsys_web . SimpleWebServer ( <EOL> self . central_path , <EOL> self . web_port ) <EOL> self . _workers = [ ] <EOL> for account in ( alice , bob ) : <EOL> account_user = account [ <NUM_LIT:0> ] <EOL> account_email = account [ <NUM_LIT:1> ] <EOL> account_cert = account [ <NUM_LIT:2> ] <EOL> worker_path = os . path . join ( self . _root_dir , account_user ) <EOL> os . makedirs ( worker_path ) <EOL> self . _workers . append ( <EOL> atet_worker . Worker ( <EOL> phlsys_git . Repo ( worker_path ) , <EOL> worker_path , <EOL> barc_cmd_path , <EOL> account_user , <EOL> account_email , <EOL> account_cert , <EOL> arcyon_cmd_path , <EOL> phab_uri ) ) <EOL> self . _workers [ - <NUM_LIT:1> ] . setup ( self . _central_repo . working_dir ) <EOL> if len ( self . _workers ) == <NUM_LIT:1> : <EOL> self . _workers [ <NUM_LIT:0> ] . push_initial_commit ( ) <EOL> else : <EOL> self . _workers [ - <NUM_LIT:1> ] . repo ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def hold_dev_arcyd_refs ( self ) : <EOL> phlsys_fs . write_text_file ( <EOL> self . _command_hold_path , <EOL> _PRE_RECEIVE_HOLD_DEV_ARCYD_REFS ) <EOL> def release_dev_arcyd_refs ( self ) : <EOL> os . remove ( self . _command_hold_path ) <EOL> @ property <EOL> def snoop_url ( self ) : <EOL> return "<STR_LIT>" . format ( self . web_port ) <EOL> @ property <EOL> def central_repo ( self ) : <EOL> return self . _central_repo <EOL> @ property <EOL> def workers ( self ) : <EOL> return self . _workers <EOL> @ property <EOL> def alice ( self ) : <EOL> return self . _workers [ <NUM_LIT:0> ] <EOL> @ property <EOL> def bob ( self ) : <EOL> return self . _workers [ <NUM_LIT:1> ] <EOL> def close ( self ) : <EOL> self . _web . close ( ) </s>
