Skip to content

Commit 470057c

Browse files
author
Alan Huang
committedAug 16, 2012
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
1 parent 627584f commit 470057c

File tree

2 files changed

+61
-6
lines changed

2 files changed

+61
-6
lines changed
 
+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
}

‎scripts/symbols/import_project_symbols.php

+13-6
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030
$args->parseStandardArguments();
3131
$args->parse(
3232
array(
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+
),
3338
array(
3439
'name' => 'more',
3540
'wildcard' => true,
@@ -151,12 +156,14 @@
151156
$path_map[$dict['path']]);
152157
}
153158

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+
}
160167

161168
echo "Loading ".number_format(count($sql))." symbols...\n";
162169
foreach (array_chunk($sql, 128) as $chunk) {

0 commit comments

Comments
 (0)
Failed to load comments.