@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Support limiting symbol deletion to certain paths

Summary:
For Nefarious Facebook Internal Purposes, which may or may not
include incremental symbol database updates.

Give the import script an option to not clear all symbols from the
project, and make a new script that clears only symbols from paths given
on stdin.

(I'm not yet sure how much of the NFIPs is going to be ported over
here. So there might be a future diff that uses this. Conversely,
since there's no real use case out here, I'm fine just moving this to
the Facebook configuration if necessary.)

Test Plan: Run scripts in innumerable bizarre and eldritch configurations.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T1602

Differential Revision: https://secure.phabricator.com/D3305

+61 -6
+48
scripts/symbols/clear_project_symbols.php
··· 1 + #!/usr/bin/env php 2 + <?php 3 + 4 + /* 5 + * Copyright 2012 Facebook, Inc. 6 + * 7 + * Licensed under the Apache License, Version 2.0 (the "License"); 8 + * you may not use this file except in compliance with the License. 9 + * You may obtain a copy of the License at 10 + * 11 + * http://www.apache.org/licenses/LICENSE-2.0 12 + * 13 + * Unless required by applicable law or agreed to in writing, software 14 + * distributed under the License is distributed on an "AS IS" BASIS, 15 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 + * See the License for the specific language governing permissions and 17 + * limitations under the License. 18 + */ 19 + 20 + $root = dirname(dirname(dirname(__FILE__))); 21 + require_once $root.'/scripts/__init_script__.php'; 22 + 23 + $project = id(new PhabricatorRepositoryArcanistProject())->loadOneWhere( 24 + 'name = %s', $argv[1]); 25 + if (!$project) { 26 + throw new Exception('No such arcanist project.'); 27 + } 28 + 29 + $input = file_get_contents('php://stdin'); 30 + $normalized = array(); 31 + foreach (explode("\n", trim($input)) as $path) { 32 + // emulate the behavior of the symbol generation scripts 33 + $normalized[] = '/'.ltrim($path, './'); 34 + } 35 + $paths = PhabricatorRepositoryCommitChangeParserWorker::lookupOrCreatePaths( 36 + $normalized); 37 + 38 + $symbol = new PhabricatorRepositorySymbol(); 39 + $conn_w = $symbol->establishConnection('w'); 40 + 41 + foreach (array_chunk(array_values($paths), 128) as $chunk) { 42 + queryfx( 43 + $conn_w, 44 + 'DELETE FROM %T WHERE arcanistProjectID = %d AND pathID IN (%Ld)', 45 + $symbol->getTableName(), 46 + $project->getID(), 47 + $chunk); 48 + }
+13 -6
scripts/symbols/import_project_symbols.php
··· 31 31 $args->parse( 32 32 array( 33 33 array( 34 + 'name' => 'no-purge', 35 + 'help' => 'Do not clear all symbols for this project before '. 36 + 'uploading new symbols. Useful for incremental updating.', 37 + ), 38 + array( 34 39 'name' => 'more', 35 40 'wildcard' => true, 36 41 ), ··· 151 156 $path_map[$dict['path']]); 152 157 } 153 158 154 - echo "Purging old symbols...\n"; 155 - queryfx( 156 - $conn_w, 157 - 'DELETE FROM %T WHERE arcanistProjectID = %d', 158 - $symbol->getTableName(), 159 - $project->getID()); 159 + if (!$args->getArg('no-purge')) { 160 + echo "Purging old symbols...\n"; 161 + queryfx( 162 + $conn_w, 163 + 'DELETE FROM %T WHERE arcanistProjectID = %d', 164 + $symbol->getTableName(), 165 + $project->getID()); 166 + } 160 167 161 168 echo "Loading ".number_format(count($sql))." symbols...\n"; 162 169 foreach (array_chunk($sql, 128) as $chunk) {