diff --git a/src/applications/repository/engine/__tests__/data/CHB.hg.tgz b/src/applications/repository/engine/__tests__/data/CHB.hg.tgz new file mode 100644 index 0000000000000000000000000000000000000000..f51e36812f095347134aefee0987efb3632af7de GIT binary patch literal 3084 zcmb2|=3v;`dN+uH`E3k$Oh~Adyo7`7Jn4>8r>wX%mi2zGO)rWxov)MisX*DZ;MqNE z15TcE%}cK+aWVOZxM(V!4VjXA`mB%n<)%>12~1O6;n- zcSg;z-(S4`-tn6Iw)g+ee{X%?^1Fu`=NmqbCJzoF>2EA~H=H@r?#xzb6KqikXYN^$n{GPD+U`zN%_){!5)~^~|83-20QO_&)zLXF93kSu~An zI$U?~pTW)CdXcoZ{fQc<>rdoKMJ6=djz7NSl}l$9ud>;n*LACz4;cIW@efed-8{R; z?q@wq;!pns3mpMvwyQ!{HFbEKfLn?|8b53_4^)ZEc@EodA{T9`i6+*V(Qs5MASUhuVsgNzGKBQ(j}Fc`SE+NM^#0QDH~8IWx~I@%uV4Tdr?+%-)#^R_jf_%Ws%Id)K>1bss!GOYVNQknvsX#Q&T{ zYu`#Nmc4cP?Z5Viy8g3tIXC>TaqzqRh;!xlXzqsJtjhmQ&lK(TI-K!V z`LNo5!`J`h-6p9#u$NERU76Fb&nl)lnP)D;#IWVp43whQCQs5ZJ=<{S!h31Af6_hw z6u$lsU^?^v0jt~Z*ON20x-1OS_nwkH?dxvw4YL0uZ_jV=5ZUs-=D?+YQk6oY`RtP0 z-ug$~ly^6L@V}Drtj5z{EECSkuGsLv{%nTk?h_kM)=O-AX5Z5AZN9jGlGofBE0~P! z*)(*1=C5~Ti2k$R{D1#s4T=9xSAIfm>F<-QZzpZ9p|`dkyW zNnmY}ctCM;Q2e*edu+EBWZX3AUpZlVv2Xgr=*QQ@T^8Jo%)fq5YTDebUmktG*dEoU z$5WGhX0FNn>xVjee|K`aWZZqlGktCF()s*rt^Yjz0PzUtIM3@93ON);p4xxliv3Z`H4=iaGsf(=U~n%T-_aT~`-3 zrNw-|wCwE(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kMVH{ne~@NCe%$&)c(&N{p^3w zH+7B&|0^3CKZ~6-@AOKsxN`U0SBpbG?N2k?`W2lus(w&sFXSMfaPt3?ik;IguDH6Z zZXRP&@gM&8&+PdG+ur}@-0+WGzu_oL&*7XiI?57Dn?k&HF5ML%vQ(oZ?QGkojn;l% zOI3LG3H^;dH0l2xjRm$TH=fv+o&O=v^z8qKW;siFp=K9b_QsSTrVszV^JM??ej~v0 z<>-IupZ-l>_g64|_|Gi;{Ym|s4KgY5pX@C%JN_%mF#nXdE9n2*yZ2Y!)Wp?)-2>L# z{Bg^3M=$@my)0g<+9>tkf_^^nr#ov4cc(`DoNnJXeQLzZhdEjahDLE0wf`skR_?2t zlsNf+hwJbDqMz|X#}E9f|FdBBe{P@F=4A2z&+k}mDZf5pJyS}cv{s+%f9qXu+ArBo z+rC`v*YwuzOGo0)1=r{F`IHvbWo@iVo?ZT{e$OWUbyoX}-o98Z`?GWM^Z%D0pa05# zo=>*YF6qy?Y+>)v?B|thZC?J{_$n+lyYlSCli^XVn&IrB^%i&LUQcKLVfjxw_~&1h z!(#svZ&dwhKXUMo|GW!l>%+H|{ET_7_iuiH{GSJ9pFSUCY}dX#@1FJT?J9c@p8Zs2 zE1&&^=?1U;;rh!b;{Ts`G5P;-#lHV4EI-ckSAGBQ^x!``Th-bBGoCYj>F1gK?|#x> z_2hr;dwGuh|Fhuxzx~1D|NFOwKKE7=JCpfcEC1w=VBalqPmPX$DzlAn_+id_`m22} zx5E+RqFwds4L6?bcl~$X|v;2U;qGrLo-JJ literal 0 HcmV?d00001 diff --git a/src/applications/repository/worker/__tests__/PhabricatorChangeParserTestCase.php b/src/applications/repository/worker/__tests__/PhabricatorChangeParserTestCase.php index 4805b95578..913fa4678f 100644 --- a/src/applications/repository/worker/__tests__/PhabricatorChangeParserTestCase.php +++ b/src/applications/repository/worker/__tests__/PhabricatorChangeParserTestCase.php @@ -202,6 +202,197 @@ final class PhabricatorChangeParserTestCase )); } + public function testMercurialParser() { + $repository = $this->buildDiscoveredRepository('CHB'); + $viewer = PhabricatorUser::getOmnipotentUser(); + + $commits = id(new DiffusionCommitQuery()) + ->setViewer($viewer) + ->withRepositoryIDs(array($repository->getID())) + ->execute(); + + $this->expectChanges( + $repository, + $commits, + array( + '970357a2dc4264060e65d68e42240bb4e5984085' => array( + array( + '/', + null, + null, + DifferentialChangeType::TYPE_CHILD, + DifferentialChangeType::FILE_DIRECTORY, + 0, + 1390249395, + ), + array( + '/file_moved', + null, + null, + DifferentialChangeType::TYPE_CHANGE, + DifferentialChangeType::FILE_NORMAL, + 1, + 1390249395, + ), + ), + + 'fbb49af9788e5dbffbc05a060b680df1fd457be3' => array( + array( + '/', + null, + null, + DifferentialChangeType::TYPE_CHILD, + DifferentialChangeType::FILE_DIRECTORY, + 0, + 1390249380, + ), + array( + '/file_link', + null, + null, + DifferentialChangeType::TYPE_ADD, + // TODO: This is not correct, and should be FILE_SYMLINK. See + // note in the parser about this. This is a known bug. + DifferentialChangeType::FILE_NORMAL, + 1, + 1390249380, + ), + ), + + '0e8d3465944c7ed7a7c139da7edc652cf80dba69' => array( + array( + '/', + null, + null, + DifferentialChangeType::TYPE_CHILD, + DifferentialChangeType::FILE_DIRECTORY, + 0, + 1390249342, + ), + array( + '/dir', + null, + null, + DifferentialChangeType::TYPE_ADD, + DifferentialChangeType::FILE_DIRECTORY, + 1, + 1390249342, + ), + array( + '/dir/subfile', + null, + null, + DifferentialChangeType::TYPE_ADD, + DifferentialChangeType::FILE_NORMAL, + 1, + 1390249342, + ), + ), + + '22c75131ff15c8a44d7a729c4542b7f4c8ed27f4' => array( + array( + '/', + null, + null, + DifferentialChangeType::TYPE_CHILD, + DifferentialChangeType::FILE_DIRECTORY, + 0, + 1390249320, + ), + array( + '/file', + null, + null, + DifferentialChangeType::TYPE_MOVE_AWAY, + DifferentialChangeType::FILE_NORMAL, + 1, + 1390249320, + ), + array( + '/file_moved', + '/file', + '22c75131ff15c8a44d7a729c4542b7f4c8ed27f4', + DifferentialChangeType::TYPE_MOVE_HERE, + DifferentialChangeType::FILE_NORMAL, + 1, + 1390249320, + ), + ), + + 'd9d252df30cb7251ad3ea121eff30c7d2e36dd67' => array( + array( + '/', + null, + null, + DifferentialChangeType::TYPE_CHILD, + DifferentialChangeType::FILE_DIRECTORY, + 0, + 1390249308, + ), + array( + '/file', + null, + null, + DifferentialChangeType::TYPE_COPY_AWAY, + DifferentialChangeType::FILE_NORMAL, + 0, + 1390249308, + ), + array( + '/file_copy', + '/file', + 'd9d252df30cb7251ad3ea121eff30c7d2e36dd67', + DifferentialChangeType::TYPE_COPY_HERE, + DifferentialChangeType::FILE_NORMAL, + 1, + 1390249308, + ), + ), + + '1fc0445d5e3d0f33e9dcbb68bbe419a847460d25' => array( + array( + '/', + null, + null, + DifferentialChangeType::TYPE_CHILD, + DifferentialChangeType::FILE_DIRECTORY, + 0, + 1390249294, + ), + array( + '/file', + null, + null, + DifferentialChangeType::TYPE_CHANGE, + DifferentialChangeType::FILE_NORMAL, + 1, + 1390249294, + ), + ), + + '61518e196efb7f80700333cc0d00634c2578871a' => array( + array( + '/', + null, + null, + DifferentialChangeType::TYPE_ADD, + DifferentialChangeType::FILE_DIRECTORY, + 1, + 1390249286, + ), + array( + '/file', + null, + null, + DifferentialChangeType::TYPE_ADD, + DifferentialChangeType::FILE_NORMAL, + 1, + 1390249286, + ), + ), + )); + } + private function expectChanges( PhabricatorRepository $repository, array $commits, @@ -211,6 +402,9 @@ final class PhabricatorChangeParserTestCase case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: $parser = 'PhabricatorRepositoryGitCommitChangeParserWorker'; break; + case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL: + $parser = 'PhabricatorRepositoryMercurialCommitChangeParserWorker'; + break; default: throw new Exception(pht('No support yet.')); } diff --git a/src/applications/repository/worker/commitchangeparser/PhabricatorRepositoryMercurialCommitChangeParserWorker.php b/src/applications/repository/worker/commitchangeparser/PhabricatorRepositoryMercurialCommitChangeParserWorker.php index cf17e65151..0fdd18b20f 100644 --- a/src/applications/repository/worker/commitchangeparser/PhabricatorRepositoryMercurialCommitChangeParserWorker.php +++ b/src/applications/repository/worker/commitchangeparser/PhabricatorRepositoryMercurialCommitChangeParserWorker.php @@ -263,45 +263,21 @@ final class PhabricatorRepositoryMercurialCommitChangeParserWorker } } - $conn_w = $repository->establishConnection('w'); - - $changes_sql = array(); + $results = array(); foreach ($changes as $change) { - $values = array( - (int)$change['repositoryID'], - (int)$change['pathID'], - (int)$change['commitID'], - $change['targetPathID'] - ? (int)$change['targetPathID'] - : 'null', - $change['targetCommitID'] - ? (int)$change['targetCommitID'] - : 'null', - (int)$change['changeType'], - (int)$change['fileType'], - (int)$change['isDirect'], - (int)$change['commitSequence'], - ); - $changes_sql[] = '('.implode(', ', $values).')'; - } - - queryfx( - $conn_w, - 'DELETE FROM %T WHERE commitID = %d', - PhabricatorRepository::TABLE_PATHCHANGE, - $commit->getID()); - foreach (array_chunk($changes_sql, 256) as $sql_chunk) { - queryfx( - $conn_w, - 'INSERT INTO %T - (repositoryID, pathID, commitID, targetPathID, targetCommitID, - changeType, fileType, isDirect, commitSequence) - VALUES %Q', - PhabricatorRepository::TABLE_PATHCHANGE, - implode(', ', $sql_chunk)); + $result = id(new PhabricatorRepositoryParsedChange()) + ->setPathID($change['pathID']) + ->setTargetPathID($change['targetPathID']) + ->setTargetCommitID($change['targetCommitID']) + ->setChangeType($change['changeType']) + ->setFileType($change['fileType']) + ->setIsDirect($change['isDirect']) + ->setCommitSequence($change['commitSequence']); + + $results[] = $result; } - return array(); + return $results; } private function mercurialPathExists(