� V�"`c�����������@@�s����d��Z��d�d�l�m�Z�d�d�l�m�Z�d�d�l�m�Z�d�d�l�Z�d�d�l�Z�d�d�l�j�j �Z �d�d�l�m�Z�m �Z �d�d�l�m�Z�d�d �l�m�Z�d�d �l�m�Z�m�Z�m�Z�d�d�l�m�Z�d�e�f�d �������YZ�d�S(���u,���Class for interacting with svn repositories i����(���t���absolute_import(���t���unicode_literals(���t���print_functionNi���(���t ���EMPTY_STRt���VERBOSITY_VERBOSE(���t ���Repository(���t���ExternalStatus(���t���fatal_errort ���indent_stringt���printlog(���t���execute_subprocesst ���SvnRepositoryc�����������B@�s����e��Z�d��Z�e�j�d���Z�e�d���Z�d����Z�d����Z �d����Z �d����Z�e�d������Z �d����Z�e�d ������Z�e�d ������Z�e�d������Z�e�d������Z�e�d ������Z�e�d������Z�RS(���ur�� Class to represent and operate on a repository description. For testing purpose, all system calls to svn should: * be isolated in separate functions with no application logic * of the form: - cmd = ['svn', ...] - value = execute_subprocess(cmd, output_to_caller={T|F}, status_to_caller={T|F}) - return value * be static methods (not rely on self) * name as _svn_subcommand_args(user_args) This convention allows easy unit testing of the repository logic by mocking the specific calls to return predefined results. u���^URL:c���������C@�s����t��j�|��|�|���|�|��_�|��j�rF�t�j�j�|��j�|��j���|��_�n:�|��j�rp�t�j�j�|��j�|��j���|��_�n�d�}�t �|���d�S(���u4��� Parse repo (a <repo> XML element). u/���DEV_ERROR in svn repository. Shouldn't be here!N( ���R���t���__init__t���_ignore_ancestryt���_brancht���ost���patht���joint���_urlt���_tagR���(���t���selft���component_namet���repot���ignore_ancestryt���msg(����(����sT���/gpfs/hps/nco/ops/nwpara/hiresw.v8.0.1/sorc/manage_externals/manic/repository_svn.pyR���(���s���� ! !c���������C@�s����t��j�j�|�|���}�t��j�j�|���ry�t��j����}�t��j�|���|��j�|��j�|��j�|���|��j �|�d���t��j�|���n�|��j �|��j�|�|���d�S(���u���Checkout or update the working copy If the repo destination directory exists, switch the sandbox to match the externals description. If the repo destination directory does not exist, checkout the correct branch or tag. NB: <recursive> is include as an argument for compatibility with git functionality (repository_git.py) u%���Expected clean state following switchN(���R���R���R���t���existst���getcwdt���chdirt���_svn_switchR���R ���t���_abort_if_dirtyt ���_svn_checkout(���R���t ���base_dir_patht ���repo_dir_namet ���verbosityt ���recursivet ���repo_dir_patht���cwd(����(����sT���/gpfs/hps/nco/ops/nwpara/hiresw.v8.0.1/sorc/manage_externals/manic/repository_svn.pyt���checkout;���s���� c���������C@�s9���|��j��|�|���t�j�j�|���r5�|��j�|�|���n��d�S(���u?��� Check and report the status of the repository N(���t���_check_syncR���R���R���t���_status_summary(���R���t���statR#���(����(����sT���/gpfs/hps/nco/ops/nwpara/hiresw.v8.0.1/sorc/manage_externals/manic/repository_svn.pyt���statusU���s����c���������C@�s����t��j�j�|���s!�t�j�|�_�ng�|��j�|���}�|�sE�t�j�|�_�n!�|��j�|�|��j ���\�|�_�|�_ �d�j�|��j �j�d���d���|�_ �d�S(���up���Check to see if repository directory exists and is at the expected url. Return: status object u���/i���N(���R���R���R���R���t���STATUS_ERRORt ���sync_statet ���_svn_infot���UNKNOWNt ���_check_urlR���t���current_versionR���t���splitt���expected_version(���R���R(���R#���t ���svn_output(����(����sT���/gpfs/hps/nco/ops/nwpara/hiresw.v8.0.1/sorc/manage_externals/manic/repository_svn.pyR&���b���s����!c���������C@�sx���t�����}�|��j�|�|���|�j�t��j�k�rt�|��j�|���}�t�|�d���}�d�j�d�|�d�|�d�|���}�t�|���n��d�S(���u]���Check if the repo is in a dirty state; if so, abort with a helpful message. i���uV��In directory {cwd} svn status now shows: {status} ERROR: {message} One possible cause of this problem is that there may have been untracked files in your working directory that had the same name as tracked files in the new revision. To recover: Clean up the above directory (resolving conflicts, etc.), then rerun checkout_externals. R$���t���messageR)���N(���R���R'���t���clean_statet ���STATUS_OKt���_svn_status_verboseR���t���formatR���(���R���R#���R3���R(���R)���t���errmsg(����(����sT���/gpfs/hps/nco/ops/nwpara/hiresw.v8.0.1/sorc/manage_externals/manic/repository_svn.pyR���v���s���� c���������C@�s����d�}�xC�|��j����D]5�}�t�j�j�|���r�|�j�d���d�j����}�Pq�q�W|�s^�t�j�}�n!�|�|�k�rv�t�j �}�n �t�j �}�|�r��d�j�|�j�d���d���}�n�t�}�|�|�f�S(���un���Determine the svn url from svn info output and return whether it matches the expected value. u���: i���u���/i���N( ���t���Nonet ���splitlinesR���t ���RE_URLLINEt���matchR0���t���stripR���R-���R5���t���MODEL_MODIFIEDR���R���(���R2���t���expected_urlt���urlt���lineR)���R/���(����(����sT���/gpfs/hps/nco/ops/nwpara/hiresw.v8.0.1/sorc/manage_externals/manic/repository_svn.pyR.�������s���� c���������C@�sU���|��j��|���}�|��j�|���}�|�r3�t�j�|�_�n�t�j�|�_�|��j�|���|�_�d�S(���u����Report whether the svn repository is in-sync with the model description and whether the sandbox is clean or dirty. N(���t���_svn_status_xmlt���xml_status_is_dirtyR���t���DIRTYR4���R5���R6���t ���status_output(���R���R(���R#���R2���t���is_dirty(����(����sT���/gpfs/hps/nco/ops/nwpara/hiresw.v8.0.1/sorc/manage_externals/manic/repository_svn.pyR'�������s����c��� ������C@�s����d�}�d�}�t��}�y�t�j�|����}�Wn$�t�k �rK�t�d�j�|������n�X|�j�d���}�|�j�d���}�xW�|�D]O�}�|�j�d���}�|�j�d���} �| �|�k�r��qq�n��| �|�k�r��qq�qq�t �}�Pqq�W|�S(���uH��Parse svn status xml output and determine if the working copy is clean or dirty. Dirty is defined as: * modified files * added files * deleted files * missing files Unversioned files do not affect the clean/dirty status. 'external' is also an acceptable state u���externalu���unversionedu#���SVN returned invalid XML message {}u���./targetu���./entryu���./wc-statusu���item( ���t���Falset���ETt ���fromstringt ���BaseExceptionR���R7���t���findt���findallt���gett���True( ���R2���t���SVN_EXTERNALt���SVN_UNVERSIONEDRF���t ���xml_statust ���xml_targett���entriest���entryR)���t���item(����(����sT���/gpfs/hps/nco/ops/nwpara/hiresw.v8.0.1/sorc/manage_externals/manic/repository_svn.pyRC�������s(���� c���������C@�s%���d�d�|��g�}�t��|�d�t��}�|�S(���u+���Return results of svn info command u���svnu���infot���output_to_caller(���R ���RN���(���R#���t���cmdt���output(����(����sT���/gpfs/hps/nco/ops/nwpara/hiresw.v8.0.1/sorc/manage_externals/manic/repository_svn.pyR,�������s����c���������C@�s%���d�d�|��g�}�t��|�d�t��}�|�S(���u+���capture the full svn status output u���svnu���statusRV���(���R ���RN���(���R#���RW���R2���(����(����sT���/gpfs/hps/nco/ops/nwpara/hiresw.v8.0.1/sorc/manage_externals/manic/repository_svn.pyR6�������s����c���������C@�s(���d�d�d�|��g�}�t��|�d�t��}�|�S(���uB��� Get status of the subversion sandbox in repo_dir u���svnu���statusu���--xmlRV���(���R ���RN���(���R#���RW���R2���(����(����sT���/gpfs/hps/nco/ops/nwpara/hiresw.v8.0.1/sorc/manage_externals/manic/repository_svn.pyRB�������s����c���������C@�sN���d�d�d�|��|�g�}�|�t��k�r@�t�d�j�d�j�|�������n��t�|���d�S(���uN��� Checkout a subversion repository (repo_url) to checkout_dir. u���svnu���checkoutu���--quietu��� {0}u��� N(���R���R ���R7���R���R ���(���R@���R#���R!���RW���(����(����sT���/gpfs/hps/nco/ops/nwpara/hiresw.v8.0.1/sorc/manage_externals/manic/repository_svn.pyR�����s����c���������C@�sk���d�d�d�g�}�|�r%�|�j��d���n��|�j��|����|�t�k�r]�t�d�j�d�j�|�������n��t�|���d�S(���u7��� Switch branches for in an svn sandbox u���svnu���switchu���--quietu���--ignore-ancestryu��� {0}u��� N(���t���appendR���R ���R7���R���R ���(���R@���R���R!���RW���(����(����sT���/gpfs/hps/nco/ops/nwpara/hiresw.v8.0.1/sorc/manage_externals/manic/repository_svn.pyR�����s���� (���t���__name__t ���__module__t���__doc__t���ret���compileR;���RG���R���R%���R)���R&���R���t���staticmethodR.���R'���RC���R,���R6���RB���R���R���(����(����(����sT���/gpfs/hps/nco/ops/nwpara/hiresw.v8.0.1/sorc/manage_externals/manic/repository_svn.pyR������s��� - (���R\���t ���__future__R����R���R���R���R]���t���xml.etree.ElementTreet���etreet���ElementTreeRH���t���global_constantsR���R���t ���repositoryR���t���externals_statusR���t���utilsR���R���R ���R ���R���(����(����(����sT���/gpfs/hps/nco/ops/nwpara/hiresw.v8.0.1/sorc/manage_externals/manic/repository_svn.pyt���<module>���s���