#!/usr/bin/env php
<?php 
$root = dirname(dirname(dirname(dirname(__FILE__))));
require_once $root . '/scripts/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline('test client for Aphlict server');
$args->setSynopsis(<<<EOHELP
**aphlict_test_client.php** [__options__]
    Connect to the Aphlict server configured in the Phabricator config.

EOHELP
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'server', 'param' => 'uri', 'default' => PhabricatorEnv::getEnvConfig('notification.client-uri'), 'help' => 'Connect to __uri__ instead of the default server.')));
$console = PhutilConsole::getConsole();
$errno = null;
$errstr = null;
$uri = $args->getArg('server');
$uri = new PhutilURI($uri);
$uri->setProtocol('tcp');
$console->writeErr("Connecting...\n");
$socket = stream_socket_client($uri, $errno, $errstr);
if (!$socket) {
    $console->writeErr("Unable to connect to Aphlict (at '{$uri}'). Error #{$errno}: {$errstr}");
    exit(1);
} else {
    $console->writeErr("Connected.\n");
}
$io_channel = new PhutilSocketChannel($socket);
$proto_channel = new PhutilJSONProtocolChannel($io_channel);
$json = new PhutilJSON();
$ssh_start_time = microtime(true);
$root = dirname(dirname(dirname(__FILE__)));
require_once $root . '/scripts/__init_script__.php';
$ssh_log = PhabricatorSSHLog::getLog();
$args = new PhutilArgumentParser($argv);
$args->setTagline(pht('execute SSH requests'));
$args->setSynopsis(<<<EOSYNOPSIS
**ssh-exec** --phabricator-ssh-user __user__ [--ssh-command __commmand__]
**ssh-exec** --phabricator-ssh-device __device__ [--ssh-command __commmand__]
    Execute authenticated SSH requests. This script is normally invoked
    via SSHD, but can be invoked manually for testing.

EOSYNOPSIS
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'phabricator-ssh-user', 'param' => 'username', 'help' => pht('If the request authenticated with a user key, the name of the ' . 'user.')), array('name' => 'phabricator-ssh-device', 'param' => 'name', 'help' => pht('If the request authenticated with a device key, the name of the ' . 'device.')), array('name' => 'phabricator-ssh-key', 'param' => 'id', 'help' => pht('The ID of the SSH key which authenticated this request. This is ' . 'used to allow logs to report when specific keys were used, to make ' . 'it easier to manage credentials.')), array('name' => 'ssh-command', 'param' => 'command', 'help' => pht('Provide a command to execute. This makes testing this script ' . 'easier. When running normally, the command is read from the ' . 'environment (%s), which is populated by sshd.', 'SSH_ORIGINAL_COMMAND'))));
try {
    $remote_address = null;
    $ssh_client = getenv('SSH_CLIENT');
    if ($ssh_client) {
        // This has the format "<ip> <remote-port> <local-port>". Grab the IP.
        $remote_address = head(explode(' ', $ssh_client));
        $ssh_log->setData(array('r' => $remote_address));
    }
    $key_id = $args->getArg('phabricator-ssh-key');
    if ($key_id) {
        $ssh_log->setData(array('k' => $key_id));
    }
    $user_name = $args->getArg('phabricator-ssh-user');
    $device_name = $args->getArg('phabricator-ssh-device');
    $user = null;
Exemple #3
0
#!/usr/bin/env php
<?php 
/*
 * Copyright 2012 Facebook, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
require_once dirname(dirname(__FILE__)) . '/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'quiet', 'help' => 'Do not print status messages to stdout.'), array('name' => 'skip-hello', 'help' => 'Do not send "capability" message when clients connect. ' . 'Clients must be configured not to expect the message. ' . 'This deviates from the Mercurial protocol, but slightly ' . 'improves performance.'), array('name' => 'do-not-daemonize', 'help' => 'Remain in the foreground instead of daemonizing.'), array('name' => 'client-limit', 'param' => 'limit', 'help' => 'Exit after serving __limit__ clients.'), array('name' => 'idle-limit', 'param' => 'seconds', 'help' => 'Exit after __seconds__ spent idle.'), array('name' => 'repository', 'wildcard' => true)));
$repo = $args->getArg('repository');
if (count($repo) !== 1) {
    throw new Exception("Specify exactly one working copy!");
}
$repo = head($repo);
id(new ArcanistHgProxyServer($repo))->setQuiet($args->getArg('quiet'))->setClientLimit($args->getArg('client-limit'))->setIdleLimit($args->getArg('idle-limit'))->setDoNotDaemonize($args->getArg('do-not-daemonize'))->setSkipHello($args->getArg('skip-hello'))->start();
#!/usr/bin/env php
<?php 
$root = dirname(dirname(dirname(__FILE__)));
require_once $root . '/scripts/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setSynopsis(<<<EOSYNOPSIS
**import_project_symbols.php** [__options__] __project_name__ < symbols

  Import project symbols (symbols are read from stdin).
EOSYNOPSIS
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'no-purge', 'help' => 'Do not clear all symbols for this project before ' . 'uploading new symbols. Useful for incremental updating.'), array('name' => 'ignore-errors', 'help' => 'If a line can\'t be parsed, ignore that line and ' . 'continue instead of exiting.'), array('name' => 'max-transaction', 'param' => 'num-syms', 'default' => '100000', 'help' => 'Maximum number of symbols that should ' . 'be part of a single transaction'), array('name' => 'more', 'wildcard' => true)));
$more = $args->getArg('more');
if (count($more) !== 1) {
    $args->printHelpAndExit();
}
$project_name = head($more);
$project = id(new PhabricatorRepositoryArcanistProject())->loadOneWhere('name = %s', $project_name);
if (!$project) {
    // TODO: Provide a less silly way to do this explicitly, or just do it right
    // here.
    echo "Project '{$project_name}' is unknown. Upload a diff to implicitly " . "create it.\n";
    exit(1);
}
echo "Parsing input from stdin...\n";
$input = file_get_contents('php://stdin');
$input = trim($input);
$input = explode("\n", $input);
function commit_symbols($syms, $project, $no_purge)
{
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
$package_spec = array('javelin.pkg.js' => array('javelin-util', 'javelin-install', 'javelin-event', 'javelin-stratcom', 'javelin-behavior', 'javelin-request', 'javelin-vector', 'javelin-dom', 'javelin-json', 'javelin-uri'), 'typeahead.pkg.js' => array('javelin-typeahead', 'javelin-typeahead-normalizer', 'javelin-typeahead-source', 'javelin-typeahead-preloaded-source', 'javelin-typeahead-ondemand-source', 'javelin-tokenizer', 'javelin-behavior-aphront-basic-tokenizer'), 'core.pkg.js' => array('javelin-mask', 'javelin-workflow', 'javelin-behavior-workflow', 'javelin-behavior-aphront-form-disable-on-submit', 'phabricator-keyboard-shortcut-manager', 'phabricator-keyboard-shortcut', 'javelin-behavior-phabricator-keyboard-shortcuts', 'javelin-behavior-refresh-csrf', 'javelin-behavior-phabricator-watch-anchor', 'javelin-behavior-phabricator-autofocus', 'phabricator-paste-file-upload', 'phabricator-menu-item', 'phabricator-dropdown-menu', 'javelin-behavior-phabricator-oncopy', 'phabricator-tooltip', 'javelin-behavior-phabricator-tooltips', 'phabricator-prefab'), 'core.pkg.css' => array('phabricator-core-css', 'phabricator-core-buttons-css', 'phabricator-standard-page-view', 'aphront-dialog-view-css', 'aphront-form-view-css', 'aphront-panel-view-css', 'aphront-side-nav-view-css', 'aphront-table-view-css', 'aphront-crumbs-view-css', 'aphront-tokenizer-control-css', 'aphront-typeahead-control-css', 'aphront-list-filter-view-css', 'phabricator-directory-css', 'phabricator-jump-nav', 'phabricator-app-buttons-css', 'phabricator-remarkup-css', 'syntax-highlighting-css', 'aphront-pager-view-css', 'phabricator-transaction-view-css', 'aphront-tooltip-css', 'aphront-headsup-view-css', 'phabricator-flag-css', 'aphront-error-view-css'), 'differential.pkg.css' => array('differential-core-view-css', 'differential-changeset-view-css', 'differential-results-table-css', 'differential-revision-history-css', 'differential-table-of-contents-css', 'differential-revision-comment-css', 'differential-revision-add-comment-css', 'differential-revision-comment-list-css', 'phabricator-object-selector-css', 'aphront-headsup-action-list-view-css', 'phabricator-content-source-view-css', 'differential-local-commits-view-css', 'inline-comment-summary-css'), 'differential.pkg.js' => array('phabricator-drag-and-drop-file-upload', 'phabricator-shaped-request', 'javelin-behavior-differential-feedback-preview', 'javelin-behavior-differential-edit-inline-comments', 'javelin-behavior-differential-populate', 'javelin-behavior-differential-show-more', 'javelin-behavior-differential-diff-radios', 'javelin-behavior-differential-accept-with-errors', 'javelin-behavior-differential-comment-jump', 'javelin-behavior-differential-add-reviewers-and-ccs', 'javelin-behavior-differential-keyboard-navigation', 'javelin-behavior-aphront-drag-and-drop', 'javelin-behavior-aphront-drag-and-drop-textarea', 'javelin-behavior-phabricator-object-selector', 'javelin-behavior-repository-crossreference', 'differential-inline-comment-editor', 'javelin-behavior-differential-dropdown-menus', 'javelin-behavior-buoyant'), 'diffusion.pkg.css' => array('diffusion-commit-view-css', 'diffusion-icons-css'), 'diffusion.pkg.js' => array('javelin-behavior-diffusion-pull-lastmodified', 'javelin-behavior-diffusion-commit-graph', 'javelin-behavior-audit-preview'), 'maniphest.pkg.css' => array('maniphest-task-summary-css', 'maniphest-transaction-detail-css', 'aphront-attached-file-view-css', 'phabricator-project-tag-css'), 'maniphest.pkg.js' => array('javelin-behavior-maniphest-batch-selector', 'javelin-behavior-maniphest-transaction-controls', 'javelin-behavior-maniphest-transaction-preview', 'javelin-behavior-maniphest-transaction-expand', 'javelin-behavior-maniphest-subpriority-editor'));
require_once dirname(__FILE__) . '/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline('map static resources');
$args->setSynopsis("**celerity_mapper.php** [--output __path__] [--with-custom] <webroot>");
$args->parse(array(array('name' => 'output', 'param' => 'path', 'default' => '../src/__celerity_resource_map__.php', 'help' => "Set the path for resource map. It is usually useful for " . "'celerity.resource-path' configuration."), array('name' => 'with-custom', 'help' => 'Include resources in <webroot>/rsrc/custom/.'), array('name' => 'webroot', 'wildcard' => true)));
$root = $args->getArg('webroot');
if (count($root) != 1 || !is_dir(reset($root))) {
    $args->printHelpAndExit();
}
$root = Filesystem::resolvePath(reset($root));
$celerity_path = Filesystem::resolvePath($args->getArg('output'), $root);
$with_custom = $args->getArg('with-custom');
$resource_hash = PhabricatorEnv::getEnvConfig('celerity.resource-hash');
$runtime_map = array();
echo "Finding raw static resources...\n";
$finder = id(new FileFinder($root))->withType('f')->withSuffix('png')->withSuffix('jpg')->withSuffix('gif')->withSuffix('swf')->withFollowSymlinks(true)->setGenerateChecksums(true);
if (!$with_custom) {
    $finder->excludePath('./rsrc/custom');
}
$raw_files = $finder->find();
#!/usr/bin/env php
<?php 
require_once dirname(dirname(__FILE__)) . '/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'skip-hello', 'help' => 'Do not expect "capability" message when connecting. ' . 'The server must be configured not to send the message. ' . 'This deviates from the Mercurial protocol, but slightly ' . 'improves performance.'), array('name' => 'repository', 'wildcard' => true)));
$repo = $args->getArg('repository');
if (count($repo) !== 1) {
    throw new Exception('Specify exactly one working copy!');
}
$repo = head($repo);
$client = new ArcanistHgProxyClient($repo);
$client->setSkipHello($args->getArg('skip-hello'));
$t_start = microtime(true);
$result = $client->executeCommand(array('log', '--template', '{node}', '--rev', 2));
$t_end = microtime(true);
var_dump($result);
echo "\nExecuted in " . (int) (1000000 * ($t_end - $t_start)) . "us.\n";
#!/usr/bin/env php
<?php 
require_once dirname(__FILE__) . '/../__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline(pht('test context-free grammars'));
$args->setSynopsis(<<<EOHELP
**lipsum.php** __class__
    Generate output from a named context-free grammar.
EOHELP
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'class', 'wildcard' => true)));
$class = $args->getArg('class');
if (count($class) !== 1) {
    $args->printHelpAndExit();
}
$class = reset($class);
$symbols = id(new PhutilClassMapQuery())->setAncestorClass('PhutilContextFreeGrammar')->execute();
$symbols = ipull($symbols, 'name', 'name');
if (empty($symbols[$class])) {
    $available = implode(', ', array_keys($symbols));
    throw new PhutilArgumentUsageException(pht("Class '%s' is not a defined, concrete subclass of %s. " . "Available classes are: %s", $class, 'PhutilContextFreeGrammar', $available));
}
$object = newv($class, array());
echo $object->generate() . "\n";
Exemple #8
0
#!/usr/bin/env php
<?php 
require_once dirname(__FILE__) . '/../__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline(pht('test syntax highlighters'));
$args->setSynopsis(<<<EOHELP
**highlight.php** [__options__]
    Syntax highlight a corpus read from stdin.
EOHELP
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'language', 'param' => 'language', 'help' => pht('Choose the highlight language.'))));
$language = $args->getArg('language');
$corpus = file_get_contents('php://stdin');
echo id(new PhutilDefaultSyntaxHighlighterEngine())->setConfig('pygments.enabled', true)->highlightSource($language, $corpus);
        Dependencies on builtins and symbols marked '@phutil-external-symbol'
        in docblocks are omitted without __--all__.

        Symbols are reported in JSON on stdout.

        This script is used internally by libphutil/arcanist to build maps of
        library symbols.

        It would be nice to eventually implement this as a C++ xhpast binary,
        as it's relatively stable and performance is currently awful
        (500ms+ for moderately large files).

EOHELP
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'all', 'help' => pht('Report all symbols, including built-ins and declared externals.')), array('name' => 'ugly', 'help' => pht('Do not prettify JSON output.')), array('name' => 'path', 'wildcard' => true, 'help' => pht('PHP Source file to analyze.'))));
$paths = $args->getArg('path');
if (count($paths) !== 1) {
    throw new Exception(pht('Specify exactly one path!'));
}
$path = Filesystem::resolvePath(head($paths));
$show_all = $args->getArg('all');
$source_code = Filesystem::readFile($path);
try {
    $tree = XHPASTTree::newFromData($source_code);
} catch (XHPASTSyntaxErrorException $ex) {
    $result = array('error' => $ex->getMessage(), 'line' => $ex->getErrorLine(), 'file' => $path);
    $json = new PhutilJSON();
    echo $json->encodeFormatted($result);
    exit(0);
}
Exemple #10
0
#!/usr/bin/env php
<?php 
require_once dirname(__FILE__) . '/../__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'attach', 'param' => 'file', 'help' => pht('Attach a file to the request.')), array('name' => 'url', 'wildcard' => true)));
$uri = $args->getArg('url');
if (count($uri) !== 1) {
    throw new PhutilArgumentUsageException('Specify exactly one URL to retrieve.');
}
$uri = head($uri);
$method = 'GET';
$data = '';
$timeout = 30;
$future = id(new HTTPSFuture($uri, $data))->setMethod($method)->setTimeout($timeout);
$attach_file = $args->getArg('attach');
if ($attach_file !== null) {
    $future->attachFileData('file', Filesystem::readFile($attach_file), basename($attach_file), Filesystem::getMimeType($attach_file));
}
print_r($future->resolve());
Exemple #11
0
// NOTE: This script is very oldschool and takes the environment as an argument.
// Some day, we could take a shot at cleaning this up.
if ($argc > 1) {
    foreach (array_slice($argv, 1) as $arg) {
        if (!preg_match('/^-/', $arg)) {
            $_SERVER['PHABRICATOR_ENV'] = $arg;
            break;
        }
    }
}
$root = dirname(dirname(dirname(__FILE__)));
require_once $root . '/scripts/__init_script__.php';
require_once $root . '/externals/mimemailparser/MimeMailParser.class.php';
$args = new PhutilArgumentParser($argv);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'process-duplicates', 'help' => pht("Process this message, even if it's a duplicate of another message. " . "This is mostly useful when debugging issues with mail routing.")), array('name' => 'env', 'wildcard' => true)));
$parser = new MimeMailParser();
$parser->setText(file_get_contents('php://stdin'));
$text_body = $parser->getMessageBody('text');
$text_body_headers = $parser->getMessageBodyHeaders('text');
$content_type = idx($text_body_headers, 'content-type');
if (!phutil_is_utf8($text_body) && (preg_match('/charset="(.*?)"/', $content_type, $matches) || preg_match('/charset=(\\S+)/', $content_type, $matches))) {
    $text_body = phutil_utf8_convert($text_body, 'UTF-8', $matches[1]);
}
$headers = $parser->getHeaders();
$headers['subject'] = iconv_mime_decode($headers['subject'], 0, 'UTF-8');
$headers['from'] = iconv_mime_decode($headers['from'], 0, 'UTF-8');
if ($args->getArg('process-duplicates')) {
    $headers['message-id'] = Filesystem::readRandomCharacters(64);
}
$received = new PhabricatorMetaMTAReceivedMail();
 /**
  * @task pull
  */
 public function run()
 {
     $argv = $this->getArgv();
     array_unshift($argv, __CLASS__);
     $args = new PhutilArgumentParser($argv);
     $args->parse(array(array('name' => 'no-discovery', 'help' => 'Pull only, without discovering commits.'), array('name' => 'not', 'param' => 'repository', 'repeat' => true, 'help' => 'Do not pull __repository__.'), array('name' => 'repositories', 'wildcard' => true, 'help' => 'Pull specific __repositories__ instead of all.')));
     $no_discovery = $args->getArg('no-discovery');
     $repo_names = $args->getArg('repositories');
     $exclude_names = $args->getArg('not');
     // Each repository has an individual pull frequency; after we pull it,
     // wait that long to pull it again. When we start up, try to pull everything
     // serially.
     $retry_after = array();
     $min_sleep = 15;
     while (true) {
         $repositories = $this->loadRepositories($repo_names);
         if ($exclude_names) {
             $exclude = $this->loadRepositories($exclude_names);
             $repositories = array_diff_key($repositories, $exclude);
         }
         // Shuffle the repositories, then re-key the array since shuffle()
         // discards keys. This is mostly for startup, we'll use soft priorities
         // later.
         shuffle($repositories);
         $repositories = mpull($repositories, null, 'getID');
         // If any repositories were deleted, remove them from the retry timer map
         // so we don't end up with a retry timer that never gets updated and
         // causes us to sleep for the minimum amount of time.
         $retry_after = array_select_keys($retry_after, array_keys($repositories));
         // Assign soft priorities to repositories based on how frequently they
         // should pull again.
         asort($retry_after);
         $repositories = array_select_keys($repositories, array_keys($retry_after)) + $repositories;
         foreach ($repositories as $id => $repository) {
             $after = idx($retry_after, $id, 0);
             if ($after > time()) {
                 continue;
             }
             $tracked = $repository->isTracked();
             if (!$tracked) {
                 continue;
             }
             try {
                 $callsign = $repository->getCallsign();
                 $this->log("Updating repository '{$callsign}'.");
                 $this->pullRepository($repository);
                 if (!$no_discovery) {
                     // TODO: It would be nice to discover only if we pulled something,
                     // but this isn't totally trivial.
                     $lock_name = get_class($this) . ':' . $callsign;
                     $lock = PhabricatorGlobalLock::newLock($lock_name);
                     $lock->lock();
                     try {
                         $this->discoverRepository($repository);
                     } catch (Exception $ex) {
                         $lock->unlock();
                         throw $ex;
                     }
                     $lock->unlock();
                 }
                 $sleep_for = $repository->getDetail('pull-frequency', $min_sleep);
                 $retry_after[$id] = time() + $sleep_for;
             } catch (PhutilLockException $ex) {
                 $retry_after[$id] = time() + $min_sleep;
                 $this->log("Failed to acquire lock.");
             } catch (Exception $ex) {
                 $retry_after[$id] = time() + $min_sleep;
                 phlog($ex);
             }
             $this->stillWorking();
         }
         if ($retry_after) {
             $sleep_until = max(min($retry_after), time() + $min_sleep);
         } else {
             $sleep_until = time() + $min_sleep;
         }
         $this->sleep($sleep_until - time());
     }
 }
#!/usr/bin/env php
<?php 
require_once dirname(__FILE__) . '/../__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline(pht('edit directory fixtures'));
$args->setSynopsis(<<<EOHELP
**directory_fixture.php** __file__ --create
  Create a new directory fixture.

**directory_fixture.php** __file__
  Edit an existing directory fixture.

EOHELP
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'create', 'help' => pht('Create a new fixture.')), array('name' => 'read-only', 'help' => pht('Do not save changes made to the fixture.')), array('name' => 'files', 'wildcard' => true)));
$is_create = $args->getArg('create');
$is_read_only = $args->getArg('read-only');
$console = PhutilConsole::getConsole();
$files = $args->getArg('files');
if (count($files) !== 1) {
    throw new PhutilArgumentUsageException(pht('Specify exactly one file to create or edit.'));
}
$file = head($files);
if ($is_create) {
    if (Filesystem::pathExists($file)) {
        throw new PhutilArgumentUsageException(pht('File "%s" already exists, so you can not %s it.', $file, '--create'));
    }
    $fixture = PhutilDirectoryFixture::newEmptyFixture();
} else {
    if (!Filesystem::pathExists($file)) {
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
$root = dirname(dirname(dirname(__FILE__)));
require_once $root . '/scripts/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setSynopsis(<<<EOSYNOPSIS
**import_project_symbols.php** [__options__] __project_name__ < symbols

  Import project symbols (symbols are read from stdin).
EOSYNOPSIS
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'no-purge', 'help' => 'Do not clear all symbols for this project before ' . 'uploading new symbols. Useful for incremental updating.'), array('name' => 'more', 'wildcard' => true)));
$more = $args->getArg('more');
if (count($more) !== 1) {
    $args->printHelpAndExit();
}
$project_name = head($more);
$project = id(new PhabricatorRepositoryArcanistProject())->loadOneWhere('name = %s', $project_name);
if (!$project) {
    // TODO: Provide a less silly way to do this explicitly, or just do it right
    // here.
    echo "Project '{$project_name}' is unknown. Upload a diff to implicitly " . "create it.\n";
    exit(1);
}
echo "Parsing input from stdin...\n";
$input = file_get_contents('php://stdin');
$input = trim($input);
#!/usr/bin/env php
<?php 
$root = dirname(dirname(dirname(__FILE__)));
require_once $root . '/scripts/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setSynopsis(<<<EOSYNOPSIS
**clear_repository_symbols.php** [__options__] __repository__

  Clear repository symbols.
EOSYNOPSIS
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'repository', 'wildcard' => true)));
$identifiers = $args->getArg('repository');
if (count($identifiers) !== 1) {
    $args->printHelpAndExit();
}
$identifier = head($identifiers);
$repository = id(new PhabricatorRepositoryQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withIdentifiers($identifiers)->executeOne();
if (!$repository) {
    echo tsprintf("%s\n", pht('Repository "%s" does not exist.', $identifier));
    exit(1);
}
$input = file_get_contents('php://stdin');
$normalized = array();
foreach (explode("\n", trim($input)) as $path) {
    // Emulate the behavior of the symbol generation scripts.
    $normalized[] = '/' . ltrim($path, './');
}
$paths = PhabricatorRepositoryCommitChangeParserWorker::lookupOrCreatePaths($normalized);
$symbol = new PhabricatorRepositorySymbol();
Exemple #16
0
#!/usr/bin/env php
<?php 
require_once dirname(dirname(__FILE__)) . '/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline('acquire and hold a lockfile');
$args->setSynopsis(<<<EOHELP
**lock.php** __file__ [__options__]
    Acquire a lockfile and hold it until told to unlock it.

EOHELP
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'test', 'help' => 'Instead of holding the lock, release it and exit.'), array('name' => 'hold', 'help' => 'Hold indefinitely without prompting.'), array('name' => 'wait', 'param' => 'n', 'help' => 'Block for up to __n__ seconds waiting for the lock.', 'default' => 0), array('name' => 'file', 'wildcard' => true)));
$file = $args->getArg('file');
if (count($file) != 1) {
    $args->printHelpAndExit();
}
$file = head($file);
$console = PhutilConsole::getConsole();
$console->writeOut("This process has PID %d. Acquiring lock...\n", getmypid());
$lock = PhutilFileLock::newForPath($file);
try {
    $lock->lock($args->getArg('wait'));
} catch (PhutilFileLockException $ex) {
    $console->writeOut("**UNABLE TO ACQUIRE LOCK:** Lock is already held.\n");
    exit(1);
}
// NOTE: This string is magic, the unit tests look for it.
$console->writeOut("LOCK ACQUIRED\n");
if ($args->getArg('test')) {
    $lock->unlock();
<?php 
require_once dirname(__FILE__) . '/../../__init_script__.php';
if (!posix_isatty(STDOUT)) {
    $sid = posix_setsid();
    if ($sid <= 0) {
        throw new Exception(pht('Failed to create new process session!'));
    }
}
$args = new PhutilArgumentParser($argv);
$args->setTagline(pht('daemon executor'));
$args->setSynopsis(<<<EOHELP
**exec_daemon.php** [__options__] __daemon__ ...
    Run an instance of __daemon__.
EOHELP
);
$args->parse(array(array('name' => 'trace', 'help' => pht('Enable debug tracing.')), array('name' => 'trace-memory', 'help' => pht('Enable debug memory tracing.')), array('name' => 'verbose', 'help' => pht('Enable verbose activity logging.')), array('name' => 'label', 'short' => 'l', 'param' => 'label', 'help' => pht('Optional process label. Makes "%s" nicer, no behavioral effects.', 'ps')), array('name' => 'daemon', 'wildcard' => true)));
$trace_memory = $args->getArg('trace-memory');
$trace_mode = $args->getArg('trace') || $trace_memory;
$verbose = $args->getArg('verbose');
if (function_exists('posix_isatty') && posix_isatty(STDIN)) {
    fprintf(STDERR, pht('Reading daemon configuration from stdin...') . "\n");
}
$config = @file_get_contents('php://stdin');
$config = id(new PhutilJSONParser())->parse($config);
PhutilTypeSpec::checkMap($config, array('log' => 'optional string|null', 'argv' => 'optional list<wild>', 'load' => 'optional list<string>', 'autoscale' => 'optional wild'));
$log = idx($config, 'log');
if ($log) {
    ini_set('error_log', $log);
    PhutilErrorHandler::setErrorListener(array('PhutilDaemon', 'errorListener'));
}
$load = idx($config, 'load', array());
#!/usr/bin/env php
<?php 
$root = dirname(dirname(dirname(__FILE__)));
require_once $root . '/scripts/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setSynopsis(<<<EOSYNOPSIS
**clear_repository_symbols.php** [__options__] __callsign__

  Clear repository symbols.
EOSYNOPSIS
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'callsign', 'wildcard' => true)));
$callsigns = $args->getArg('callsign');
if (count($callsigns) !== 1) {
    $args->printHelpAndExit();
}
$callsign = head($callsigns);
$repository = id(new PhabricatorRepositoryQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withCallsigns($callsigns)->executeOne();
if (!$repository) {
    echo pht("Repository '%s' does not exist.", $callsign);
    exit(1);
}
$input = file_get_contents('php://stdin');
$normalized = array();
foreach (explode("\n", trim($input)) as $path) {
    // Emulate the behavior of the symbol generation scripts.
    $normalized[] = '/' . ltrim($path, './');
}
$paths = PhabricatorRepositoryCommitChangeParserWorker::lookupOrCreatePaths($normalized);
$symbol = new PhabricatorRepositorySymbol();
Exemple #19
0
#!/usr/bin/env php
<?php 
$root = dirname(dirname(dirname(__FILE__)));
require_once $root . '/scripts/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline(pht('load files as image macros'));
$args->setSynopsis(<<<EOHELP
**add_macro.php** __image__ [--as __name__]
    Add an image macro. This can be useful for importing a large number
    of macros.
EOHELP
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'as', 'param' => 'name', 'help' => pht('Use a specific name instead of the first part of the image name.')), array('name' => 'more', 'wildcard' => true)));
$more = $args->getArg('more');
if (count($more) !== 1) {
    $args->printHelpAndExit();
}
$path = head($more);
$data = Filesystem::readFile($path);
$name = $args->getArg('as');
if ($name === null) {
    $name = head(explode('.', basename($path)));
}
$existing = id(new PhabricatorFileImageMacro())->loadOneWhere('name = %s', $name);
if ($existing) {
    throw new Exception(pht("A macro already exists with the name '%s'!", $name));
}
$file = PhabricatorFile::newFromFileData($data, array('name' => basename($path), 'canCDN' => true));
$macro = id(new PhabricatorFileImageMacro())->setFilePHID($file->getPHID())->setName($name)->save();
$id = $file->getID();
Exemple #20
0
useful for debugging changes to Diffusion.

e.g. enqueue reparse owners in the TEST repo for all commits:
./reparse.php --all TEST --owners

e.g. do same but exclude before yesterday (local time):
./reparse.php --all TEST --owners --min-date yesterday
./reparse.php --all TEST --owners --min-date "today -1 day"

e.g. do same but exclude before 03/31/2013 (local time):
./reparse.php --all TEST --owners --min-date "03/31/2013"
EOHELP
);
$min_date_usage_examples = "Valid examples:\n" . "  'today', 'today 2pm', '-1 hour', '-2 hours', '-24 hours',\n" . "  'yesterday', 'today -1 day', 'yesterday 2pm', '2pm -1 day',\n" . "  'last Monday', 'last Monday 14:00', 'last Monday 2pm',\n" . "  '31 March 2013', '31 Mar', '03/31', '03/31/2013',\n" . "See __http://www.php.net/manual/en/datetime.formats.php__ for more.\n";
$args->parseStandardArguments();
$args->parse(array(array('name' => 'revision', 'wildcard' => true), array('name' => 'all', 'param' => 'callsign or phid', 'help' => 'Reparse all commits in the specified repository. This ' . 'mode queues parsers into the task queue; you must run ' . 'taskmasters to actually do the parses. Use with ' . '__--force-local__ to run the tasks locally instead of ' . 'with taskmasters.'), array('name' => 'min-date', 'param' => 'date', 'help' => 'Must be used with __--all__, this will exclude commits ' . 'which are earlier than __date__.' . "\n" . $min_date_usage_examples), array('name' => 'message', 'help' => 'Reparse commit messages.'), array('name' => 'change', 'help' => 'Reparse changes.'), array('name' => 'herald', 'help' => 'Reevaluate Herald rules (may send huge amounts of email!)'), array('name' => 'owners', 'help' => 'Reevaluate related commits for owners packages (may ' . 'delete existing relationship entries between your ' . 'package and some old commits!)'), array('name' => 'harbormaster', 'help' => 'EXPERIMENTAL. Execute Harbormaster.'), array('name' => 'force', 'short' => 'f', 'help' => 'Act noninteractively, without prompting.'), array('name' => 'force-local', 'help' => 'Only used with __--all__, use this to run the tasks ' . 'locally instead of deferring them to taskmaster daemons.')));
$all_from_repo = $args->getArg('all');
$reparse_message = $args->getArg('message');
$reparse_change = $args->getArg('change');
$reparse_herald = $args->getArg('herald');
$reparse_owners = $args->getArg('owners');
$reparse_harbormaster = $args->getArg('harbormaster');
$reparse_what = $args->getArg('revision');
$force = $args->getArg('force');
$force_local = $args->getArg('force-local');
$min_date = $args->getArg('min-date');
if (!$all_from_repo && !$reparse_what) {
    usage('Specify a commit or repository to reparse.');
}
if ($all_from_repo && $reparse_what) {
    $commits = implode(', ', $reparse_what);
#!/usr/bin/env php
<?php 
require_once dirname(dirname(__FILE__)) . '/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline('regenerate CSS sprite sheets');
$args->setSynopsis(<<<EOHELP
**sprites**
    Rebuild CSS sprite sheets.

EOHELP
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'force', 'help' => 'Force regeneration even if sources have not changed.')));
$root = dirname(phutil_get_library_root('phabricator'));
$webroot = $root . '/webroot/rsrc';
$webroot = Filesystem::readablePath($webroot);
$generator = new CeleritySpriteGenerator();
$sheets = array('menu' => $generator->buildMenuSheet(), 'apps' => $generator->buildAppsSheet(), 'conpherence' => $generator->buildConpherenceSheet(), 'apps-large' => $generator->buildAppsLargeSheet(), 'payments' => $generator->buildPaymentsSheet(), 'tokens' => $generator->buildTokenSheet(), 'docs' => $generator->buildDocsSheet(), 'gradient' => $generator->buildGradientSheet(), 'main-header' => $generator->buildMainHeaderSheet(), 'login' => $generator->buildLoginSheet(), 'projects' => $generator->buildProjectsSheet());
list($err) = exec_manual('optipng');
if ($err) {
    $have_optipng = false;
    echo phutil_console_format("<bg:red> WARNING </bg> `optipng` not found in PATH.\n" . "Sprites will not be optimized! Install `optipng`!\n");
} else {
    $have_optipng = true;
}
foreach ($sheets as $name => $sheet) {
    $sheet->setBasePath($root);
    $manifest_path = $root . '/resources/sprite/manifest/' . $name . '.json';
    if (!$args->getArg('force')) {
        if (Filesystem::pathExists($manifest_path)) {
            $data = Filesystem::readFile($manifest_path);
Exemple #22
0
#!/usr/bin/env php
<?php 
require_once dirname(__FILE__) . '/../__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline(pht('test console prompting'));
$args->setSynopsis(<<<EOHELP
**prompt.php** __options__
    Test console prompting.
EOHELP
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'history', 'param' => 'file', 'default' => '', 'help' => pht('Use specified history __file__.')), array('name' => 'prompt', 'param' => 'text', 'default' => pht('Enter some text:'), 'help' => pht('Change the prompt text to __text__.'))));
$result = phutil_console_prompt($args->getArg('prompt'), $args->getArg('history'));
$console = PhutilConsole::getConsole();
$console->writeOut("%s\n", pht('Input is: %s', $result));
    public function __construct(array $argv)
    {
        PhutilServiceProfiler::getInstance()->enableDiscardMode();
        $args = new PhutilArgumentParser($argv);
        $args->setTagline(pht('daemon overseer'));
        $args->setSynopsis(<<<EOHELP
**launch_daemon.php** [__options__] __daemon__
    Launch and oversee an instance of __daemon__.
EOHELP
);
        $args->parseStandardArguments();
        $args->parse(array(array('name' => 'trace-memory', 'help' => pht('Enable debug memory tracing.')), array('name' => 'verbose', 'help' => pht('Enable verbose activity logging.')), array('name' => 'label', 'short' => 'l', 'param' => 'label', 'help' => pht('Optional process label. Makes "%s" nicer, no behavioral effects.', 'ps'))));
        $argv = array();
        if ($args->getArg('trace')) {
            $this->traceMode = true;
            $argv[] = '--trace';
        }
        if ($args->getArg('trace-memory')) {
            $this->traceMode = true;
            $this->traceMemory = true;
            $argv[] = '--trace-memory';
        }
        $verbose = $args->getArg('verbose');
        if ($verbose) {
            $this->verbose = true;
            $argv[] = '--verbose';
        }
        $label = $args->getArg('label');
        if ($label) {
            $argv[] = '-l';
            $argv[] = $label;
        }
        $this->argv = $argv;
        if (function_exists('posix_isatty') && posix_isatty(STDIN)) {
            fprintf(STDERR, pht('Reading daemon configuration from stdin...') . "\n");
        }
        $config = @file_get_contents('php://stdin');
        $config = id(new PhutilJSONParser())->parse($config);
        $this->libraries = idx($config, 'load');
        $this->log = idx($config, 'log');
        $this->daemonize = idx($config, 'daemonize');
        $this->piddir = idx($config, 'piddir');
        $this->config = $config;
        if (self::$instance) {
            throw new Exception(pht('You may not instantiate more than one Overseer per process.'));
        }
        self::$instance = $this;
        $this->startEpoch = time();
        // Check this before we daemonize, since if it's an issue the child will
        // exit immediately.
        if ($this->piddir) {
            $dir = $this->piddir;
            try {
                Filesystem::assertWritable($dir);
            } catch (Exception $ex) {
                throw new Exception(pht("Specified daemon PID directory ('%s') does not exist or is " . "not writable by the daemon user!", $dir));
            }
        }
        if (!idx($config, 'daemons')) {
            throw new PhutilArgumentUsageException(pht('You must specify at least one daemon to start!'));
        }
        if ($this->log) {
            // NOTE: Now that we're committed to daemonizing, redirect the error
            // log if we have a `--log` parameter. Do this at the last moment
            // so as many setup issues as possible are surfaced.
            ini_set('error_log', $this->log);
        }
        if ($this->daemonize) {
            // We need to get rid of these or the daemon will hang when we TERM it
            // waiting for something to read the buffers. TODO: Learn how unix works.
            fclose(STDOUT);
            fclose(STDERR);
            ob_start();
            $pid = pcntl_fork();
            if ($pid === -1) {
                throw new Exception(pht('Unable to fork!'));
            } else {
                if ($pid) {
                    exit(0);
                }
            }
        }
        $this->modules = PhutilDaemonOverseerModule::getAllModules();
        pcntl_signal(SIGUSR2, array($this, 'didReceiveNotifySignal'));
        pcntl_signal(SIGHUP, array($this, 'didReceiveReloadSignal'));
        pcntl_signal(SIGINT, array($this, 'didReceiveGracefulSignal'));
        pcntl_signal(SIGTERM, array($this, 'didReceiveTerminalSignal'));
    }
Exemple #24
0
 * limitations under the License.
 */
$root = dirname(dirname(dirname(__FILE__)));
require_once $root . '/scripts/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline('manage open Audit requests');
$args->setSynopsis(<<<EOSYNOPSIS
**audit.php** __repository_callsign__
    Close all open audit requests in a repository. This is intended to
    reset the state of an imported repository which triggered a bunch of
    spurious audit requests during import.

EOSYNOPSIS
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'more', 'wildcard' => true)));
$more = $args->getArg('more');
if (count($more) !== 1) {
    $args->printHelpAndExit();
}
$callsign = reset($more);
$repository = id(new PhabricatorRepository())->loadOneWhere('callsign = %s', $callsign);
if (!$repository) {
    throw new Exception("No repository exists with callsign '{$callsign}'!");
}
$ok = phutil_console_confirm('This will reset all open audit requests ("Audit Required" or "Concern ' . 'Raised") for commits in this repository to "Audit Not Required". This ' . 'operation destroys information and can not be undone! Are you sure ' . 'you want to proceed?');
if (!$ok) {
    echo "OK, aborting.\n";
    die(1);
}
echo "Loading commits...\n";
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
require_once dirname(dirname(__FILE__)) . '/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline('regenerate CSS sprite sheets');
$args->setSynopsis(<<<EOHELP
**sprites**
    Rebuild CSS sprite sheets.

EOHELP
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'source', 'param' => 'directory', 'help' => 'Directory with sprite sources.')));
$srcroot = $args->getArg('source');
if (!$srcroot) {
    throw new Exception("You must specify a source directory with '--source'.");
}
$webroot = dirname(phutil_get_library_root('phabricator')) . '/webroot/rsrc';
$webroot = Filesystem::readablePath($webroot);
function glx($x)
{
    return 60 + 48 * $x;
}
function gly($y)
{
    return 110 + 48 * $y;
}
$sheet = new PhutilSpriteSheet();
#!/usr/bin/env php
<?php 
require_once dirname(__FILE__) . '/__init_script__.php';
require_once dirname(__FILE__) . '/lib/PhutilLibraryMapBuilder.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline('rebuild the library map file');
$args->setSynopsis(<<<EOHELP
    **phutil_rebuild_map.php** [__options__] __root__
        Rebuild the library map file for a libphutil library.

EOHELP
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'quiet', 'help' => 'Do not write status messages to stderr.'), array('name' => 'drop-cache', 'help' => 'Drop the symbol cache and rebuild the entire map from ' . 'scratch.'), array('name' => 'limit', 'param' => 'N', 'default' => 8, 'help' => 'Controls the number of symbol mapper subprocesses run ' . 'at once. Defaults to 8.'), array('name' => 'show', 'help' => 'Print symbol map to stdout instead of writing it to the ' . 'map file.'), array('name' => 'ugly', 'help' => 'Use faster but less readable serialization for --show.'), array('name' => 'root', 'wildcard' => true)));
$root = $args->getArg('root');
if (count($root) !== 1) {
    throw new Exception("Provide exactly one library root!");
}
$root = Filesystem::resolvePath(head($root));
$builder = new PhutilLibraryMapBuilder($root);
$builder->setQuiet($args->getArg('quiet'));
$builder->setSubprocessLimit($args->getArg('limit'));
if ($args->getArg('drop-cache')) {
    $builder->dropSymbolCache();
}
if ($args->getArg('show')) {
    $builder->setShowMap(true);
    $builder->setUgly($args->getArg('ugly'));
}
$builder->buildMap();
exit(0);
#!/usr/bin/env php
<?php 
$root = dirname(dirname(dirname(__FILE__)));
require_once $root . '/scripts/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline('test InteractiveEditor class');
$args->setSynopsis(<<<EOHELP
**interactive_editor.php** [__options__]
    Edit some content via the InteractiveEditor class. This script
    makes it easier to test changes to InteractiveEditor, which is
    difficult to unit test.
EOHELP
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'fallback', 'param' => 'editor', 'help' => 'Set the fallback editor.'), array('name' => 'line', 'short' => 'l', 'param' => 'number', 'help' => 'Open at line number __number__.'), array('name' => 'name', 'param' => 'filename', 'help' => 'Set edited file name.')));
if ($args->getArg('help')) {
    $args->printHelpAndExit();
}
$editor = new PhutilInteractiveEditor("The wizard quickly\n" . "jinxed the gnomes\n" . "before they vaporized.");
$name = $args->getArg('name');
if ($name) {
    $editor->setName($name);
}
$line = $args->getArg('line');
if ($line) {
    $editor->setLineOffset($line);
}
$fallback = $args->getArg('fallback');
if ($fallback) {
    $editor->setFallbackEditor($fallback);
}
Exemple #28
0
#!/usr/bin/env php
<?php 
$root = dirname(dirname(dirname(__FILE__)));
require_once $root . '/scripts/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline('test Filesystem::getMimeType()');
$args->setSynopsis(<<<EOHELP
**mime.php** [__options__] __file__
    Determine the mime type of a file.
EOHELP
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'default', 'param' => 'mimetype', 'help' => 'Use __mimetype__ as default instead of builtin default.'), array('name' => 'file', 'wildcard' => true)));
$file = $args->getArg('file');
if (count($file) !== 1) {
    $args->printHelpAndExit();
}
$file = reset($file);
$default = $args->getArg('default');
if ($default) {
    echo Filesystem::getMimeType($file, $default) . "\n";
} else {
    echo Filesystem::getMimeType($file) . "\n";
}
#!/usr/bin/env php
<?php 
$root = dirname(dirname(dirname(__FILE__)));
require_once $root . '/scripts/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline(pht('emit a test event'));
$args->setSynopsis(<<<EOHELP
**emit_test_event.php** [--listen listener] ...
  Emit a test event after installing any specified __listener__s.
EOHELP
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'listen', 'param' => 'listener', 'repeat' => true)));
$console = PhutilConsole::getConsole();
foreach ($args->getArg('listen') as $listener) {
    $console->writeOut("%s\n", pht("Installing '%s'...", $listener));
    newv($listener, array())->register();
}
$console->writeOut("%s\n", pht('Emitting event...'));
PhutilEventEngine::dispatchEvent(new PhabricatorEvent(PhabricatorEventType::TYPE_TEST_DIDRUNTEST, array('time' => time())));
$console->writeOut("%s\n", pht('Done.'));
exit(0);
Exemple #30
0
    have, you can pipe in all the commit hashes to this script to
    "undo" the damage in Differential after you revert the commits.

    To use this script:

      1. Identify the commits you want to undo the effects of.
      2. Put all their identifiers (commit hashes in git/hg, revision
         numbers in svn) into a file, one per line.
      3. Pipe that file into this script with relevant arguments.
      4. Revisions marked "committed" by those commits will be
         restored to their previous state.

EOSYNOPSIS
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'repository', 'param' => 'callsign', 'help' => 'Callsign for the repository these commits appear in.')));
$callsign = $args->getArg('repository');
if (!$callsign) {
    $args->printHelpAndExit();
}
$repository = id(new PhabricatorRepository())->loadOneWhere('callsign = %s', $callsign);
if (!$repository) {
    throw new Exception("No repository with callsign '{$callsign}'!");
}
echo "Reading commit identifiers from stdin...\n";
$identifiers = @file_get_contents('php://stdin');
$identifiers = trim($identifiers);
$identifiers = explode("\n", $identifiers);
echo "Read " . count($identifiers) . " commit identifiers.\n";
if (!$identifiers) {
    throw new Exception("You must provide commmit identifiers on stdin!");