4 $root = dirname(dirname(dirname(__FILE__
)));
5 require_once $root.'/scripts/__init_script__.php';
7 $args = new PhutilArgumentParser($argv);
8 $args->setSynopsis(<<<EOSYNOPSIS
9 **clear_repository_symbols.php** [__options__] __repository__
11 Clear repository symbols.
14 $args->parseStandardArguments();
18 'name' => 'repository',
23 $identifiers = $args->getArg('repository');
24 if (count($identifiers) !== 1) {
25 $args->printHelpAndExit();
28 $identifier = head($identifiers);
29 $repository = id(new PhabricatorRepositoryQuery())
30 ->setViewer(PhabricatorUser
::getOmnipotentUser())
31 ->withIdentifiers($identifiers)
37 pht('Repository "%s" does not exist.', $identifier));
41 $input = file_get_contents('php://stdin');
42 $normalized = array();
43 foreach (explode("\n", trim($input)) as $path) {
44 // Emulate the behavior of the symbol generation scripts.
45 $normalized[] = '/'.ltrim($path, './');
47 $paths = PhabricatorRepositoryCommitChangeParserWorker
::lookupOrCreatePaths(
50 $symbol = new PhabricatorRepositorySymbol();
51 $conn_w = $symbol->establishConnection('w');
53 foreach (array_chunk(array_values($paths), 128) as $chunk) {
56 'DELETE FROM %T WHERE repositoryPHID = %s AND pathID IN (%Ld)',
57 $symbol->getTableName(),
58 $repository->getPHID(),