本文整理汇总了PHP中hgsprintf函数的典型用法代码示例。如果您正苦于以下问题:PHP hgsprintf函数的具体用法?PHP hgsprintf怎么用?PHP hgsprintf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了hgsprintf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getMercurialResult
protected function getMercurialResult(ConduitAPIRequest $request)
{
$drequest = $this->getDiffusionRequest();
$path = $drequest->getPath();
$grep = $request->getValue('grep');
$repository = $drequest->getRepository();
$limit = $request->getValue('limit');
$offset = $request->getValue('offset');
$results = array();
$future = $repository->getLocalCommandFuture('grep --rev %s --print0 --line-number %s %s', hgsprintf('ancestors(%s)', $drequest->getStableCommit()), $grep, $path);
$lines = id(new LinesOfALargeExecFuture($future))->setDelimiter("");
$parts = array();
foreach ($lines as $line) {
$parts[] = $line;
if (count($parts) == 4) {
list($path, $char_offset, $line, $string) = $parts;
$results[] = array($path, $line, $string);
if (count($results) >= $offset + $limit) {
break;
}
$parts = array();
}
}
unset($lines);
return $results;
}
开发者ID:patelhardik,项目名称:phabricator,代码行数:26,代码来源:DiffusionSearchQueryConduitAPIMethod.php
示例2: testhgsprintf
public function testhgsprintf()
{
$this->assertEqual("'version-1'", hgsprintf('%s', 'version-1'));
$this->assertEqual("'single\\'quote'", hgsprintf('%s', "single'quote"));
$this->assertEqual("'back\\\\slash'", hgsprintf('%s', 'back\\slash'));
$this->assertEqual("'33%'", hgsprintf('%R', hgsprintf('%s', '33%')));
}
开发者ID:chaozhang80,项目名称:tool-package,代码行数:7,代码来源:PhutilxsprintfTestCase.php
示例3: __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
示例4: executeQuery
protected function executeQuery()
{
$repository = $this->getRepository();
$path = $this->path;
$commit = $this->commit;
$match_against = trim($path, '/');
$prefix = trim('./' . $match_against, '/');
list($entire_manifest) = $repository->execxLocalCommand('locate --print0 --rev %s -I %s', hgsprintf('%s', $commit), $prefix);
return explode("", $entire_manifest);
}
开发者ID:fengshao0907,项目名称:phabricator,代码行数:10,代码来源:DiffusionLowLevelMercurialPathsQuery.php
示例5: loadMercurialCommitRef
private function loadMercurialCommitRef()
{
$repository = $this->getRepository();
list($stdout) = $repository->execxLocalCommand('log --template %s --rev %s', '{author}\\n{desc}', hgsprintf('%s', $this->identifier));
list($author, $message) = explode("\n", $stdout, 2);
$author = phutil_utf8ize($author);
$message = phutil_utf8ize($message);
list($author_name, $author_email) = $this->splitUserIdentifier($author);
$hashes = array(id(new DiffusionCommitHash())->setHashType(ArcanistDifferentialRevisionHash::HASH_MERCURIAL_COMMIT)->setHashValue($this->identifier));
return id(new DiffusionCommitRef())->setAuthorName($author_name)->setAuthorEmail($author_email)->setMessage($message)->setHashes($hashes);
}
开发者ID:denghp,项目名称:phabricator,代码行数:11,代码来源:DiffusionLowLevelCommitQuery.php
示例6: getMercurialResult
protected function getMercurialResult(ConduitAPIRequest $request)
{
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
$paths = $request->getValue('paths');
$results = $this->loadCommitsFromCache($paths);
foreach ($paths as $path => $commit) {
if (array_key_exists($path, $results)) {
continue;
}
list($hash) = $repository->execxLocalCommand('log --template %s --limit 1 --removed --rev %s -- %s', '{node}', hgsprintf('reverse(ancestors(%s))', $commit), nonempty(ltrim($path, '/'), '.'));
$results[$path] = trim($hash);
}
return $results;
}
开发者ID:pugong,项目名称:phabricator,代码行数:15,代码来源:DiffusionLastModifiedQueryConduitAPIMethod.php
示例7: executeQuery
protected function executeQuery()
{
$repository = $this->getRepository();
$path = $this->path;
$commit = $this->commit;
$hg_paths_command = 'locate --print0 --rev %s -I %s';
$hg_version = PhabricatorRepositoryVersion::getMercurialVersion();
if (PhabricatorRepositoryVersion::isMercurialFilesCommandAvailable($hg_version)) {
$hg_paths_command = 'files --print0 --rev %s -I %s';
}
$match_against = trim($path, '/');
$prefix = trim('./' . $match_against, '/');
list($entire_manifest) = $repository->execxLocalCommand($hg_paths_command, hgsprintf('%s', $commit), $prefix);
return explode("", $entire_manifest);
}
开发者ID:pugong,项目名称:phabricator,代码行数:15,代码来源:DiffusionLowLevelMercurialPathsQuery.php
示例8: executeQuery
protected function executeQuery()
{
$repository = $this->getRepository();
if ($this->contains !== null) {
$spec = hgsprintf('(descendants(%s) and head())', $this->contains);
} else {
$spec = hgsprintf('head()');
}
list($stdout) = $repository->execxLocalCommand('log --template %s --rev %s', '{node}\\1{branch}\\2', $spec);
$branches = array();
$lines = explode("", $stdout);
$lines = array_filter($lines);
foreach ($lines as $line) {
list($node, $branch) = explode("", $line);
$branches[] = id(new DiffusionRepositoryRef())->setShortName($branch)->setCommitIdentifier($node);
}
return $branches;
}
开发者ID:denghp,项目名称:phabricator,代码行数:18,代码来源:DiffusionLowLevelMercurialBranchesQuery.php
示例9: executeQuery
protected function executeQuery()
{
$repository = $this->getRepository();
$specs = array();
if ($this->contains !== null) {
$specs['all'] = hgsprintf('(descendants(%s) and head())', $this->contains);
$specs['open'] = hgsprintf('(descendants(%s) and head() and not closed())', $this->contains);
} else {
$specs['all'] = hgsprintf('head()');
$specs['open'] = hgsprintf('head() and not closed()');
}
$futures = array();
foreach ($specs as $key => $spec) {
$futures[$key] = $repository->getLocalCommandFuture('log --template %s --rev %s', '{node}\\1{branch}\\2', $spec);
}
$branches = array();
$open = array();
foreach (new FutureIterator($futures) as $key => $future) {
list($stdout) = $future->resolvex();
$lines = explode("", $stdout);
$lines = array_filter($lines);
foreach ($lines as $line) {
list($node, $branch) = explode("", $line);
$id = $node . '/' . $branch;
if (empty($branches[$id])) {
$branches[$id] = id(new DiffusionRepositoryRef())->setShortName($branch)->setCommitIdentifier($node);
}
if ($key == 'open') {
$open[$id] = true;
}
}
}
foreach ($branches as $id => $branch) {
$branch->setRawFields(array('closed' => empty($open[$id])));
}
return array_values($branches);
}
开发者ID:pugong,项目名称:phabricator,代码行数:37,代码来源:DiffusionLowLevelMercurialBranchesQuery.php
示例10: loadCommitInfo
private function loadCommitInfo(array $branches)
{
$repository_api = $this->getRepositoryAPI();
$futures = array();
foreach ($branches as $branch) {
if ($repository_api instanceof ArcanistMercurialAPI) {
$futures[$branch['name']] = $repository_api->execFutureLocal('log -l 1 --template %s -r %s', "{node}{date|hgdate}{p1node}{desc|firstline}{desc}", hgsprintf('%s', $branch['name']));
} else {
// NOTE: "-s" is an option deep in git's diff argument parser that
// doesn't seem to have much documentation and has no long form. It
// suppresses any diff output.
$futures[$branch['name']] = $repository_api->execFutureLocal('show -s --format=%C %s --', '%H%x01%ct%x01%T%x01%s%x01%s%n%n%b', $branch['name']);
}
}
$branches = ipull($branches, null, 'name');
$futures = id(new FutureIterator($futures))->limit(16);
foreach ($futures as $name => $future) {
list($info) = $future->resolvex();
list($hash, $epoch, $tree, $desc, $text) = explode("", trim($info), 5);
$branch = $branches[$name] + array('hash' => $hash, 'desc' => $desc, 'tree' => $tree, 'epoch' => (int) $epoch);
try {
$message = ArcanistDifferentialCommitMessage::newFromRawCorpus($text);
$id = $message->getRevisionID();
$branch['revisionID'] = $id;
} catch (ArcanistUsageException $ex) {
// In case of invalid commit message which fails the parsing,
// do nothing.
$branch['revisionID'] = null;
}
$branches[$name] = $branch;
}
return $branches;
}
开发者ID:lewisf,项目名称:arcanist,代码行数:33,代码来源:ArcanistFeatureWorkflow.php
示例11: cleanupBranch
private function cleanupBranch()
{
$repository_api = $this->getRepositoryAPI();
echo "Cleaning up feature {$this->branchType}...\n";
if ($this->isGit) {
list($ref) = $repository_api->execxLocal('rev-parse --verify %s', $this->branch);
$ref = trim($ref);
$recovery_command = csprintf('git checkout -b %s %s', $this->branch, $ref);
echo "(Use `{$recovery_command}` if you want it back.)\n";
$repository_api->execxLocal('branch -D %s', $this->branch);
} else {
if ($this->isHg) {
$common_ancestor = $repository_api->getCanonicalRevisionName(hgsprintf("ancestor(%s,%s)", $this->onto, $this->branch));
$branch_root = $repository_api->getCanonicalRevisionName(hgsprintf("first((%s::%s)-%s)", $common_ancestor, $this->branch, $common_ancestor));
$repository_api->execxLocal('--config extensions.mq= strip -r %s', $branch_root);
if ($repository_api->isBookmark($this->branch)) {
$repository_api->execxLocal('bookmark -d %s', $this->branch);
}
}
}
if ($this->getArgument('delete-remote')) {
if ($this->isGit) {
list($err, $ref) = $repository_api->execManualLocal('rev-parse --verify %s/%s', $this->remote, $this->branch);
if ($err) {
echo "No remote feature {$this->branchType} to clean up.\n";
} else {
// NOTE: In Git, you delete a remote branch by pushing it with a
// colon in front of its name:
//
// git push <remote> :<branch>
echo "Cleaning up remote feature branch...\n";
$repository_api->execxLocal('push %s :%s', $this->remote, $this->branch);
}
} else {
if ($this->isHg) {
// named branches were closed as part of the earlier commit
// so only worry about bookmarks
if ($repository_api->isBookmark($this->branch)) {
$repository_api->execxLocal('push -B %s %s', $this->branch, $this->remote);
}
}
}
}
}
开发者ID:chaozhang80,项目名称:tool-package,代码行数:44,代码来源:ArcanistLandWorkflow.php
示例12: loadNewCommitIdentifiers
/**
* Find all ancestors of a new closing branch head which are not ancestors
* of any old closing branch head.
*/
private function loadNewCommitIdentifiers($new_head, array $all_closing_heads)
{
$repository = $this->getRepository();
$vcs = $repository->getVersionControlSystem();
switch ($vcs) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
if ($all_closing_heads) {
$escheads = array();
foreach ($all_closing_heads as $head) {
$escheads[] = hgsprintf('%s', $head);
}
$escheads = implode(' or ', $escheads);
list($stdout) = $this->getRepository()->execxLocalCommand('log --template %s --rev %s', '{node}\\n', hgsprintf('%s', $new_head) . ' - (' . $escheads . ')');
} else {
list($stdout) = $this->getRepository()->execxLocalCommand('log --template %s --rev %s', '{node}\\n', hgsprintf('%s', $new_head));
}
$stdout = trim($stdout);
if (!strlen($stdout)) {
return array();
}
return phutil_split_lines($stdout, $retain_newlines = false);
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
if ($all_closing_heads) {
list($stdout) = $this->getRepository()->execxLocalCommand('log --format=%s %s --not %Ls', '%H', $new_head, $all_closing_heads);
} else {
list($stdout) = $this->getRepository()->execxLocalCommand('log --format=%s %s', '%H', $new_head);
}
$stdout = trim($stdout);
if (!strlen($stdout)) {
return array();
}
return phutil_split_lines($stdout, $retain_newlines = false);
default:
throw new Exception(pht('Unsupported VCS "%s"!', $vcs));
}
}
开发者ID:denghp,项目名称:phabricator,代码行数:40,代码来源:PhabricatorRepositoryRefEngine.php
示例13: resolveBaseCommitRule
public function resolveBaseCommitRule($rule, $source)
{
list($type, $name) = explode(':', $rule, 2);
// NOTE: This function MUST return node hashes or symbolic commits (like
// branch names or the word "tip"), not revsets. This includes ".^" and
// similar, which a revset, not a symbolic commit identifier. If you return
// a revset it will be escaped later and looked up literally.
switch ($type) {
case 'hg':
$matches = null;
if (preg_match('/^gca\\((.+)\\)$/', $name, $matches)) {
list($err, $merge_base) = $this->execManualLocal('log --template={node} --rev %s', sprintf('ancestor(., %s)', $matches[1]));
if (!$err) {
$this->setBaseCommitExplanation(pht("it is the greatest common ancestor of '%s' and %s, as " . "specified by '%s' in your %s 'base' configuration.", $matches[1], '.', $rule, $source));
return trim($merge_base);
}
} else {
list($err, $commit) = $this->execManualLocal('log --template {node} --rev %s', hgsprintf('%s', $name));
if ($err) {
list($err, $commit) = $this->execManualLocal('log --template {node} --rev %s', $name);
}
if (!$err) {
$this->setBaseCommitExplanation(pht("it is specified by '%s' in your %s 'base' configuration.", $rule, $source));
return trim($commit);
}
}
break;
case 'arc':
switch ($name) {
case 'empty':
$this->setBaseCommitExplanation(pht("you specified '%s' in your %s 'base' configuration.", $rule, $source));
return 'null';
case 'outgoing':
list($err, $outgoing_base) = $this->execManualLocal('log --template={node} --rev %s', 'limit(reverse(ancestors(.) - outgoing()), 1)');
if (!$err) {
$this->setBaseCommitExplanation(pht("it is the first ancestor of the working copy that is not " . "outgoing, and it matched the rule %s in your %s " . "'base' configuration.", $rule, $source));
return trim($outgoing_base);
}
case 'amended':
$text = $this->getCommitMessage('.');
$message = ArcanistDifferentialCommitMessage::newFromRawCorpus($text);
if ($message->getRevisionID()) {
$this->setBaseCommitExplanation(pht("'%s' has been amended with 'Differential Revision:', " . "as specified by '%s' in your %s 'base' configuration.", '.' . $rule, $source));
// NOTE: This should be safe because Mercurial doesn't support
// amend until 2.2.
return $this->getCanonicalRevisionName('.^');
}
break;
case 'bookmark':
$revset = 'limit(' . ' sort(' . ' (ancestors(.) and bookmark() - .) or' . ' (ancestors(.) - outgoing()), ' . ' -rev),' . '1)';
list($err, $bookmark_base) = $this->execManualLocal('log --template={node} --rev %s', $revset);
if (!$err) {
$this->setBaseCommitExplanation(pht("it is the first ancestor of %s that either has a bookmark, " . "or is already in the remote and it matched the rule %s in " . "your %s 'base' configuration", '.', $rule, $source));
return trim($bookmark_base);
}
break;
case 'this':
$this->setBaseCommitExplanation(pht("you specified '%s' in your %s 'base' configuration.", $rule, $source));
return $this->getCanonicalRevisionName('.^');
default:
if (preg_match('/^nodiff\\((.+)\\)$/', $name, $matches)) {
list($results) = $this->execxLocal('log --template %s --rev %s', "{node}{desc}", sprintf('ancestor(.,%s)::.^', $matches[1]));
$results = array_reverse(explode("", trim($results)));
foreach ($results as $result) {
if (empty($result)) {
continue;
}
list($node, $desc) = explode("", $result, 2);
$message = ArcanistDifferentialCommitMessage::newFromRawCorpus($desc);
if ($message->getRevisionID()) {
$this->setBaseCommitExplanation(pht("it is the first ancestor of %s that has a diff and is " . "the gca or a descendant of the gca with '%s', " . "specified by '%s' in your %s 'base' configuration.", '.', $matches[1], $rule, $source));
return $node;
}
}
}
break;
}
break;
default:
return null;
}
return null;
}
开发者ID:lewisf,项目名称:arcanist,代码行数:83,代码来源:ArcanistMercurialAPI.php
示例14: resolveMercurialRefs
private function resolveMercurialRefs()
{
$repository = $this->getRepository();
$futures = array();
foreach ($this->refs as $ref) {
$futures[$ref] = $repository->getLocalCommandFuture('log --template=%s --rev %s', '{node}', hgsprintf('%s', $ref));
}
$results = array();
foreach (Futures($futures) as $ref => $future) {
try {
list($stdout) = $future->resolvex();
} catch (CommandException $ex) {
if (preg_match('/ambiguous identifier/', $ex->getStdErr())) {
// This indicates that the ref ambiguously matched several things.
// Eventually, it would be nice to return all of them, but it is
// unclear how to best do that. For now, treat it as a miss instead.
continue;
}
throw $ex;
}
// It doesn't look like we can figure out the type (commit/branch/rev)
// from this output very easily. For now, just call everything a commit.
$type = 'commit';
$results[$ref][] = array('type' => $type, 'identifier' => trim($stdout));
}
return $results;
}
开发者ID:denghp,项目名称:phabricator,代码行数:27,代码来源:DiffusionLowLevelResolveRefsQuery.php
示例15: findMercurialPushKeyRefUpdates
private function findMercurialPushKeyRefUpdates()
{
$key_namespace = getenv('HG_NAMESPACE');
if ($key_namespace === 'phases') {
// Mercurial changes commit phases as part of normal push operations. We
// just ignore these, as they don't seem to represent anything
// interesting.
return array();
}
$key_name = getenv('HG_KEY');
$key_old = getenv('HG_OLD');
if (!strlen($key_old)) {
$key_old = null;
}
$key_new = getenv('HG_NEW');
if (!strlen($key_new)) {
$key_new = null;
}
if ($key_namespace !== 'bookmarks') {
throw new Exception(pht("Unknown Mercurial key namespace '%s', with key '%s' (%s -> %s). " . "Rejecting push.", $key_namespace, $key_name, coalesce($key_old, pht('null')), coalesce($key_new, pht('null'))));
}
if ($key_old === $key_new) {
// We get a callback when the bookmark doesn't change. Just ignore this,
// as it's a no-op.
return array();
}
$ref_flags = 0;
$merge_base = null;
if ($key_old === null) {
$ref_flags |= PhabricatorRepositoryPushLog::CHANGEFLAG_ADD;
} else {
if ($key_new === null) {
$ref_flags |= PhabricatorRepositoryPushLog::CHANGEFLAG_DELETE;
} else {
list($merge_base_raw) = $this->getRepository()->execxLocalCommand('log --template %s --rev %s', '{node}', hgsprintf('ancestor(%s, %s)', $key_old, $key_new));
if (strlen(trim($merge_base_raw))) {
$merge_base = trim($merge_base_raw);
}
if ($merge_base && $merge_base === $key_old) {
$ref_flags |= PhabricatorRepositoryPushLog::CHANGEFLAG_APPEND;
} else {
$ref_flags |= PhabricatorRepositoryPushLog::CHANGEFLAG_REWRITE;
}
}
}
$ref_update = $this->newPushLog()->setRefType(PhabricatorRepositoryPushLog::REFTYPE_BOOKMARK)->setRefName($key_name)->setRefOld(coalesce($key_old, self::EMPTY_HASH))->setRefNew(coalesce($key_new, self::EMPTY_HASH))->setChangeFlags($ref_flags);
return array($ref_update);
}
开发者ID:rchicoli,项目名称:phabricator,代码行数:48,代码来源:DiffusionCommitHookEngine.php
示例16: run
public function run()
{
$console = PhutilConsole::getConsole();
if (!$this->getArgument('show-base')) {
$this->printRepositorySection();
$console->writeOut("\n");
}
$repository_api = $this->getRepositoryAPI();
$arg_commit = $this->getArgument('commit');
if (count($arg_commit)) {
$this->parseBaseCommitArgument($arg_commit);
}
$arg = $arg_commit ? ' ' . head($arg_commit) : '';
$repository_api->setBaseCommitArgumentRules($this->getArgument('base', ''));
$supports_ranges = $repository_api->supportsCommitRanges();
$head_commit = $this->getArgument('head');
if ($head_commit !== null) {
$arg .= csprintf(' --head %R', $head_commit);
$repository_api->setHeadCommit($head_commit);
}
if ($supports_ranges) {
$relative = $repository_api->getBaseCommit();
if ($this->getArgument('show-base')) {
echo $relative . "\n";
return 0;
}
$info = $repository_api->getLocalCommitInformation();
if ($info) {
$commits = array();
foreach ($info as $commit) {
$hash = substr($commit['commit'], 0, 16);
$summary = $commit['summary'];
$commits[] = " {$hash} {$summary}";
}
$commits = implode("\n", $commits);
} else {
$commits = ' ' . pht('(No commits.)');
}
$explanation = $repository_api->getBaseCommitExplanation();
$relative_summary = $repository_api->getCommitSummary($relative);
$relative = substr($relative, 0, 16);
if ($repository_api instanceof ArcanistGitAPI) {
$head = $this->getArgument('head', 'HEAD');
$command = csprintf('git diff %R', "{$relative}..{$head}");
} else {
if ($repository_api instanceof ArcanistMercurialAPI) {
$command = csprintf('hg diff --rev %R', hgsprintf('%s', $relative));
} else {
throw new Exception(pht('Unknown VCS!'));
}
}
echo phutil_console_wrap(phutil_console_format("**%s**\n%s\n\n %s %s\n\n", pht('COMMIT RANGE'), pht("If you run '%s', changes between the commit:", "arc diff{$arg}"), $relative, $relative_summary));
if ($head_commit === null) {
$will_be_sent = pht('...and the current working copy state will be sent to ' . 'Differential, because %s', $explanation);
} else {
$will_be_sent = pht('...and "%s" will be sent to Differential, because %s', $head_commit, $explanation);
}
echo phutil_console_wrap(phutil_console_format("%s\n\n%s\n\n \$ %s\n\n%s\n\n", $will_be_sent, pht('You can see the exact changes that will be sent by running ' . 'this command:'), $command, pht('These commits will be included in the diff:')));
echo $commits . "\n\n\n";
}
$any_status = $this->getArgument('any-status');
$query = array('status' => $any_status ? 'status-any' : 'status-open');
$revisions = $repository_api->loadWorkingCopyDifferentialRevisions($this->getConduit(), $query);
echo phutil_console_wrap(phutil_console_format("**%s**\n%s\n\n", pht('MATCHING REVISIONS'), pht('These Differential revisions match the changes in this working ' . 'copy:')));
if (empty($revisions)) {
echo " " . pht('(No revisions match.)') . "\n";
echo "\n";
echo phutil_console_wrap(phutil_console_format(pht("Since there are no revisions in Differential which match this " . "working copy, a new revision will be **created** if you run " . "'%s'.\n\n", "arc diff{$arg}")));
} else {
$other_author_phids = array();
foreach ($revisions as $revision) {
if ($revision['authorPHID'] != $this->getUserPHID()) {
$other_author_phids[] = $revision['authorPHID'];
}
}
$other_authors = array();
if ($other_author_phids) {
$other_authors = $this->getConduit()->callMethodSynchronous('user.query', array('phids' => $other_author_phids));
$other_authors = ipull($other_authors, 'userName', 'phid');
}
foreach ($revisions as $revision) {
$title = $revision['title'];
$monogram = 'D' . $revision['id'];
if ($revision['authorPHID'] != $this->getUserPHID()) {
$author = $other_authors[$revision['authorPHID']];
echo pht(" %s (%s) %s\n", $monogram, $author, $title);
} else {
echo pht(" %s %s\n", $monogram, $title);
}
echo ' ' . pht('Reason') . ': ' . $revision['why'] . "\n";
echo "\n";
}
if (count($revisions) == 1) {
echo phutil_console_wrap(phutil_console_format(pht("Since exactly one revision in Differential matches this " . "working copy, it will be **updated** if you run '%s'.", "arc diff{$arg}")));
} else {
echo phutil_console_wrap(pht("Since more than one revision in Differential matches this " . "working copy, you will be asked which revision you want to " . "update if you run '%s'.", "arc diff {$arg}"));
}
echo "\n\n";
}
return 0;
//.........这里部分代码省略.........
开发者ID:barcelonascience,项目名称:arcanist,代码行数:101,代码来源:ArcanistWhichWorkflow.php
示例17: resolveMercurialRefs
private function resolveMercurialRefs()
{
$repository = $this->getRepository();
// First, pull all of the branch heads in the repository. Doing this in
// bulk is much faster than querying each individual head if we're
// checking even a small number of refs.
$branches = id(new DiffusionLowLevelMercurialBranchesQuery())->setRepository($repository)->executeQuery();
$branches = mgroup($branches, 'getShortName');
$results = array();
$unresolved = $this->refs;
foreach ($unresolved as $key => $ref) {
if (empty($branches[$ref])) {
continue;
}
foreach ($branches[$ref] as $branch) {
$fields = $branch->getRawFields();
$results[$ref][] = array('type' => 'branch', 'identifier' => $branch->getCommitIdentifier(), 'closed' => idx($fields, 'closed', false));
}
unset($unresolved[$key]);
}
if (!$unresolved) {
return $results;
}
// If we still have unresolved refs (which might be things like "tip"),
// try to resolve them individually.
$futures = array();
foreach ($unresolved as $ref) {
$futures[$ref] = $repository->getLocalCommandFuture('log --template=%s --rev %s', '{node}', hgsprintf('%s', $ref));
}
foreach (new FutureIterator($futures) as $ref => $future) {
try {
list($stdout) = $future->resolvex();
} catch (CommandException $ex) {
if (preg_match('/ambiguous identifier/', $ex->getStdErr())) {
// This indicates that the ref ambiguously matched several things.
// Eventually, it would be nice to return all of them, but it is
// unclear how to best do that. For now, treat it as a miss instead.
continue;
}
if (preg_match('/unknown revision/', $ex->getStdErr())) {
// No matches for this ref.
continue;
}
throw $ex;
}
// It doesn't look like we can figure out the type (commit/branch/rev)
// from this output very easily. For now, just call everything a commit.
$type = 'commit';
$results[$ref][] = array('type' => $type, 'identifier' => trim($stdout));
}
return $results;
}
开发者ID:rchicoli,项目名称:phabricator,代码行数:52,代码来源:DiffusionLowLevelResolveRefsQuery.php
示例18: getMercurialResult
protected function getMercurialResult(ConduitAPIRequest $request)
{
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
$commit_hash = $request->getValue('commit');
$path = $request->getValue('path');
$offset = $request->getValue('offset');
$limit = $request->getValue('limit');
$path = DiffusionPathIDQuery::normalizePath($path);
$path = ltrim($path, '/');
// NOTE: Older versions of Mercurial give different results for these
// commands (see T1268):
//
// $ hg log -- ''
// $ hg log
//
// All versions of Mercurial give different results for these commands
// (merge commits are excluded with the "." version):
//
// $ hg log -- .
// $ hg log
//
// If we don't have a path component in the query, omit it from the command
// entirely to avoid these inconsistencies.
// NOTE: When viewing the history of a file, we don't use "-b", because
// Mercurial stops history at the branchpoint but we're interested in all
// ancestors. When viewing history of a branch, we do use "-b", and thus
// stop history (this is more consistent with the Mercurial worldview of
// branches).
if (strlen($path)) {
$path_arg = csprintf('-- %s', $path);
$branch_arg = '';
} else {
$path_arg = '';
// NOTE: --branch used to be called --only-branch; use -b for
// compatibility.
$branch_arg = csprintf('-b %s', $drequest->getBranch());
}
list($stdout) = $repository->execxLocalCommand('log --debug --template %s --limit %d %C --rev %s %C', '{node};{parents}\\n', $offset + $limit, $branch_arg, hgsprintf('reverse(ancestors(%s))', $commit_hash), $path_arg);
$stdout = PhabricatorRepository::filterMercurialDebugOutput($stdout);
$lines = explode("\n", trim($stdout));
$lines = array_slice($lines, $offset);
$hash_list = array();
$parent_map = array();
$last = null;
foreach (array_reverse($lines) as $line) {
list($hash, $parents) = explode(';', $line);
$parents = trim($parents);
if (!$parents) {
if ($last === null) {
$parent_map[$hash] = array('...');
} else {
$parent_map[$hash] = array($last);
}
} else {
$parents = preg_split('/\\s+/', $parents);
foreach ($parents as $parent) {
list($plocal, $phash) = explode(':', $parent);
if (!preg_match('/^0+$/', $phash)) {
$parent_map[$hash][] = $phash;
}
}
// This may happen for the zeroth commit in repository, both hashes
// are "000000000...".
if (empty($parent_map[$hash])) {
$parent_map[$hash] = array('...');
}
}
// The rendering code expects the first commit to be "mainline", like
// Git. Flip the order so it does the right thing.
$parent_map[$hash] = array_reverse($parent_map[$hash]);
$hash_list[] = $hash;
$last = $hash;
}
$hash_list = array_reverse($hash_list);
$this->parents = $parent_map;
return DiffusionQuery::loadHistoryForCommitIdentifiers($hash_list, $drequest);
}
开发者ID:pugong,项目名称:phabricator,代码行数:78,代码来源:DiffusionHistoryQueryConduitAPIMethod.php
示例19: loadNewCommitIdentifiers
/**
* Find all ancestors of a new closing branch head which are not ancestors
* of any old closing branch head.
*/
private function loadNewCommitIdentifiers($new_head, array $all_closing_heads)
{
$repository = $this->getRepository();
$vcs = $repository->getVersionControlSystem();
switch ($vcs) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
if ($all_closing_heads) {
$parts = array();
foreach ($all_closing_heads as $head) {
$parts[] = hgsprintf('%s', $head);
}
// See T5896. Mercurial can not parse an "X or Y or ..." rev list
// with more than about 300 items, because it exceeds the maximum
// allowed recursion depth. Split all the heads into chunks of
// 256, and build a query like this:
//
// ((1 or 2 or ... or 255) or (256 or 257 or ... 511))
//
// If we have more than 65535 heads, we'll do that again:
//
// (((1 or ...) or ...) or ((65536 or ...) or ...))
$chunk_size = 256;
while (count($parts) > $chunk_size) {
$chunks = array_chunk($parts, $chunk_size);
foreach ($chunks as $key => $chunk) {
$chunks[$key] = '(' . implode(' or ', $chunk) . ')';
}
$parts = array_values($chunks);
}
$parts = '(' . implode(' or ', $parts) . ')';
list($stdout) = $this->getRepository()->execxLocalCommand('log --template %s --rev %s', '{node}\\n', hgsprintf('%s', $new_head) . ' - ' . $parts);
} else {
list($stdout) = $this->getRepository()->execxLocalCommand('log --template %s --rev %s', '{node}\\n', hgsprintf('%s', $new_head));
}
$stdout = trim($stdout);
if (!strlen($stdout)) {
return array();
}
return phutil_split_lines($stdout, $retain_newlines = false);
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
if ($all_closing_heads) {
list($stdout) = $this->getRepository()->execxLocalCommand('log --format=%s %s --not %Ls', '%H', $new_head, $all_closing_heads);
} else {
list($stdout) = $this->getRepository()->execxLocalCommand('log --format=%s %s', '%H', $new_head);
}
$stdout = trim($stdout);
if (!strlen($stdout)) {
return array();
}
return phutil_split_lines($stdout, $retain_newlines = false);
default:
throw new Exception(pht('Unsupported VCS "%s"!', $vcs));
}
}
开发者ID:vinzent,项目名称:phabricator,代码行数:58,代码来源:PhabricatorRepositoryRefEngine.php
示例20: run
//.........这里部分代码省略.........
} else {
echo phutil_console_format("\n\n<bg:yellow>** %s **</bg> %s\n", pht('WARNING'), pht("
|
请发表评论