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


PHP hgsprintf函数代码示例

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


在下文中一共展示了hgsprintf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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