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


PHP PhabricatorRepository类代码示例

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


在下文中一共展示了PhabricatorRepository类的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: getRawDiff

 private function getRawDiff(PhabricatorRepository $repository, $commit, $use_log, $try_harder)
 {
     $flags = array('-n1', '-M', '-C', '-B', '--raw', '-t', '--abbrev=40');
     if ($try_harder) {
         $flags[] = '--find-copies-harder';
     }
     if ($use_log) {
         // This is the first commit so we need to use "log". We know it's not a
         // merge commit because it couldn't be merging anything, so this is safe.
         // NOTE: "--pretty=format: " is to disable diff output, we only want the
         // part we get from "--raw".
         $future = $repository->getLocalCommandFuture('log %Ls --pretty=format: %s', $flags, $commit);
     } else {
         // Otherwise, we can use "diff", which will give us output for merges.
         // We diff against the first parent, as this is generally the expectation
         // and results in sensible behavior.
         $future = $repository->getLocalCommandFuture('diff %Ls %s^1 %s', $flags, $commit, $commit);
     }
     // Don't spend more than 30 seconds generating the slower output.
     if ($try_harder) {
         $future->setTimeout(30);
     }
     list($raw) = $future->resolvex();
     return $raw;
 }
开发者ID:endlessm,项目名称:phabricator,代码行数:25,代码来源:DiffusionInternalGitRawDiffQueryConduitAPIMethod.php

示例3: executeUpdate

 protected function executeUpdate(PhabricatorRepository $repository, $local_path)
 {
     // This is a local command, but needs credentials.
     $future = $repository->getRemoteCommandFuture('pull -u');
     $future->setCWD($local_path);
     try {
         $future->resolvex();
     } catch (CommandException $ex) {
         $err = $ex->getError();
         $stdout = $ex->getStdOut();
         // NOTE: Between versions 2.1 and 2.1.1, Mercurial changed the behavior
         // of "hg pull" to return 1 in case of a successful pull with no changes.
         // This behavior has been reverted, but users who updated between Feb 1,
         // 2012 and Mar 1, 2012 will have the erroring version. Do a dumb test
         // against stdout to check for this possibility.
         // See: https://github.com/facebook/phabricator/issues/101/
         // NOTE: Mercurial has translated versions, which translate this error
         // string. In a translated version, the string will be something else,
         // like "aucun changement trouve". There didn't seem to be an easy way
         // to handle this (there are hard ways but this is not a common problem
         // and only creates log spam, not application failures). Assume English.
         // TODO: Remove this once we're far enough in the future that deployment
         // of 2.1 is exceedingly rare?
         if ($err == 1 && preg_match('/no changes found/', $stdout)) {
             return;
         } else {
             throw $ex;
         }
     }
 }
开发者ID:ramons03,项目名称:phabricator,代码行数:30,代码来源:PhabricatorRepositoryMercurialPullDaemon.php

示例4: executeUpdate

 protected function executeUpdate(PhabricatorRepository $repository, $local_path)
 {
     // Run a bunch of sanity checks to detect people checking out repositories
     // inside other repositories, making empty directories, pointing the local
     // path at some random file or path, etc.
     list($err, $stdout) = $repository->execLocalCommand('rev-parse --show-toplevel');
     if ($err) {
         // Try to raise a more tailored error message in the more common case
         // of the user creating an empty directory. (We could try to remove it,
         // but might not be able to, and it's much simpler to raise a good
         // message than try to navigate those waters.)
         if (is_dir($local_path)) {
             $files = Filesystem::listDirectory($local_path, $include_hidden = true);
             if (!$files) {
                 throw new Exception("Expected to find a git repository at '{$local_path}', but there " . "is an empty directory there. Remove the directory: the daemon " . "will run 'git clone' for you.");
             }
         }
         throw new Exception("Expected to find a git repository at '{$local_path}', but there is " . "a non-repository directory (with other stuff in it) there. Move or " . "remove this directory (or reconfigure the repository to use a " . "different directory), and then either clone a repository yourself " . "or let the daemon do it.");
     } else {
         $repo_path = rtrim($stdout, "\n");
         if (empty($repo_path)) {
             throw new Exception("Expected to find a git repository at '{$local_path}', but " . "there was no result from `git rev-parse --show-toplevel`. " . "Something is misconfigured or broken. The git repository " . "may be inside a '.git/' directory.");
         }
         if (!Filesystem::pathsAreEquivalent($repo_path, $local_path)) {
             throw new Exception("Expected to find repo at '{$local_path}', but the actual " . "git repository root for this directory is '{$repo_path}'. " . "Something is misconfigured. The repository's 'Local Path' should " . "be set to some place where the daemon can check out a working " . "copy, and should not be inside another git repository.");
         }
     }
     // This is a local command, but needs credentials.
     $future = $repository->getRemoteCommandFuture('fetch --all --prune');
     $future->setCWD($local_path);
     $future->resolvex();
 }
开发者ID:ramons03,项目名称:phabricator,代码行数:32,代码来源:PhabricatorRepositoryGitFetchDaemon.php

示例5: loadPackagesForPaths

 private static function loadPackagesForPaths(PhabricatorRepository $repository, array $paths, $limit = 0)
 {
     $package = new PhabricatorOwnersPackage();
     $path = new PhabricatorOwnersPath();
     $conn = $package->establishConnection('r');
     $repository_clause = qsprintf($conn, 'AND p.repositoryPHID = %s', $repository->getPHID());
     $limit_clause = '';
     if (!empty($limit)) {
         $limit_clause = qsprintf($conn, 'LIMIT %d', $limit);
     }
     $data = queryfx_all($conn, 'SELECT pkg.id FROM %T pkg JOIN %T p ON p.packageID = pkg.id
     WHERE p.path IN (%Ls) %Q ORDER BY LENGTH(p.path) DESC %Q', $package->getTableName(), $path->getTableName(), $paths, $repository_clause, $limit_clause);
     $ids = ipull($data, 'id');
     if (empty($ids)) {
         return array();
     }
     $order = array();
     foreach ($ids as $id) {
         if (empty($order[$id])) {
             $order[$id] = true;
         }
     }
     $packages = $package->loadAllWhere('id in (%Ld)', array_keys($order));
     $packages = array_select_keys($packages, array_keys($order));
     return $packages;
 }
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:26,代码来源:PhabricatorOwnersPackage.php

示例6: getCommitHashes

 protected function getCommitHashes(PhabricatorRepository $repository, PhabricatorRepositoryCommit $commit)
 {
     list($stdout) = $repository->execxLocalCommand('log -n 1 --format=%s %s --', '%T', $commit->getCommitIdentifier());
     $commit_hash = $commit->getCommitIdentifier();
     $tree_hash = trim($stdout);
     return array(array(ArcanistDifferentialRevisionHash::HASH_GIT_COMMIT, $commit_hash), array(ArcanistDifferentialRevisionHash::HASH_GIT_TREE, $tree_hash));
 }
开发者ID:neoxen,项目名称:phabricator,代码行数:7,代码来源:PhabricatorRepositoryGitCommitMessageParserWorker.php

示例7: updateBranchStates

 private function updateBranchStates(PhabricatorRepository $repository, array $branches)
 {
     assert_instances_of($branches, 'DiffusionRepositoryRef');
     $all_cursors = id(new PhabricatorRepositoryRefCursorQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withRepositoryPHIDs(array($repository->getPHID()))->execute();
     $state_map = array();
     $type_branch = PhabricatorRepositoryRefCursor::TYPE_BRANCH;
     foreach ($all_cursors as $cursor) {
         if ($cursor->getRefType() !== $type_branch) {
             continue;
         }
         $raw_name = $cursor->getRefNameRaw();
         $hash = $cursor->getCommitIdentifier();
         $state_map[$raw_name][$hash] = $cursor;
     }
     foreach ($branches as $branch) {
         $cursor = idx($state_map, $branch->getShortName(), array());
         $cursor = idx($cursor, $branch->getCommitIdentifier());
         if (!$cursor) {
             continue;
         }
         $fields = $branch->getRawFields();
         $cursor_state = (bool) $cursor->getIsClosed();
         $branch_state = (bool) idx($fields, 'closed');
         if ($cursor_state != $branch_state) {
             $cursor->setIsClosed((int) $branch_state)->save();
         }
     }
 }
开发者ID:vinzent,项目名称:phabricator,代码行数:28,代码来源:PhabricatorRepositoryRefEngine.php

示例8: 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

示例9: markReachable

 private function markReachable(PhabricatorRepository $repository)
 {
     if (!$repository->isGit()) {
         throw new PhutilArgumentUsageException(pht('Only Git repositories are supported, this repository ("%s") is ' . 'not a Git repository.', $repository->getDisplayName()));
     }
     $viewer = $this->getViewer();
     $commits = id(new DiffusionCommitQuery())->setViewer($viewer)->withRepository($repository)->execute();
     $flag = PhabricatorRepositoryCommit::IMPORTED_UNREACHABLE;
     $graph = new PhabricatorGitGraphStream($repository);
     foreach ($commits as $commit) {
         $identifier = $commit->getCommitIdentifier();
         try {
             $graph->getCommitDate($identifier);
             $unreachable = false;
         } catch (Exception $ex) {
             $unreachable = true;
         }
         // The commit has proper reachability, so do nothing.
         if ($commit->isUnreachable() === $unreachable) {
             $this->untouchedCount++;
             continue;
         }
         if ($unreachable) {
             echo tsprintf("%s: %s\n", $commit->getMonogram(), pht('Marking commit unreachable.'));
             $commit->writeImportStatusFlag($flag);
         } else {
             echo tsprintf("%s: %s\n", $commit->getMonogram(), pht('Marking commit reachable.'));
             $commit->clearImportStatusFlag($flag);
         }
     }
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:31,代码来源:PhabricatorRepositoryManagementMarkReachableWorkflow.php

示例10: executeUpdate

 protected function executeUpdate(PhabricatorRepository $repository, $local_path)
 {
     // This is a local command, but needs credentials.
     $future = $repository->getRemoteCommandFuture('fetch --all');
     $future->setCWD($local_path);
     $future->resolvex();
 }
开发者ID:netcomtec,项目名称:phabricator,代码行数:7,代码来源:PhabricatorRepositoryGitFetchDaemon.php

示例11: 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

示例12: __construct

 public function __construct(PhabricatorRepository $repository, $commit)
 {
     $this->repository = $repository;
     $future = $repository->getLocalCommandFuture('log --template %s --rev %s', '{rev}\\1{node}\\1{date}\\1{parents}\\2', hgsprintf('reverse(ancestors(%s))', $commit));
     $this->iterator = new LinesOfALargeExecFuture($future);
     $this->iterator->setDelimiter("");
     $this->iterator->rewind();
 }
开发者ID:denghp,项目名称:phabricator,代码行数:8,代码来源:PhabricatorMercurialGraphStream.php

示例13: linkCommit

 public static final function linkCommit(PhabricatorRepository $repository, $commit, $summary = '')
 {
     $commit_name = $repository->formatCommitName($commit, $local = true);
     if (strlen($summary)) {
         $commit_name .= ': ' . $summary;
     }
     return phutil_tag('a', array('href' => $repository->getCommitURI($commit)), $commit_name);
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:8,代码来源:DiffusionView.php

示例14: __construct

 public function __construct(PhabricatorRepository $repository)
 {
     $this->repository = $repository;
     $future = $repository->getLocalCommandFuture("log --template '{rev}{node}{date}{parents}'");
     $this->iterator = new LinesOfALargeExecFuture($future);
     $this->iterator->setDelimiter("");
     $this->iterator->rewind();
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:8,代码来源:PhabricatorMercurialGraphStream.php

示例15: getDefaultRefName

 private function getDefaultRefName(PhabricatorRepository $repository, DifferentialDiff $diff)
 {
     $onto = $diff->loadTargetBranch();
     if ($onto !== null) {
         return $onto;
     }
     return $repository->getDefaultBranch();
 }
开发者ID:pugong,项目名称:phabricator,代码行数:8,代码来源:DifferentialRevisionOperationController.php


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