<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 unittest <EOL> import phlgit_checkout <EOL> import phlgit_commit <EOL> import phlgit_fetch <EOL> import phlgit_merge <EOL> import phlgit_push <EOL> import phlgit_rebase <EOL> import phlgit_revparse <EOL> import phlgitu_fixture <EOL> import phlgitx_refcache <EOL> import abdt_branch <EOL> import abdt_classicnaming <EOL> import abdt_differresultcache <EOL> import abdt_git <EOL> import abdt_naming <EOL> import abdt_rbranchnaming <EOL> class Test ( unittest . TestCase ) : <EOL> def __init__ ( self , data ) : <EOL> super ( Test , self ) . __init__ ( data ) <EOL> self . repos = None <EOL> self . repo_central = None <EOL> self . repo_dev = None <EOL> self . repo_arcyd = None <EOL> def setUp ( self ) : <EOL> self . repos = phlgitu_fixture . CentralisedWithTwoWorkers ( ) <EOL> self . repo_central = self . repos . central_repo <EOL> self . repo_dev = self . repos . w0 . repo <EOL> sys_repo = self . repos . w1 . repo <EOL> refcache_repo = phlgitx_refcache . Repo ( sys_repo ) <EOL> differ_cache = abdt_differresultcache . Cache ( refcache_repo ) <EOL> self . repo_arcyd = abdt_git . Repo ( <EOL> refcache_repo , differ_cache , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def tearDown ( self ) : <EOL> self . repos . close ( ) <EOL> def test_A_Breathing ( self ) : <EOL> remote = "<STR_LIT>" <EOL> expected_branches = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> for branch in expected_branches : <EOL> phlgit_push . push_asymmetrical ( <EOL> self . repo_dev , '<STR_LIT>' , branch , remote ) <EOL> self . repo_arcyd ( "<STR_LIT>" ) <EOL> branches = abdt_git . get_managed_branches ( <EOL> self . repo_arcyd , "<STR_LIT>" , abdt_rbranchnaming . Naming ( ) ) <EOL> actual_branches = [ b . review_branch_name ( ) for b in branches ] <EOL> self . assertSetEqual ( set ( expected_branches ) , set ( actual_branches ) ) <EOL> for b in branches : <EOL> self . repo_arcyd . archive_to_abandoned ( <EOL> b . review_branch_hash ( ) , <EOL> b . review_branch_name ( ) , <EOL> '<STR_LIT>' ) <EOL> self . repo_arcyd . archive_to_landed ( <EOL> b . review_branch_hash ( ) , <EOL> b . review_branch_name ( ) , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> def _get_updated_branch ( self , branch_name ) : <EOL> phlgit_fetch . all_prune ( self . repo_arcyd ) <EOL> branch_list = abdt_git . get_managed_branches ( <EOL> self . repo_arcyd , "<STR_LIT>" , abdt_classicnaming . Naming ( ) ) <EOL> self . assertEqual ( len ( branch_list ) , <NUM_LIT:1> ) <EOL> branch = branch_list [ <NUM_LIT:0> ] <EOL> self . assertEqual ( branch . review_branch_name ( ) , branch_name ) <EOL> return branch <EOL> def test_B_RawDiffNewCommits ( self ) : <EOL> base , branch_name , branch = self . _setup_for_tracked_branch ( ) <EOL> self . assertIs ( branch . has_new_commits ( ) , False ) <EOL> phlgit_checkout . branch ( self . repo_dev , branch_name ) <EOL> filename = '<STR_LIT>' <EOL> self . _create_new_file ( self . repo_dev , filename ) <EOL> self . repo_dev ( '<STR_LIT>' , filename ) <EOL> phlgit_commit . index ( self . repo_dev , message = filename ) <EOL> phlgit_push . branch ( self . repo_dev , branch_name ) <EOL> branch = self . _get_updated_branch ( branch_name ) <EOL> self . assertIs ( branch . has_new_commits ( ) , True ) <EOL> branch . describe_new_commits ( ) <EOL> self . assertIn ( filename , branch . make_raw_diff ( ) . diff ) <EOL> branch . mark_ok_in_review ( ) <EOL> self . assertIs ( branch . has_new_commits ( ) , False ) <EOL> branch . describe_new_commits ( ) <EOL> self . assertIn ( filename , branch . make_raw_diff ( ) . diff ) <EOL> self . assertIn ( filename , branch . make_message_digest ( ) ) <EOL> self . assertEqual ( <EOL> branch . get_commit_message_from_tip ( ) . strip ( ) , <EOL> filename ) <EOL> self . assertTrue ( len ( branch . get_any_author_emails ( ) ) > <NUM_LIT:0> ) <EOL> self . assertTrue ( len ( branch . get_author_names_emails ( ) ) > <NUM_LIT:0> ) <EOL> phlgit_checkout . branch ( self . repo_dev , '<STR_LIT>' ) <EOL> filename = '<STR_LIT>' <EOL> self . _create_new_file ( self . repo_dev , filename ) <EOL> self . repo_dev ( '<STR_LIT>' , filename ) <EOL> phlgit_commit . index ( self . repo_dev , message = filename ) <EOL> phlgit_push . branch ( self . repo_dev , '<STR_LIT>' ) <EOL> branch = self . _get_updated_branch ( branch_name ) <EOL> self . assertIs ( branch . has_new_commits ( ) , False ) <EOL> phlgit_checkout . branch ( self . repo_dev , branch_name ) <EOL> phlgit_merge . no_ff ( self . repo_dev , '<STR_LIT>' ) <EOL> phlgit_push . branch ( self . repo_dev , branch_name ) <EOL> self . assertIs ( branch . has_new_commits ( ) , False ) <EOL> branch = self . _get_updated_branch ( branch_name ) <EOL> self . assertNotIn ( filename , branch . make_raw_diff ( ) . diff ) <EOL> branch . mark_ok_in_review ( ) <EOL> self . assertIs ( branch . has_new_commits ( ) , False ) <EOL> phlgit_checkout . branch ( self . repo_dev , branch_name ) <EOL> phlgit_rebase . onto_upstream ( self . repo_dev , '<STR_LIT>' ) <EOL> phlgit_push . force_branch ( self . repo_dev , branch_name ) <EOL> self . assertIs ( branch . has_new_commits ( ) , False ) <EOL> branch = self . _get_updated_branch ( branch_name ) <EOL> self . assertIs ( branch . has_new_commits ( ) , True ) <EOL> branch . describe_new_commits ( ) <EOL> branch . mark_ok_in_review ( ) <EOL> self . assertIs ( branch . has_new_commits ( ) , False ) <EOL> def _setup_for_tracked_branch ( self ) : <EOL> base , branch_name , branch = self . _setup_for_untracked_branch ( ) <EOL> branch . mark_ok_new_review ( <NUM_LIT> ) <EOL> return base , branch_name , branch <EOL> def _setup_for_untracked_branch ( self , repo_name = '<STR_LIT:name>' , branch_url = None ) : <EOL> base = abdt_naming . EXAMPLE_REVIEW_BRANCH_BASE <EOL> naming = abdt_classicnaming . Naming ( ) <EOL> branch_name = abdt_classicnaming . EXAMPLE_REVIEW_BRANCH_NAME <EOL> self . repo_dev ( '<STR_LIT>' , '<STR_LIT>' , branch_name ) <EOL> phlgit_push . push ( self . repo_dev , branch_name , '<STR_LIT>' ) <EOL> self . repo_arcyd ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> review_branch = naming . make_review_branch_from_name ( branch_name ) <EOL> review_hash = phlgit_revparse . get_sha1_or_none ( <EOL> self . repo_arcyd , review_branch . branch ) <EOL> branch = abdt_branch . Branch ( <EOL> self . repo_arcyd , <EOL> review_branch , <EOL> review_hash , <EOL> None , <EOL> None , <EOL> None , <EOL> repo_name , <EOL> branch_url ) <EOL> branch . verify_review_branch_base ( ) <EOL> return base , branch_name , branch <EOL> def _create_new_file ( self , repo , filename ) : <EOL> self . assertFalse ( os . path . isfile ( filename ) ) <EOL> open ( os . path . join ( repo . working_dir , filename ) , '<STR_LIT:a>' ) . close ( ) </s>
