mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 21:02:41 +01:00
execx ==> execxLocalCommand for git libraries in diffusion
Summary: this was fairly mechanical at the end of the day note that future/exec got removed by the code generation robots post this change Test Plan: clicked around diffusion a bunch looking for errors. For a given repo (say http://phabricator.dev/diffusion/BOBALIE/) - http://phabricator.dev/diffusion/BOBALIE/history/ - http://phabricator.dev/diffusion/BOBALIE/history/origin:master/.arcconfig - http://phabricator.dev/diffusion/BOBALIE/browse/origin:master/ - http://phabricator.dev/diffusion/BOBALIE/browse/origin:master/.arcconfig - http://phabricator.dev/rBOBALIEbfede2e8ea9435644968e2e76c0bac8949fb7d06 For a given file (say http://phabricator.dev/diffusion/BOBALIE/change/origin:master/.arcconfig;bfede2e8ea9435644968e2e76c0bac8949fb7d06) - history view* - browse view - change view * found a bug where the history view doesn't have the change view in the left hand UI will fix laters Reviewers: epriestley Reviewed By: epriestley CC: aran, epriestley Differential Revision: 1095
This commit is contained in:
parent
1494476d30
commit
5c21b5345d
14 changed files with 30 additions and 60 deletions
|
@ -24,9 +24,8 @@ final class DiffusionGitBranchQuery extends DiffusionBranchQuery {
|
|||
|
||||
$local_path = $repository->getDetail('local-path');
|
||||
|
||||
list($stdout) = execx(
|
||||
'(cd %s && git branch -r --verbose --no-abbrev)',
|
||||
$local_path);
|
||||
list($stdout) = $repository->execxLocalCommand(
|
||||
'branch -r --verbose --no-abbrev');
|
||||
|
||||
$branches = array();
|
||||
foreach (self::parseGitRemoteBranchOutput($stdout) as $name => $head) {
|
||||
|
|
|
@ -9,7 +9,5 @@
|
|||
phutil_require_module('phabricator', 'applications/diffusion/data/branch');
|
||||
phutil_require_module('phabricator', 'applications/diffusion/query/branch/base');
|
||||
|
||||
phutil_require_module('phutil', 'future/exec');
|
||||
|
||||
|
||||
phutil_require_source('DiffusionGitBranchQuery.php');
|
||||
|
|
|
@ -25,26 +25,22 @@ final class DiffusionGitBrowseQuery extends DiffusionBrowseQuery {
|
|||
$path = $drequest->getPath();
|
||||
$commit = $drequest->getCommit();
|
||||
|
||||
$local_path = $repository->getDetail('local-path');
|
||||
|
||||
if ($path == '') {
|
||||
// Fast path to improve the performance of the repository view; we know
|
||||
// the root is always a tree at any commit and always exists.
|
||||
$stdout = 'tree';
|
||||
} else {
|
||||
try {
|
||||
list($stdout) = execx(
|
||||
"(cd %s && git cat-file -t %s:%s)",
|
||||
$local_path,
|
||||
list($stdout) = $repository->execxLocalCommand(
|
||||
'cat-file -t %s:%s',
|
||||
$commit,
|
||||
$path);
|
||||
} catch (CommandException $e) {
|
||||
$stderr = $e->getStdErr();
|
||||
if (preg_match('/^fatal: Not a valid object name/', $stderr)) {
|
||||
// Grab two logs, since the first one is when the object was deleted.
|
||||
list($stdout) = execx(
|
||||
'(cd %s && git log -n2 --format="%%H" %s -- %s)',
|
||||
$local_path,
|
||||
list($stdout) = $repository->execxLocalCommand(
|
||||
'log -n2 --format="%%H" %s -- %s',
|
||||
$commit,
|
||||
$path);
|
||||
$stdout = trim($stdout);
|
||||
|
@ -73,9 +69,8 @@ final class DiffusionGitBrowseQuery extends DiffusionBrowseQuery {
|
|||
return true;
|
||||
}
|
||||
|
||||
list($stdout) = execx(
|
||||
"(cd %s && git ls-tree -l %s:%s)",
|
||||
$local_path,
|
||||
list($stdout) = $repository->execxLocalCommand(
|
||||
'ls-tree -l %s:%s',
|
||||
$commit,
|
||||
$path);
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ phutil_require_module('phabricator', 'applications/differential/constants/change
|
|||
phutil_require_module('phabricator', 'applications/diffusion/data/repositorypath');
|
||||
phutil_require_module('phabricator', 'applications/diffusion/query/browse/base');
|
||||
|
||||
phutil_require_module('phutil', 'future/exec');
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
|
|
|
@ -45,27 +45,24 @@ final class DiffusionGitDiffQuery extends DiffusionDiffQuery {
|
|||
$options = implode(' ', $options);
|
||||
|
||||
try {
|
||||
list($raw_diff) = execx(
|
||||
"(cd %s && git diff %C %s^ %s -- %s)",
|
||||
$repository->getDetail('local-path'),
|
||||
list($raw_diff) = $repository->execxLocalCommand(
|
||||
'diff %C %s^ %s -- %s',
|
||||
$options,
|
||||
$effective_commit,
|
||||
$effective_commit,
|
||||
$drequest->getPath());
|
||||
} catch (CommandException $ex) {
|
||||
// Check if this is the root commit by seeing if it has parents.
|
||||
list($parents) = execx(
|
||||
'(cd %s && git log --format=%s %s --)',
|
||||
$repository->getDetail('local-path'),
|
||||
list($parents) = $repository->execxLocalCommand(
|
||||
'log --format=%s %s --',
|
||||
'%P', // "parents"
|
||||
$effective_commit);
|
||||
if (!strlen(trim($parents))) {
|
||||
// No parents means we're looking at the root revision. Diff against
|
||||
// the empty tree hash instead, since there is no parent so "^" does
|
||||
// not work. See ArcanistGitAPI for more discussion.
|
||||
list($raw_diff) = execx(
|
||||
'(cd %s && git diff %C %s %s -- %s)',
|
||||
$repository->getDetail('local-path'),
|
||||
list($raw_diff) = $repository->execxLocalCommand(
|
||||
'diff %C %s %s -- %s',
|
||||
$options,
|
||||
ArcanistGitAPI::GIT_MAGIC_ROOT_COMMIT,
|
||||
$effective_commit,
|
||||
|
|
|
@ -12,7 +12,5 @@ phutil_require_module('arcanist', 'repository/api/git');
|
|||
phutil_require_module('phabricator', 'applications/differential/storage/diff');
|
||||
phutil_require_module('phabricator', 'applications/diffusion/query/diff/base');
|
||||
|
||||
phutil_require_module('phutil', 'future/exec');
|
||||
|
||||
|
||||
phutil_require_source('DiffusionGitDiffQuery.php');
|
||||
|
|
|
@ -25,17 +25,14 @@ final class DiffusionGitFileContentQuery extends DiffusionFileContentQuery {
|
|||
$path = $drequest->getPath();
|
||||
$commit = $drequest->getCommit();
|
||||
|
||||
$local_path = $repository->getDetail('local-path');
|
||||
if ($this->getNeedsBlame()) {
|
||||
list($corpus) = execx(
|
||||
'(cd %s && git --no-pager blame -c -l --date=short %s -- %s)',
|
||||
$local_path,
|
||||
list($corpus) = $repository->execxLocalCommand(
|
||||
'--no-pager blame -c -l --date=short %s -- %s',
|
||||
$commit,
|
||||
$path);
|
||||
} else {
|
||||
list($corpus) = execx(
|
||||
'(cd %s && git cat-file blob %s:%s)',
|
||||
$local_path,
|
||||
list($corpus) = $repository->execxLocalCommand(
|
||||
'cat-file blob %s:%s',
|
||||
$commit,
|
||||
$path);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
phutil_require_module('phabricator', 'applications/diffusion/data/filecontent');
|
||||
phutil_require_module('phabricator', 'applications/diffusion/query/filecontent/base');
|
||||
|
||||
phutil_require_module('phutil', 'future/exec');
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
|
|
|
@ -25,16 +25,13 @@ final class DiffusionGitHistoryQuery extends DiffusionHistoryQuery {
|
|||
$path = $drequest->getPath();
|
||||
$commit_hash = $drequest->getCommit();
|
||||
|
||||
$local_path = $repository->getDetail('local-path');
|
||||
|
||||
list($stdout) = execx(
|
||||
'(cd %s && git log '.
|
||||
list($stdout) = $repository->execxLocalCommand(
|
||||
'log '.
|
||||
'--skip=%d '.
|
||||
'-n %d '.
|
||||
'--abbrev=40 '.
|
||||
'--pretty=format:%%H '.
|
||||
'%s -- %s)',
|
||||
$local_path,
|
||||
'%s -- %s',
|
||||
$this->getOffset(),
|
||||
$this->getLimit(),
|
||||
$commit_hash,
|
||||
|
|
|
@ -8,7 +8,5 @@
|
|||
|
||||
phutil_require_module('phabricator', 'applications/diffusion/query/history/base');
|
||||
|
||||
phutil_require_module('phutil', 'future/exec');
|
||||
|
||||
|
||||
phutil_require_source('DiffusionGitHistoryQuery.php');
|
||||
|
|
|
@ -22,9 +22,8 @@ final class DiffusionGitLastModifiedQuery extends DiffusionLastModifiedQuery {
|
|||
$drequest = $this->getRequest();
|
||||
$repository = $drequest->getRepository();
|
||||
|
||||
list($hash) = execx(
|
||||
"(cd %s && git log -n1 --format=%%H %s -- %s)",
|
||||
$repository->getDetail('local-path'),
|
||||
list($hash) = $repository->execxLocalCommand(
|
||||
'log -n1 --format=%%H %s -- %s',
|
||||
$drequest->getCommit(),
|
||||
$drequest->getPath());
|
||||
$hash = trim($hash);
|
||||
|
|
|
@ -10,7 +10,6 @@ phutil_require_module('phabricator', 'applications/diffusion/query/lastmodified/
|
|||
phutil_require_module('phabricator', 'applications/repository/storage/commit');
|
||||
phutil_require_module('phabricator', 'applications/repository/storage/commitdata');
|
||||
|
||||
phutil_require_module('phutil', 'future/exec');
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ class DiffusionGitRequest extends DiffusionRequest {
|
|||
$this->path = implode('/', $parts);
|
||||
|
||||
if ($this->repository) {
|
||||
$local_path = $this->repository->getDetail('local-path');
|
||||
$repository = $this->repository;
|
||||
|
||||
// TODO: This is not terribly efficient and does not produce terribly
|
||||
// good error messages, but it seems better to put error handling code
|
||||
|
@ -52,15 +52,13 @@ class DiffusionGitRequest extends DiffusionRequest {
|
|||
// message to indicate whether they've typed in some bogus branch and/or
|
||||
// followed a bad link, or misconfigured the default branch in the
|
||||
// Repository tool.
|
||||
list($this->stableCommitName) = execx(
|
||||
'(cd %s && git rev-parse --verify %s)',
|
||||
$local_path,
|
||||
list($this->stableCommitName) = $repository->execxLocalCommand(
|
||||
'rev-parse --verify %s',
|
||||
$branch);
|
||||
|
||||
if ($this->commit) {
|
||||
list($commit) = execx(
|
||||
'(cd %s && git rev-parse --verify %s)',
|
||||
$local_path,
|
||||
list($commit) = $repository->execxLocalCommand(
|
||||
'rev-parse --verify %s',
|
||||
$this->commit);
|
||||
|
||||
// Beyond verifying them, expand commit short forms to full 40-character
|
||||
|
@ -76,9 +74,8 @@ class DiffusionGitRequest extends DiffusionRequest {
|
|||
TODO: Unclear if this is actually a good idea or not; it breaks commit views
|
||||
at the very least.
|
||||
|
||||
list($contains) = execx(
|
||||
'(cd %s && git branch --contains %s)',
|
||||
$local_path,
|
||||
list($contains) = $repository->execxLocalCommand(
|
||||
'branch --contains %s',
|
||||
$this->commit);
|
||||
$contains = array_filter(explode("\n", $contains));
|
||||
$found = false;
|
||||
|
|
|
@ -8,7 +8,5 @@
|
|||
|
||||
phutil_require_module('phabricator', 'applications/diffusion/request/base');
|
||||
|
||||
phutil_require_module('phutil', 'future/exec');
|
||||
|
||||
|
||||
phutil_require_source('DiffusionGitRequest.php');
|
||||
|
|
Loading…
Reference in a new issue