当前位置: 首页>>代码示例>>PHP>>正文


PHP PhabricatorRepository::establishConnection方法代码示例

本文整理汇总了PHP中PhabricatorRepository::establishConnection方法的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorRepository::establishConnection方法的具体用法?PHP PhabricatorRepository::establishConnection怎么用?PHP PhabricatorRepository::establishConnection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PhabricatorRepository的用法示例。


在下文中一共展示了PhabricatorRepository::establishConnection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: doLock

 protected function doLock($wait)
 {
     $conn = $this->conn;
     if (!$conn) {
         // Try to reuse a connection from the connection pool.
         $conn = array_pop(self::$pool);
     }
     if (!$conn) {
         // NOTE: Using the 'repository' database somewhat arbitrarily, mostly
         // because the first client of locks is the repository daemons. We must
         // always use the same database for all locks, but don't access any
         // tables so we could use any valid database. We could build a
         // database-free connection instead, but that's kind of messy and we
         // might forget about it in the future if we vertically partition the
         // application.
         $dao = new PhabricatorRepository();
         // NOTE: Using "force_new" to make sure each lock is on its own
         // connection.
         $conn = $dao->establishConnection('w', $force_new = true);
         // NOTE: Since MySQL will disconnect us if we're idle for too long, we set
         // the wait_timeout to an enormous value, to allow us to hold the
         // connection open indefinitely (or, at least, for 24 days).
         $max_allowed_timeout = 2147483;
         queryfx($conn, 'SET wait_timeout = %d', $max_allowed_timeout);
     }
     $result = queryfx_one($conn, 'SELECT GET_LOCK(%s, %f)', 'phabricator:' . $this->lockname, $wait);
     $ok = head($result);
     if (!$ok) {
         throw new PhutilLockException($this->getName());
     }
     $this->conn = $conn;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:32,代码来源:PhabricatorGlobalLock.php

示例2: checkIfRepositoryIsFullyImported

 private function checkIfRepositoryIsFullyImported(PhabricatorRepository $repository)
 {
     // Check if the repository has the "Importing" flag set. We want to clear
     // the flag if we can.
     $importing = $repository->getDetail('importing');
     if (!$importing) {
         // This repository isn't marked as "Importing", so we're done.
         return;
     }
     // Look for any commit which hasn't imported.
     $unparsed_commit = queryfx_one($repository->establishConnection('r'), 'SELECT * FROM %T WHERE repositoryID = %d AND (importStatus & %d) != %d
     LIMIT 1', id(new PhabricatorRepositoryCommit())->getTableName(), $repository->getID(), PhabricatorRepositoryCommit::IMPORTED_ALL, PhabricatorRepositoryCommit::IMPORTED_ALL);
     if ($unparsed_commit) {
         // We found a commit which still needs to import, so we can't clear the
         // flag.
         return;
     }
     // Clear the "importing" flag.
     $repository->openTransaction();
     $repository->beginReadLocking();
     $repository = $repository->reload();
     $repository->setDetail('importing', false);
     $repository->save();
     $repository->endReadLocking();
     $repository->saveTransaction();
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:26,代码来源:PhabricatorRepositoryManagementUpdateWorkflow.php

示例3: executeChecks

 protected function executeChecks()
 {
     if (phutil_is_windows()) {
         $bin_name = 'where';
     } else {
         $bin_name = 'which';
     }
     if (!Filesystem::binaryExists($bin_name)) {
         $message = pht("Without '%s', Phabricator can not test for the availability " . "of other binaries.", $bin_name);
         $this->raiseWarning($bin_name, $message);
         // We need to return here if we can't find the 'which' / 'where' binary
         // because the other tests won't be valid.
         return;
     }
     if (!Filesystem::binaryExists('diff')) {
         $message = pht("Without 'diff', Phabricator will not be able to generate or render " . "diffs in multiple applications.");
         $this->raiseWarning('diff', $message);
     } else {
         $tmp_a = new TempFile();
         $tmp_b = new TempFile();
         $tmp_c = new TempFile();
         Filesystem::writeFile($tmp_a, 'A');
         Filesystem::writeFile($tmp_b, 'A');
         Filesystem::writeFile($tmp_c, 'B');
         list($err) = exec_manual('diff %s %s', $tmp_a, $tmp_b);
         if ($err) {
             $this->newIssue('bin.diff.same')->setName(pht("Unexpected 'diff' Behavior"))->setMessage(pht("The 'diff' binary on this system has unexpected behavior: " . "it was expected to exit without an error code when passed " . "identical files, but exited with code %d.", $err));
         }
         list($err) = exec_manual('diff %s %s', $tmp_a, $tmp_c);
         if (!$err) {
             $this->newIssue('bin.diff.diff')->setName(pht("Unexpected 'diff' Behavior"))->setMessage(pht("The 'diff' binary on this system has unexpected behavior: " . "it was expected to exit with a nonzero error code when passed " . "differing files, but did not."));
         }
     }
     $table = new PhabricatorRepository();
     $vcses = queryfx_all($table->establishConnection('r'), 'SELECT DISTINCT versionControlSystem FROM %T', $table->getTableName());
     foreach ($vcses as $vcs) {
         switch ($vcs['versionControlSystem']) {
             case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
                 $binary = 'git';
                 break;
             case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
                 $binary = 'svn';
                 break;
             case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
                 $binary = 'hg';
                 break;
             default:
                 $binary = null;
                 break;
         }
         if (!$binary) {
             continue;
         }
         if (!Filesystem::binaryExists($binary)) {
             $message = pht('You have at least one repository configured which uses this ' . 'version control system. It will not work without the VCS binary.');
             $this->raiseWarning($binary, $message);
         }
     }
 }
开发者ID:denghp,项目名称:phabricator,代码行数:59,代码来源:PhabricatorSetupCheckBinaries.php

示例4: lookupPaths

 private static function lookupPaths(array $paths)
 {
     $repository = new PhabricatorRepository();
     $conn_w = $repository->establishConnection('w');
     $result_map = array();
     foreach (array_chunk($paths, 128) as $path_chunk) {
         $chunk_map = queryfx_all($conn_w, 'SELECT path, id FROM %T WHERE path IN (%Ls)', PhabricatorRepository::TABLE_PATH, $path_chunk);
         foreach ($chunk_map as $row) {
             $result_map[$row['path']] = $row['id'];
         }
     }
     return $result_map;
 }
开发者ID:netcomtec,项目名称:phabricator,代码行数:13,代码来源:PhabricatorRepositoryCommitChangeParserWorker.php

示例5: loadPathIDs

 public function loadPathIDs()
 {
     $repository = new PhabricatorRepository();
     $path_normal_map = array();
     foreach ($this->paths as $path) {
         $normal = self::normalizePath($path);
         $path_normal_map[$normal][] = $path;
     }
     $paths = queryfx_all($repository->establishConnection('r'), 'SELECT * FROM %T WHERE pathHash IN (%Ls)', PhabricatorRepository::TABLE_PATH, array_map('md5', array_keys($path_normal_map)));
     $paths = ipull($paths, 'id', 'path');
     $result = array();
     foreach ($path_normal_map as $normal => $originals) {
         foreach ($originals as $original) {
             $result[$original] = idx($paths, $normal);
         }
     }
     return $result;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:18,代码来源:DiffusionPathIDQuery.php

示例6: writeCommitChanges

 private function writeCommitChanges(PhabricatorRepository $repository, PhabricatorRepositoryCommit $commit, array $changes)
 {
     $repository_id = (int) $repository->getID();
     $commit_id = (int) $commit->getID();
     // NOTE: This SQL is being built manually instead of with qsprintf()
     // because some SVN changes affect an enormous number of paths (millions)
     // and this showed up as significantly slow on a profile at some point.
     $changes_sql = array();
     foreach ($changes as $change) {
         $values = array($repository_id, (int) $change->getPathID(), $commit_id, nonempty((int) $change->getTargetPathID(), 'null'), nonempty((int) $change->getTargetCommitID(), 'null'), (int) $change->getChangeType(), (int) $change->getFileType(), (int) $change->getIsDirect(), (int) $change->getCommitSequence());
         $changes_sql[] = '(' . implode(', ', $values) . ')';
     }
     $conn_w = $repository->establishConnection('w');
     queryfx($conn_w, 'DELETE FROM %T WHERE commitID = %d', PhabricatorRepository::TABLE_PATHCHANGE, $commit_id);
     foreach (PhabricatorLiskDAO::chunkSQL($changes_sql) as $chunk) {
         queryfx($conn_w, 'INSERT INTO %T
       (repositoryID, pathID, commitID, targetPathID, targetCommitID,
         changeType, fileType, isDirect, commitSequence)
       VALUES %Q', PhabricatorRepository::TABLE_PATHCHANGE, $chunk);
     }
 }
开发者ID:truSense,项目名称:phabricator,代码行数:21,代码来源:PhabricatorRepositoryCommitChangeParserWorker.php

示例7: isBadCommit

 protected function isBadCommit($full_commit_name)
 {
     $repository = new PhabricatorRepository();
     $bad_commit = queryfx_one($repository->establishConnection('w'), 'SELECT * FROM %T WHERE fullCommitName = %s', PhabricatorRepository::TABLE_BADCOMMIT, $full_commit_name);
     return (bool) $bad_commit;
 }
开发者ID:barcelonascience,项目名称:phabricator,代码行数:6,代码来源:PhabricatorRepositoryCommitParserWorker.php

示例8: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $shortcuts = id(new PhabricatorRepositoryShortcut())->loadAll();
     if ($shortcuts) {
         $shortcuts = msort($shortcuts, 'getSequence');
         $rows = array();
         foreach ($shortcuts as $shortcut) {
             $rows[] = array(phutil_render_tag('a', array('href' => $shortcut->getHref()), phutil_escape_html($shortcut->getName())), phutil_escape_html($shortcut->getDescription()));
         }
         $shortcut_table = new AphrontTableView($rows);
         $shortcut_table->setHeaders(array('Link', ''));
         $shortcut_table->setColumnClasses(array('pri', 'wide'));
         $shortcut_panel = new AphrontPanelView();
         $shortcut_panel->setHeader('Shortcuts');
         $shortcut_panel->appendChild($shortcut_table);
     } else {
         $shortcut_panel = null;
     }
     $repository = new PhabricatorRepository();
     $repositories = $repository->loadAll();
     foreach ($repositories as $key => $repo) {
         if (!$repo->isTracked()) {
             unset($repositories[$key]);
         }
     }
     $repository_ids = mpull($repositories, 'getID');
     $summaries = array();
     $commits = array();
     if ($repository_ids) {
         $summaries = queryfx_all($repository->establishConnection('r'), 'SELECT * FROM %T WHERE repositoryID IN (%Ld)', PhabricatorRepository::TABLE_SUMMARY, $repository_ids);
         $summaries = ipull($summaries, null, 'repositoryID');
         $commit_ids = array_filter(ipull($summaries, 'lastCommitID'));
         if ($commit_ids) {
             $commit = new PhabricatorRepositoryCommit();
             $commits = $commit->loadAllWhere('id IN (%Ld)', $commit_ids);
             $commits = mpull($commits, null, 'getRepositoryID');
         }
     }
     $rows = array();
     foreach ($repositories as $repository) {
         $id = $repository->getID();
         $commit = idx($commits, $id);
         $size = idx(idx($summaries, $id, array()), 'size', 0);
         $date = '-';
         $time = '-';
         if ($commit) {
             $date = phabricator_date($commit->getEpoch(), $user);
             $time = phabricator_time($commit->getEpoch(), $user);
         }
         $rows[] = array(phutil_render_tag('a', array('href' => '/diffusion/' . $repository->getCallsign() . '/'), phutil_escape_html($repository->getName())), phutil_escape_html($repository->getDetail('description')), PhabricatorRepositoryType::getNameForRepositoryType($repository->getVersionControlSystem()), $size ? number_format($size) : '-', $commit ? DiffusionView::linkCommit($repository, $commit->getCommitIdentifier()) : '-', $date, $time);
     }
     $repository_tool_uri = PhabricatorEnv::getProductionURI('/repository/');
     $repository_tool = phutil_render_tag('a', array('href' => $repository_tool_uri), 'repository tool');
     $no_repositories_txt = 'This instance of Phabricator does not have any ' . 'configured repositories. ';
     if ($user->getIsAdmin()) {
         $no_repositories_txt .= 'To setup one or more repositories, visit the ' . $repository_tool . '.';
     } else {
         $no_repositories_txt .= 'Ask an administrator to setup one or more ' . 'repositories via the ' . $repository_tool . '.';
     }
     $table = new AphrontTableView($rows);
     $table->setNoDataString($no_repositories_txt);
     $table->setHeaders(array('Repository', 'Description', 'VCS', 'Commits', 'Last', 'Date', 'Time'));
     $table->setColumnClasses(array('pri', 'wide', '', 'n', 'n', '', 'right'));
     $panel = new AphrontPanelView();
     $panel->setHeader('Browse Repositories');
     $panel->appendChild($table);
     $crumbs = $this->buildCrumbs();
     return $this->buildStandardPageResponse(array($crumbs, $shortcut_panel, $panel), array('title' => 'Diffusion'));
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:71,代码来源:DiffusionHomeController.php

示例9: executeChecks

 protected function executeChecks()
 {
     if (phutil_is_windows()) {
         $bin_name = 'where';
     } else {
         $bin_name = 'which';
     }
     if (!Filesystem::binaryExists($bin_name)) {
         $message = pht("Without '%s', Phabricator can not test for the availability " . "of other binaries.", $bin_name);
         $this->raiseWarning($bin_name, $message);
         // We need to return here if we can't find the 'which' / 'where' binary
         // because the other tests won't be valid.
         return;
     }
     if (!Filesystem::binaryExists('diff')) {
         $message = pht("Without '%s', Phabricator will not be able to generate or render " . "diffs in multiple applications.", 'diff');
         $this->raiseWarning('diff', $message);
     } else {
         $tmp_a = new TempFile();
         $tmp_b = new TempFile();
         $tmp_c = new TempFile();
         Filesystem::writeFile($tmp_a, 'A');
         Filesystem::writeFile($tmp_b, 'A');
         Filesystem::writeFile($tmp_c, 'B');
         list($err) = exec_manual('diff %s %s', $tmp_a, $tmp_b);
         if ($err) {
             $this->newIssue('bin.diff.same')->setName(pht("Unexpected '%s' Behavior", 'diff'))->setMessage(pht("The '%s' binary on this system has unexpected behavior: " . "it was expected to exit without an error code when passed " . "identical files, but exited with code %d.", 'diff', $err));
         }
         list($err) = exec_manual('diff %s %s', $tmp_a, $tmp_c);
         if (!$err) {
             $this->newIssue('bin.diff.diff')->setName(pht("Unexpected 'diff' Behavior"))->setMessage(pht("The '%s' binary on this system has unexpected behavior: " . "it was expected to exit with a nonzero error code when passed " . "differing files, but did not.", 'diff'));
         }
     }
     $table = new PhabricatorRepository();
     $vcses = queryfx_all($table->establishConnection('r'), 'SELECT DISTINCT versionControlSystem FROM %T', $table->getTableName());
     foreach ($vcses as $vcs) {
         switch ($vcs['versionControlSystem']) {
             case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
                 $binary = 'git';
                 break;
             case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
                 $binary = 'svn';
                 break;
             case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
                 $binary = 'hg';
                 break;
             default:
                 $binary = null;
                 break;
         }
         if (!$binary) {
             continue;
         }
         if (!Filesystem::binaryExists($binary)) {
             $message = pht('You have at least one repository configured which uses this ' . 'version control system. It will not work without the VCS binary.');
             $this->raiseWarning($binary, $message);
             continue;
         }
         $version = null;
         switch ($vcs['versionControlSystem']) {
             case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
                 $minimum_version = null;
                 $bad_versions = array();
                 list($err, $stdout, $stderr) = exec_manual('git --version');
                 $version = trim(substr($stdout, strlen('git version ')));
                 break;
             case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
                 $minimum_version = '1.5';
                 $bad_versions = array('1.7.1' => pht('This version of Subversion has a bug where `%s` does not work ' . 'for files added in rN (Subversion issue #2873), fixed in 1.7.2.', 'svn diff -c N'));
                 list($err, $stdout, $stderr) = exec_manual('svn --version --quiet');
                 $version = trim($stdout);
                 break;
             case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
                 $minimum_version = '1.9';
                 $bad_versions = array('2.1' => pht('This version of Mercurial returns a bad exit code ' . 'after a successful pull.'), '2.2' => pht('This version of Mercurial has a significant memory leak, fixed ' . 'in 2.2.1. Pushing fails with this version as well; see %s.', 'T3046#54922'));
                 $version = PhabricatorRepositoryVersion::getMercurialVersion();
                 break;
         }
         if ($version === null) {
             $this->raiseUnknownVersionWarning($binary);
         } else {
             if ($minimum_version && version_compare($version, $minimum_version, '<')) {
                 $this->raiseMinimumVersionWarning($binary, $minimum_version, $version);
             }
             foreach ($bad_versions as $bad_version => $details) {
                 if ($bad_version === $version) {
                     $this->raiseBadVersionWarning($binary, $bad_version);
                 }
             }
         }
     }
 }
开发者ID:pugong,项目名称:phabricator,代码行数:92,代码来源:PhabricatorBinariesSetupCheck.php

示例10: PhabricatorRepository

<?php

$table_w = new PhabricatorRepository();
$conn_w = $table_w->establishConnection('w');
// Repository and Project share a database.
$conn_r = $table_w->establishConnection('r');
$projects_table = 'repository_arcanistproject';
$raw_projects_data = queryfx_all($conn_r, 'SELECT * FROM %T', $projects_table);
$raw_projects_data = ipull($raw_projects_data, null, 'id');
$repository_ids = ipull($raw_projects_data, 'repositoryID');
if (!$repository_ids) {
    return;
}
$repositories = id(new PhabricatorRepositoryQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withIDs($repository_ids)->execute();
$projects_to_repo_ids_map = ipull($raw_projects_data, 'repositoryID', 'phid');
$projects_to_repos_map = array();
foreach ($projects_to_repo_ids_map as $projectPHID => $repositoryID) {
    $repo = idx($repositories, $repositoryID);
    if ($repo) {
        $projects_to_repos_map[$projectPHID] = $repo->getPHID();
    }
}
foreach ($raw_projects_data as $project_row) {
    $repositoryID = idx($project_row, 'repositoryID');
    $repo = idx($repositories, $repositoryID);
    if (!$repo) {
        continue;
    }
    echo pht("Migrating symbols configuration for '%s' project...\n", idx($project_row, 'name', '???'));
    $symbol_index_projects = $project_row['symbolIndexProjects'];
    $symbol_index_projects = nonempty($symbol_index_projects, '[]');
开发者ID:hrb518,项目名称:phabricator,代码行数:31,代码来源:20150504.symbolsproject.1.php

示例11: recordCommit

 private function recordCommit(PhabricatorRepository $repository, $commit_identifier, $epoch, $close_immediately, array $parents)
 {
     $commit = new PhabricatorRepositoryCommit();
     $commit->setRepositoryID($repository->getID());
     $commit->setCommitIdentifier($commit_identifier);
     $commit->setEpoch($epoch);
     if ($close_immediately) {
         $commit->setImportStatus(PhabricatorRepositoryCommit::IMPORTED_CLOSEABLE);
     }
     $data = new PhabricatorRepositoryCommitData();
     $conn_w = $repository->establishConnection('w');
     try {
         // If this commit has parents, look up their IDs. The parent commits
         // should always exist already.
         $parent_ids = array();
         if ($parents) {
             $parent_rows = queryfx_all($conn_w, 'SELECT id, commitIdentifier FROM %T
         WHERE commitIdentifier IN (%Ls) AND repositoryID = %d', $commit->getTableName(), $parents, $repository->getID());
             $parent_map = ipull($parent_rows, 'id', 'commitIdentifier');
             foreach ($parents as $parent) {
                 if (empty($parent_map[$parent])) {
                     throw new Exception(pht('Unable to identify parent "%s"!', $parent));
                 }
                 $parent_ids[] = $parent_map[$parent];
             }
         } else {
             // Write an explicit 0 so we can distinguish between "really no
             // parents" and "data not available".
             if (!$repository->isSVN()) {
                 $parent_ids = array(0);
             }
         }
         $commit->openTransaction();
         $commit->save();
         $data->setCommitID($commit->getID());
         $data->save();
         foreach ($parent_ids as $parent_id) {
             queryfx($conn_w, 'INSERT IGNORE INTO %T (childCommitID, parentCommitID)
           VALUES (%d, %d)', PhabricatorRepository::TABLE_PARENTS, $commit->getID(), $parent_id);
         }
         $commit->saveTransaction();
         $this->insertTask($repository, $commit);
         queryfx($conn_w, 'INSERT INTO %T (repositoryID, size, lastCommitID, epoch)
       VALUES (%d, 1, %d, %d)
       ON DUPLICATE KEY UPDATE
         size = size + 1,
         lastCommitID =
           IF(VALUES(epoch) > epoch, VALUES(lastCommitID), lastCommitID),
         epoch = IF(VALUES(epoch) > epoch, VALUES(epoch), epoch)', PhabricatorRepository::TABLE_SUMMARY, $repository->getID(), $commit->getID(), $epoch);
         if ($this->repairMode) {
             // Normally, the query should throw a duplicate key exception. If we
             // reach this in repair mode, we've actually performed a repair.
             $this->log(pht('Repaired commit "%s".', $commit_identifier));
         }
         PhutilEventEngine::dispatchEvent(new PhabricatorEvent(PhabricatorEventType::TYPE_DIFFUSION_DIDDISCOVERCOMMIT, array('repository' => $repository, 'commit' => $commit)));
     } catch (AphrontDuplicateKeyQueryException $ex) {
         $commit->killTransaction();
         // Ignore. This can happen because we discover the same new commit
         // more than once when looking at history, or because of races or
         // data inconsistency or cosmic radiation; in any case, we're still
         // in a good state if we ignore the failure.
     }
 }
开发者ID:denghp,项目名称:phabricator,代码行数:63,代码来源:PhabricatorRepositoryDiscoveryEngine.php

示例12: writeBrowse

 private function writeBrowse(PhabricatorRepository $repository, PhabricatorRepositoryCommit $commit, array $effects, array $path_map)
 {
     $conn_w = $repository->establishConnection('w');
     $sql = array();
     foreach ($effects as $effect) {
         $type = $effect['changeType'];
         if (!$effect['rawDirect']) {
             if ($type == DifferentialChangeType::TYPE_COPY_AWAY) {
                 // Don't write COPY_AWAY to the filesystem table if it isn't a direct
                 // event.
                 continue;
             }
             if ($type == DifferentialChangeType::TYPE_CHILD) {
                 // Don't write CHILD to the filesystem table. Although doing these
                 // writes has the nice property of letting you see when a directory's
                 // contents were last changed, it explodes the table tremendously
                 // and makes Diffusion far slower.
                 continue;
             }
         }
         if ($effect['rawPath'] == '/') {
             // Don't write any events on '/' to the filesystem table; in
             // particular, it doesn't have a meaningful parentID.
             continue;
         }
         $existed = !DifferentialChangeType::isDeleteChangeType($type);
         $sql[] = qsprintf($conn_w, '(%d, %d, %d, %d, %d, %d)', $repository->getID(), $path_map[$this->getParentPath($effect['rawPath'])], $commit->getCommitIdentifier(), $path_map[$effect['rawPath']], $existed ? 1 : 0, $effect['fileType']);
     }
     queryfx($conn_w, 'DELETE FROM %T WHERE repositoryID = %d AND svnCommit = %d', PhabricatorRepository::TABLE_FILESYSTEM, $repository->getID(), $commit->getCommitIdentifier());
     foreach (array_chunk($sql, 512) as $sql_chunk) {
         queryfx($conn_w, 'INSERT INTO %T
       (repositoryID, parentID, svnCommit, pathID, existed, fileType)
       VALUES %Q', PhabricatorRepository::TABLE_FILESYSTEM, implode(', ', $sql_chunk));
     }
 }
开发者ID:denghp,项目名称:phabricator,代码行数:35,代码来源:PhabricatorRepositorySvnCommitChangeParserWorker.php

示例13: loadPage

 protected function loadPage()
 {
     $table = new PhabricatorRepository();
     $conn_r = $table->establishConnection('r');
     $data = queryfx_all($conn_r, 'SELECT * FROM %T r %Q %Q %Q %Q', $table->getTableName(), $this->buildJoinsClause($conn_r), $this->buildWhereClause($conn_r), $this->buildOrderClause($conn_r), $this->buildLimitClause($conn_r));
     $repositories = $table->loadAllFromArray($data);
     if ($this->needCommitCounts) {
         $sizes = ipull($data, 'size', 'id');
         foreach ($repositories as $id => $repository) {
             $repository->attachCommitCount(nonempty($sizes[$id], 0));
         }
     }
     if ($this->needMostRecentCommits) {
         $commit_ids = ipull($data, 'lastCommitID', 'id');
         $commit_ids = array_filter($commit_ids);
         if ($commit_ids) {
             $commits = id(new DiffusionCommitQuery())->setViewer($this->getViewer())->withIDs($commit_ids)->execute();
         } else {
             $commits = array();
         }
         foreach ($repositories as $id => $repository) {
             $commit = null;
             if (idx($commit_ids, $id)) {
                 $commit = idx($commits, $commit_ids[$id]);
             }
             $repository->attachMostRecentCommit($commit);
         }
     }
     return $repositories;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:30,代码来源:PhabricatorRepositoryQuery.php

示例14: parseCommit


//.........这里部分代码省略.........
         // of running 'git check-attr' for stuff like 'binary', 'merge' or 'diff',
         // and by falling back to inspecting the first 8,000 characters of the
         // buffer for null bytes (this is seriously git's algorithm, see
         // buffer_is_binary() in xdiff-interface.c).
         $change_type = null;
         $change_path = $src_path;
         $change_target = null;
         $is_direct = true;
         switch ($action[0]) {
             case 'A':
                 $change_type = DifferentialChangeType::TYPE_ADD;
                 break;
             case 'D':
                 $change_type = DifferentialChangeType::TYPE_DELETE;
                 break;
             case 'C':
                 $change_type = DifferentialChangeType::TYPE_COPY_HERE;
                 $change_path = $dst_path;
                 $change_target = $src_path;
                 $copy_away[$change_target][] = $change_path;
                 break;
             case 'R':
                 $change_type = DifferentialChangeType::TYPE_MOVE_HERE;
                 $change_path = $dst_path;
                 $change_target = $src_path;
                 $move_away[$change_target][] = $change_path;
                 break;
             case 'T':
                 // Type of the file changed, fall through and treat it as a
                 // modification. Not 100% sure this is the right thing to do but it
                 // seems reasonable.
             // Type of the file changed, fall through and treat it as a
             // modification. Not 100% sure this is the right thing to do but it
             // seems reasonable.
             case 'M':
                 if ($file_type == DifferentialChangeType::FILE_DIRECTORY) {
                     $change_type = DifferentialChangeType::TYPE_CHILD;
                     $is_direct = false;
                 } else {
                     $change_type = DifferentialChangeType::TYPE_CHANGE;
                 }
                 break;
                 // NOTE: "U" (unmerged) and "X" (unknown) statuses are also possible
                 // in theory but shouldn't appear here.
             // NOTE: "U" (unmerged) and "X" (unknown) statuses are also possible
             // in theory but shouldn't appear here.
             default:
                 throw new Exception("Failed to parse line '{$line}'.");
         }
         $changes[$change_path] = array('repositoryID' => $repository->getID(), 'commitID' => $commit->getID(), 'path' => $change_path, 'changeType' => $change_type, 'fileType' => $file_type, 'isDirect' => $is_direct, 'commitSequence' => $commit->getEpoch(), 'targetPath' => $change_target, 'targetCommitID' => $change_target ? $commit->getID() : null);
     }
     // Add a change to '/' since git doesn't mention it.
     $changes['/'] = array('repositoryID' => $repository->getID(), 'commitID' => $commit->getID(), 'path' => '/', 'changeType' => DifferentialChangeType::TYPE_CHILD, 'fileType' => DifferentialChangeType::FILE_DIRECTORY, 'isDirect' => false, 'commitSequence' => $commit->getEpoch(), 'targetPath' => null, 'targetCommitID' => null);
     foreach ($copy_away as $change_path => $destinations) {
         if (isset($move_away[$change_path])) {
             $change_type = DifferentialChangeType::TYPE_MULTICOPY;
             $is_direct = true;
             unset($move_away[$change_path]);
         } else {
             $change_type = DifferentialChangeType::TYPE_COPY_AWAY;
             $is_direct = false;
         }
         $reference = $changes[reset($destinations)];
         $changes[$change_path] = array('repositoryID' => $repository->getID(), 'commitID' => $commit->getID(), 'path' => $change_path, 'changeType' => $change_type, 'fileType' => $reference['fileType'], 'isDirect' => $is_direct, 'commitSequence' => $commit->getEpoch(), 'targetPath' => null, 'targetCommitID' => null);
     }
     foreach ($move_away as $change_path => $destinations) {
         $reference = $changes[reset($destinations)];
         $changes[$change_path] = array('repositoryID' => $repository->getID(), 'commitID' => $commit->getID(), 'path' => $change_path, 'changeType' => DifferentialChangeType::TYPE_MOVE_AWAY, 'fileType' => $reference['fileType'], 'isDirect' => true, 'commitSequence' => $commit->getEpoch(), 'targetPath' => null, 'targetCommitID' => null);
     }
     $paths = array();
     foreach ($changes as $change) {
         $paths[$change['path']] = true;
         if ($change['targetPath']) {
             $paths[$change['targetPath']] = true;
         }
     }
     $path_map = $this->lookupOrCreatePaths(array_keys($paths));
     foreach ($changes as $key => $change) {
         $changes[$key]['pathID'] = $path_map[$change['path']];
         if ($change['targetPath']) {
             $changes[$key]['targetPathID'] = $path_map[$change['targetPath']];
         } else {
             $changes[$key]['targetPathID'] = null;
         }
     }
     $conn_w = $repository->establishConnection('w');
     $changes_sql = 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));
     }
     $this->finishParse();
 }
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:101,代码来源:PhabricatorRepositoryGitCommitChangeParserWorker.php

示例15: PhabricatorRepository

<?php

$table = new PhabricatorRepository();
$conn_w = $table->establishConnection('w');
$default_path = PhabricatorEnv::getEnvConfig('repository.default-local-path');
$default_path = rtrim($default_path, '/');
foreach (new LiskMigrationIterator($table) as $repository) {
    $local_path = $repository->getLocalPath();
    if (strlen($local_path)) {
        // Repository already has a modern, unique local path.
        continue;
    }
    $local_path = $repository->getDetail('local-path');
    if (!strlen($local_path)) {
        // Repository does not have a local path using the older format.
        continue;
    }
    $random = Filesystem::readRandomCharacters(8);
    // Try the configured path first, then a default path, then a path with some
    // random noise.
    $paths = array($local_path, $default_path . '/' . $repository->getID() . '/', $default_path . '/' . $repository->getID() . '-' . $random . '/');
    foreach ($paths as $path) {
        // Set, then get the path to normalize it.
        $repository->setLocalPath($path);
        $path = $repository->getLocalPath();
        try {
            queryfx($conn_w, 'UPDATE %T SET localPath = %s WHERE id = %d', $table->getTableName(), $path, $repository->getID());
            echo tsprintf("%s\n", pht('Assigned repository "%s" to local path "%s".', $repository->getDisplayName(), $path));
            break;
        } catch (AphrontDuplicateKeyQueryException $ex) {
            // Ignore, try the next one.
开发者ID:rchicoli,项目名称:phabricator,代码行数:31,代码来源:20160503.repo.03.lpathmigrate.php


注:本文中的PhabricatorRepository::establishConnection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。