1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-22 05:20:56 +01:00

- Added getRemoteCommandFuture(..) and getLocalCommand Future(..) methods to PhabricatorRepository

- Removed irrelevant csprintf(..)
  - Updated code to use $repository->getRemoteURI()
  - Updated code to use getRemoteCommandFuture(..) in Diffusion code
  - Updated code to use $repository->getRemoteURI()
This commit is contained in:
Abdul Qabiz 2011-09-09 01:16:48 +05:30
parent e3a9d73fe1
commit 6355b291ed
9 changed files with 32 additions and 22 deletions

View file

@ -140,9 +140,9 @@ final class DiffusionSvnDiffQuery extends DiffusionDiffQuery {
$repository = $drequest->getRepository(); $repository = $drequest->getRepository();
list($ref, $rev) = $spec; list($ref, $rev) = $spec;
return new ExecFuture( return $repository->getRemoteCommandFuture(
'svn --non-interactive cat %s%s@%d', 'cat %s%s@%d',
$repository->getDetail('remote-uri'), $repository->getRemoteURI(),
$ref, $ref,
$rev); $rev);
} }

View file

@ -16,7 +16,6 @@ phutil_require_module('phabricator', 'applications/diffusion/query/pathchange/ba
phutil_require_module('phabricator', 'infrastructure/diff/engine'); phutil_require_module('phabricator', 'infrastructure/diff/engine');
phutil_require_module('phutil', 'future'); phutil_require_module('phutil', 'future');
phutil_require_module('phutil', 'future/exec');
phutil_require_module('phutil', 'utils'); phutil_require_module('phutil', 'utils');

View file

@ -33,11 +33,11 @@ final class DiffusionSvnFileContentQuery extends DiffusionFileContentQuery {
$path = $drequest->getPath(); $path = $drequest->getPath();
$commit = $drequest->getCommit(); $commit = $drequest->getCommit();
$remote_uri = $repository->getDetail('remote-uri'); $remote_uri = $repository->getRemoteURI();
try { try {
list($corpus) = execx( list($corpus) = $repository->execxRemoteCommand(
'svn --non-interactive %s %s%s@%s', '%s %s%s@%s',
$this->getNeedsBlame() ? 'blame' : 'cat', $this->getNeedsBlame() ? 'blame' : 'cat',
$remote_uri, $remote_uri,
$path, $path,

View file

@ -9,7 +9,6 @@
phutil_require_module('phabricator', 'applications/diffusion/data/filecontent'); phutil_require_module('phabricator', 'applications/diffusion/data/filecontent');
phutil_require_module('phabricator', 'applications/diffusion/query/filecontent/base'); phutil_require_module('phabricator', 'applications/diffusion/query/filecontent/base');
phutil_require_module('phutil', 'future/exec');
phutil_require_module('phutil', 'utils'); phutil_require_module('phutil', 'utils');

View file

@ -28,9 +28,9 @@ class PhabricatorRepositorySvnCommitDiscoveryDaemon
} }
$uri = $this->getBaseSVNLogURI(); $uri = $this->getBaseSVNLogURI();
list($xml) = execx( list($xml) = $repository->execxRemoteCommand(
'svn log --xml --non-interactive --quiet --limit 1 %s@HEAD', ' log --xml --quiet --limit 1 %s@HEAD',
$uri); $uri);
$results = $this->parseSVNLogXML($xml); $results = $this->parseSVNLogXML($xml);
$commit = key($results); $commit = key($results);
@ -47,6 +47,7 @@ class PhabricatorRepositorySvnCommitDiscoveryDaemon
private function discoverCommit($commit, $epoch) { private function discoverCommit($commit, $epoch) {
$uri = $this->getBaseSVNLogURI(); $uri = $this->getBaseSVNLogURI();
$repository = $this->getRepository();
$discover = array( $discover = array(
$commit => $epoch, $commit => $epoch,
@ -58,8 +59,8 @@ class PhabricatorRepositorySvnCommitDiscoveryDaemon
// Find all the unknown commits on this path. Note that we permit // Find all the unknown commits on this path. Note that we permit
// importing an SVN subdirectory rather than the entire repository, so // importing an SVN subdirectory rather than the entire repository, so
// commits may be nonsequential. // commits may be nonsequential.
list($err, $xml, $stderr) = exec_manual( list($err, $xml, $stderr) = $repository->execRemoteCommand(
'svn log --xml --non-interactive --quiet --limit %d %s@%d', ' log --xml --quiet --limit %d %s@%d',
$limit, $limit,
$uri, $uri,
$upper_bound - 1); $upper_bound - 1);

View file

@ -9,7 +9,6 @@
phutil_require_module('phabricator', 'applications/repository/constants/repositorytype'); phutil_require_module('phabricator', 'applications/repository/constants/repositorytype');
phutil_require_module('phabricator', 'applications/repository/daemon/commitdiscovery/base'); phutil_require_module('phabricator', 'applications/repository/daemon/commitdiscovery/base');
phutil_require_module('phutil', 'future/exec');
phutil_require_module('phutil', 'utils'); phutil_require_module('phutil', 'utils');

View file

@ -97,6 +97,12 @@ class PhabricatorRepository extends PhabricatorRepositoryDAO {
return call_user_func_array('execx', $args); return call_user_func_array('execx', $args);
} }
public function getRemoteCommandFuture($pattern /*, $arg, ... */) {
$args = func_get_args();
$args = $this->formatRemoteCommand($args);
return newv('ExecFuture', $args);
}
public function passthruRemoteCommand($pattern /*, $arg, ... */) { public function passthruRemoteCommand($pattern /*, $arg, ... */) {
$args = func_get_args(); $args = func_get_args();
$args = $this->formatRemoteCommand($args); $args = $this->formatRemoteCommand($args);
@ -115,12 +121,19 @@ class PhabricatorRepository extends PhabricatorRepositoryDAO {
return call_user_func_array('execx', $args); return call_user_func_array('execx', $args);
} }
public function getLocalCommandFuture($pattern /*, $arg, ... */) {
$args = func_get_args();
$args = $this->formatLocalCommand($args);
return newv('ExecFuture', $args);
}
public function passthruLocalCommand($pattern /*, $arg, ... */) { public function passthruLocalCommand($pattern /*, $arg, ... */) {
$args = func_get_args(); $args = func_get_args();
$args = $this->formatLocalCommand($args); $args = $this->formatLocalCommand($args);
return call_user_func_array('phutil_passthru', $args); return call_user_func_array('phutil_passthru', $args);
} }
private function formatRemoteCommand(array $args) { private function formatRemoteCommand(array $args) {
$pattern = $args[0]; $pattern = $args[0];
$args = array_slice($args, 1); $args = array_slice($args, 1);

View file

@ -68,8 +68,8 @@ abstract class PhabricatorRepositoryCommitParserWorker
} }
try { try {
list($xml) = execx( list($xml) = $this->repository->execxRemoteCommand(
"svn log --xml {$verbose} --limit 1 --non-interactive %s@%d", "log --xml {$verbose} --limit 1 %s@%d",
$uri, $uri,
$revision); $revision);
} catch (CommandException $ex) { } catch (CommandException $ex) {

View file

@ -593,10 +593,9 @@ class PhabricatorRepositorySvnCommitChangeParserWorker
// position in the document. // position in the document.
$all_paths = array_reverse(array_keys($parents)); $all_paths = array_reverse(array_keys($parents));
foreach (array_chunk($all_paths, 64) as $path_chunk) { foreach (array_chunk($all_paths, 64) as $path_chunk) {
list($raw_xml) = execx( list($raw_xml) = $repository->execxRemoteCommand(
'svn --non-interactive --xml ls %C', '--xml ls %C',
implode(' ', $path_chunk)); implode(' ', $path_chunk));
$xml = new SimpleXMLElement($raw_xml); $xml = new SimpleXMLElement($raw_xml);
foreach ($xml->list as $list) { foreach ($xml->list as $list) {
$list_path = (string)$list['path']; $list_path = (string)$list['path'];
@ -669,8 +668,8 @@ class PhabricatorRepositorySvnCommitChangeParserWorker
$cache_loc = sys_get_temp_dir().'/diffusion.'.$hashkey.'.svnls'; $cache_loc = sys_get_temp_dir().'/diffusion.'.$hashkey.'.svnls';
if (!Filesystem::pathExists($cache_loc)) { if (!Filesystem::pathExists($cache_loc)) {
$tmp = new TempFile(); $tmp = new TempFile();
execx( $repository->execxRemoteCommand(
'svn --non-interactive --xml ls -R %s%s@%d > %s', '--xml ls -R %s%s@%d > %s',
$repository->getDetail('remote-uri'), $repository->getDetail('remote-uri'),
$path, $path,
$rev, $rev,