/* Ċ Ġ* ĠCopyright Ġ 2 0 0 0 - 2 0 1 6 ĠJetBrains Ġs . r . o . Ċ Ġ* Ċ Ġ* ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ Ġ* Ġyou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ Ġ* ĠYou Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat Ċ Ġ* Ċ Ġ* Ġhttp :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ Ġ* Ċ Ġ* ĠUnless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ Ġ* Ġdistributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ Ġ* ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ Ġ* ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ Ġ* Ġlimitations Ġunder Ġthe ĠLicense . Ċ Ġ*/ Ċ package Ġgit 4 idea . ch err yp ick Ċ Ċ import Ġgit 4 idea . test . branch Ċ import Ġgit 4 idea . test . checkout Ċ import Ġgit 4 idea . test . checkout New Ċ import Ġgit 4 idea . test . file Ċ Ċ class ĠGit Ch erry Pick Auto Commit Test Ġ: ĠGit Ch erry Pick Test () Ġ{ ĊĊĠ Ġoverride Ġfun ĠsetUp () Ġ{ ĊĠĠĠ Ġsuper . setUp () ĊĠĠĠ Ġmy Git Settings . is Auto Commit On Ch erry Pick Ġ= Ġtrue ĊĠ Ġ} ĊĊĠ Ġfun Ġ` test Ġsimple Ġcherry - pick `() Ġ{ ĊĠĠĠ Ġbranch (" feature ") ĊĠĠĠ Ġval Ġcommit Ġ= Ġfile (" c . txt "). create (). add Commit (" fix Ġ# 1 "). hash () ĊĠĠĠ Ġcheckout (" feature ") ĊĊĠĠĠ Ġcherry Pick ( commit ) ĊĊĠĠĠ Ġassert Successful Notification (" Ch erry - pick Ġsuccessful ", Ġ"${ short Hash ( commit )} Ġfix Ġ# 1 ") ĊĠĠĠ Ġassert Last Message (" fix Ġ# 1 \ n \ n ( ch erry Ġpicked Ġfrom Ġcommit Ġ${ commit }) ") ĊĠĠĠ Ġassert Only Default Change list () ĊĠ Ġ} ĊĊĠ Ġfun Ġ` test Ġdirty Ġtree Ġconflicting Ġwith Ġcommit `() Ġ{ ĊĠĠĠ Ġ` check Ġdirty Ġtree Ġconflicting Ġwith Ġcommit `() ĊĠ Ġ} ĊĊĠ Ġfun Ġ` test Ġun tracked Ġfile Ġconflicting Ġwith Ġcommit `() Ġ{ ĊĠĠĠ Ġ` check Ġun tracked Ġfile Ġconflicting Ġwith Ġcommit `() ĊĠ Ġ} ĊĊĠ Ġfun Ġ` test Ġconflict Ġwith Ġcherry - pick ed Ġcommit Ġshould Ġshow Ġmerge Ġdialog `() Ġ{ ĊĠĠĠ Ġ` check Ġconflict Ġwith Ġcherry - pick ed Ġcommit Ġshould Ġshow Ġmerge Ġdialog `() ĊĠ Ġ} ĊĊĠ Ġfun Ġ` test Ġun resolved Ġconflict Ġwith Ġcherry - pick ed Ġcommit Ġshould Ġproduce Ġa Ġchange list `() Ġ{ ĊĠĠĠ Ġval Ġcommit Ġ= Ġprepare Conflict () ĊĠĠĠ Ġ` do Ġnothing Ġon Ġmerge `() ĊĊĠĠĠ Ġcherry Pick ( commit ) ĊĊĠĠĠ Ġ` assert Ġmerge Ġdialog Ġwas Ġshown `() ĊĠĠĠ Ġassert Change list Created (" on _ master Ġ( ch erry Ġpicked Ġfrom Ġcommit Ġ${ short Hash ( commit )}) ") ĊĠĠĠ Ġassert Warning Notification (" Ch erry - pick ed Ġwith Ġconflicts ", Ġ""" ĊĠĠĠĠĠ Ġ${ short Hash ( commit )} Ġon _ master ĊĠĠĠĠĠ ĠUn resolved Ġconflicts Ġremain Ġin Ġthe Ġworking Ġtree . Ġ< a Ġhref =' resolve '> Resolve Ġthem .< a /> ĊĠĠĠĠĠ Ġ"" ") ĊĠ Ġ} ĊĊĠ Ġfun Ġ` test Ġresolve Ġconflicts Ġand Ġcommit `() Ġ{ ĊĠĠĠ Ġ` check Ġresolve Ġconflicts Ġand Ġcommit `() ĊĠ Ġ} ĊĊĠ Ġfun Ġ` test Ġresolve Ġconflicts Ġbut Ġcancel Ġcommit `() Ġ{ ĊĠĠĠ Ġval Ġcommit Ġ= Ġprepare Conflict () ĊĠĠĠ Ġ` mark Ġas Ġresolved Ġon Ġmerge `() ĊĠĠĠ Ġv cs Helper . on Commit Ġ{ Ġmsg Ġ-> Ġfalse Ġ} ĊĊĠĠĠ Ġcherry Pick ( commit ) ĊĊĠĠĠ Ġ` assert Ġmerge Ġdialog Ġwas Ġshown `() ĊĠĠĠ Ġassert Change list Created (" on _ master Ġ( ch erry Ġpicked Ġfrom Ġcommit Ġ${ short Hash ( commit )}) ") ĊĠĠĠ Ġassert No Notification () ĊĠ Ġ} ĊĊĠ Ġfun Ġ` test Ġcherry - pick Ġ 2 Ġcommit `() Ġ{ ĊĠĠĠ Ġbranch (" feature ") ĊĠĠĠ Ġval Ġcommit 1 Ġ= Ġfile (" one . txt "). create (). add Commit (" fix Ġ# 1 "). hash () ĊĠĠĠ Ġval Ġcommit 2 Ġ= Ġfile (" two . txt "). create (). add Commit (" fix Ġ# 2 "). hash () ĊĠĠĠ Ġcheckout (" feature ") ĊĊĠĠĠ Ġcherry Pick ( commit 1 , Ġcommit 2 ) ĊĊĠĠĠ Ġassert Log Messages (""" ĊĠĠĠĠĠ Ġfix Ġ# 2 ĊĊĠĠĠĠĠ Ġ( ch erry Ġpicked Ġfrom Ġcommit Ġ$ commit 2 ) """, Ġ""" ĊĠĠĠĠĠ Ġfix Ġ# 1 ĊĊĠĠĠĠĠ Ġ( ch erry Ġpicked Ġfrom Ġcommit Ġ$ commit 1 ) """) ĊĠĠĠ Ġassert Successful Notification (" Ch erry - pick Ġsuccessful ", """ ĊĠĠĠĠĠ Ġ${ short Hash ( commit 1 )} Ġfix Ġ# 1 ĊĠĠĠĠĠ Ġ${ short Hash ( commit 2 )} Ġfix Ġ# 2 Ċ """) ĊĠ Ġ} ĊĊĠ Ġfun Ġ` test Ġcherry - pick ed Ġ 3 Ġcommits Ġwhere Ġ 2 nd Ġconflicts Ġwith Ġlocal Ġchanges `() Ġ{ ĊĠĠĠ Ġval Ġcommon Ġ= Ġfile (" common . txt ") ĊĠĠĠ Ġcommon . create (" initial Ġcontent \ n "). add Commit (" common ") ĊĠĠĠ Ġbranch (" feature ") ĊĠĠĠ Ġval Ġcommit 1 Ġ= Ġfile (" one . txt "). create (). add Commit (" fix Ġ# 1 "). hash () ĊĠĠĠ Ġval Ġcommit 2 Ġ= Ġcommon . append (" on Ġmaster \ n "). add Commit (" app ended Ġcommon "). hash () ĊĠĠĠ Ġval Ġcommit 3 Ġ= Ġfile (" two . txt "). create (). add Commit (" fix Ġ# 2 "). hash () ĊĠĠĠ Ġcheckout (" feature ") ĊĠĠĠ Ġcommon . append (" on Ġfeature \ n ") ĊĊĠĠĠ Ġcherry Pick ( commit 1 , Ġcommit 2 , Ġcommit 3 ) ĊĊĠĠĠ Ġassert Error Notification (" Ch erry - pick ĠFailed ", Ġ""" ĊĠĠĠĠĠ Ġ${ short Hash ( commit 2 )} Ġappended Ġcommon ĊĠĠĠĠĠ ĠYour Ġlocal Ġchanges Ġwould Ġbe Ġoverwritten Ġby Ġcherry - pick . ĊĠĠĠĠĠ ĠCommit Ġyour Ġchanges Ġor Ġst ash Ġthem Ġto Ġproceed . ĊĠĠĠĠĠ ĠHowever Ġcherry - pick Ġsucceeded Ġfor Ġthe Ġfollowing Ġcommit : ĊĠĠĠĠĠ Ġ${ short Hash ( commit 1 )} Ġfix Ġ# 1 """) ĊĊĠ Ġ} ĊĊĠ Ġfun Ġ` test Ġcherry - pick Ġ 3 Ġcommits , Ġwhere Ġsecond Ġconflicts Ġwith Ġmaster `() Ġ{ ĊĠĠĠ Ġval Ġcommon Ġ= Ġfile (" common . txt ") ĊĠĠĠ Ġcommon . create (" initial Ġcontent \ n "). add Commit (" common ") ĊĠĠĠ Ġbranch (" feature ") ĊĠĠĠ Ġval Ġcommit 1 Ġ= Ġfile (" one . txt "). create (). add Commit (" fix Ġ# 1 "). hash () ĊĠĠĠ Ġval Ġcommit 2 Ġ= Ġcommon . append (" on Ġmaster \ n "). add Commit (" app ended Ġcommon "). hash () ĊĠĠĠ Ġval Ġcommit 3 Ġ= Ġfile (" two . txt "). create (). add Commit (" fix Ġ# 2 "). hash () ĊĠĠĠ Ġcheckout (" feature ") ĊĠĠĠ Ġcommon . append (" on Ġfeature \ n "). add Commit (" app ended Ġon Ġfeature "). hash () ĊĠĠĠ Ġ` do Ġnothing Ġon Ġmerge `() ĊĊĠĠĠ Ġcherry Pick ( commit 1 , Ġcommit 2 , Ġcommit 3 ) ĊĊĠĠĠ Ġ` assert Ġmerge Ġdialog Ġwas Ġshown `() ĊĠĠĠ Ġassert Last Message (" fix Ġ# 1 \ n \ n ( ch erry Ġpicked Ġfrom Ġcommit Ġ$ commit 1 )") ĊĠ Ġ} ĊĊĠ Ġ// ĠIDEA - 7 3 5 4 8 ĊĠ Ġfun Ġ` test Ġnothing Ġto Ġcommit `() Ġ{ ĊĠĠĠ Ġval Ġcommit Ġ= Ġfile (" c . txt "). create (). add Commit (" fix Ġ# 1 "). hash () ĊĠĠĠ Ġcheckout New (" feature ") ĊĊĠĠĠ Ġcherry Pick ( commit ) ĊĊĠĠĠ Ġassert Warning Notification (" Nothing Ġto Ġcherry - pick ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" All Ġchanges Ġfrom Ġ${ short Hash ( commit )} Ġhave Ġalready Ġbeen Ġapplied ") ĊĠ Ġ} ĊĊĠ Ġ// ĠIDEA - 7 3 5 4 8 ĊĠ Ġfun Ġ` test Ġseveral Ġcommits Ġone Ġof Ġwhich Ġhave Ġalready Ġbeen Ġapplied `() Ġ{ ĊĠĠĠ Ġfile (" common . txt "). create (" common Ġcontent \ n "). add Commit (" common Ġfile ") ĊĠĠĠ Ġcheckout New (" feature ") ĊĠĠĠ Ġval Ġcommit 1 Ġ= Ġfile (" a . txt "). create (" initial \ n "). add Commit (" fix Ġ# 1 "). hash () ĊĠĠĠ Ġval Ġempty Commit Ġ= Ġfile (" common . txt "). append (" more Ġto Ġcommon \ n "). add Commit (" to Ġcommon "). hash () ĊĠĠĠ Ġval Ġcommit 3 Ġ= Ġfile (" a . txt "). append (" more \ n "). add Commit (" fix Ġ# 2 "). hash () ĊĠĠĠ Ġcheckout (" master ") ĊĠĠĠ Ġfile (" common . txt "). append (" more Ġto Ġcommon \ n "). add Commit (" to Ġcommon Ġfrom Ġmaster ") ĊĊĠĠĠ Ġcherry Pick ( commit 1 , Ġempty Commit , Ġcommit 3 ) ĊĊĠĠĠ Ġassert Log Messages ( ĊĠĠĠĠĠ Ġ""" ĊĠĠĠĠĠ Ġfix Ġ# 2 ĊĊĠĠĠĠĠ Ġ( ch erry Ġpicked Ġfrom Ġcommit Ġ$ commit 3 ) """, ĊĠĠĠĠĠ Ġ""" ĊĠĠĠĠĠ Ġfix Ġ# 1 ĊĊĠĠĠĠĠ Ġ( ch erry Ġpicked Ġfrom Ġcommit Ġ$ commit 1 ) """) ĊĠĠĠ Ġassert Successful Notification (" Ch erry - pick ed Ġ 2 Ġcommits Ġfrom Ġ 3 ", """ ĊĠĠĠĠĠ Ġ${ short Hash ( commit 1 )} Ġfix Ġ# 1 ĊĠĠĠĠĠ Ġ${ short Hash ( commit 3 )} Ġfix Ġ# 2 ĊĠĠĠĠĠ Ġ${ short Hash ( empty Commit )} Ġwas Ġskipped , Ġbecause Ġall Ġchanges Ġhave Ġalready Ġbeen Ġapplied . """) ĊĠ Ġ} Ċ }