Index: trunk/extensions/CodeReview/svnImport.php |
— | — | @@ -1,183 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -$IP = getenv( 'MW_INSTALL_PATH' ); |
5 | | -if ( $IP === false ) { |
6 | | - $IP = dirname( __FILE__ ) . '/../..'; |
7 | | -} |
8 | | -require( "$IP/maintenance/Maintenance.php" ); |
9 | | - |
10 | | -class SvnImport extends Maintenance { |
11 | | - |
12 | | - /* Initialize various stuff to make this a useful command line script */ |
13 | | - public function __construct() { |
14 | | - parent::__construct(); |
15 | | - $this->mDescription = "Import revisions to Code Review from a Subversion repo"; |
16 | | - $this->addOption( 'precache', 'Pre-cache diffs for last N revisions. ' . |
17 | | - 'May be a positive integer, 0 (for none) or \'all\'. Default is 0', false, true ); |
18 | | - $this->addArg( 'repo', 'The name of the repo. Use \'all\' to import from all defined repos' ); |
19 | | - $this->addArg( 'start', "The revision to begin the import from. If not specified then " . |
20 | | - "it starts from the last repo imported to the wiki. Ignored if " . |
21 | | - "'all' is specified for <repo>", false ); |
22 | | - } |
23 | | - |
24 | | - public function execute() { |
25 | | - $cacheSize = 0; |
26 | | - if ( $this->hasOption( 'precache' ) ) { |
27 | | - $cacheSize = $this->getOption( 'precache' ); |
28 | | - if ( strtolower( $cacheSize ) !== "all" ) { |
29 | | - if ( preg_match( '/^\d+$/', $cacheSize ) ) { |
30 | | - $cacheSize = intval( $cacheSize ); |
31 | | - } else { |
32 | | - $this->error( "Invalid argument for --precache (must be a positive integer, 0 or 'all')", true ); |
33 | | - } |
34 | | - } |
35 | | - } |
36 | | - |
37 | | - $repo = $this->getArg( 0 ); |
38 | | - |
39 | | - if ( $repo == "all" ) { |
40 | | - $repoList = CodeRepository::getRepoList(); |
41 | | - foreach ( $repoList as $repoInfo ) { |
42 | | - $this->importRepo( $repoInfo->getName(), null, $cacheSize ); |
43 | | - } |
44 | | - } else { |
45 | | - $startRev = null; |
46 | | - if ( $this->hasArg( 1 ) ) { |
47 | | - $startRev = $this->getArg( 1 ); |
48 | | - } |
49 | | - $this->importRepo( $repo, $startRev, $cacheSize ); |
50 | | - } |
51 | | - } |
52 | | - |
53 | | - /** |
54 | | - * Import a repository in the local database. |
55 | | - * @param $repoName String Local name of repository |
56 | | - * @param $start Int Revision to begin the import from (Default: null, means last stored revision); |
57 | | - */ |
58 | | - private function importRepo( $repoName, $start = null, $cacheSize = 0 ) { |
59 | | - global $wgCodeReviewImportBatchSize; |
60 | | - static $adaptorReported = false; |
61 | | - |
62 | | - $repo = CodeRepository::newFromName( $repoName ); |
63 | | - |
64 | | - if ( !$repo ) { |
65 | | - $this->error( "Invalid repo $repoName" ); |
66 | | - return; |
67 | | - } |
68 | | - |
69 | | - $svn = SubversionAdaptor::newFromRepo( $repo->getPath() ); |
70 | | - if ( !$adaptorReported ) { |
71 | | - $this->output( "Using " . get_class($svn). " adaptor\n" ); |
72 | | - $adaptorReported = true; |
73 | | - } |
74 | | - |
75 | | - $this->output( "IMPORT FROM REPO: $repoName\n" ); |
76 | | - $lastStoredRev = $repo->getLastStoredRev(); |
77 | | - $this->output( "Last stored revision: $lastStoredRev\n" ); |
78 | | - |
79 | | - $chunkSize = $wgCodeReviewImportBatchSize; |
80 | | - |
81 | | - $startTime = microtime( true ); |
82 | | - $revCount = 0; |
83 | | - $start = ( $start !== null ) ? intval( $start ) : $lastStoredRev + 1; |
84 | | - |
85 | | - /* |
86 | | - * FIXME: when importing only a part of a repository, the given path |
87 | | - * might not have been created with revision 1. For example, the |
88 | | - * mediawiki '/trunk/phase3' got created with r1284. |
89 | | - */ |
90 | | - if ( $start > ( $lastStoredRev + 1 ) ) { |
91 | | - $this->error( "Invalid starting point. r{$start} is beyond last stored revision: r" . ($lastStoredRev + 1) ); |
92 | | - return; |
93 | | - } |
94 | | - |
95 | | - $this->output( "Syncing from r$start to HEAD...\n" ); |
96 | | - |
97 | | - if ( !$svn->canConnect() ) { |
98 | | - $this->error( "Unable to connect to repository." ); |
99 | | - return; |
100 | | - } |
101 | | - |
102 | | - while ( true ) { |
103 | | - $log = $svn->getLog( '', $start, $start + $chunkSize - 1 ); |
104 | | - if ( empty( $log ) ) { |
105 | | - # Repo seems to give a blank when max rev is invalid, which |
106 | | - # stops new revisions from being added. Try to avoid this |
107 | | - # by trying less at a time from the last point. |
108 | | - if ( $chunkSize <= 1 ) { |
109 | | - break; // done! |
110 | | - } |
111 | | - $chunkSize = max( 1, floor( $chunkSize / 4 ) ); |
112 | | - continue; |
113 | | - } else { |
114 | | - $start += $chunkSize; |
115 | | - } |
116 | | - if ( !is_array( $log ) ) { |
117 | | - var_dump( $log ); // @TODO: cleanup :) |
118 | | - $this->error( 'Log entry is not an array! See content above.', true ); |
119 | | - } |
120 | | - foreach ( $log as $data ) { |
121 | | - $revCount++; |
122 | | - $delta = microtime( true ) - $startTime; |
123 | | - $revSpeed = $revCount / $delta; |
124 | | - |
125 | | - $codeRev = CodeRevision::newFromSvn( $repo, $data ); |
126 | | - $codeRev->save(); |
127 | | - |
128 | | - $this->output( sprintf( "%d %s %s (%0.1f revs/sec)\n", |
129 | | - $codeRev->getId(), |
130 | | - wfTimestamp( TS_DB, $codeRev->getTimestamp() ), |
131 | | - $codeRev->getAuthor(), |
132 | | - $revSpeed ) ); |
133 | | - } |
134 | | - wfWaitForSlaves( 5 ); |
135 | | - } |
136 | | - |
137 | | - if ( $cacheSize !== 0 ) { |
138 | | - $dbw = wfGetDB( DB_MASTER ); |
139 | | - $options = array( 'ORDER BY' => 'cr_id DESC' ); |
140 | | - |
141 | | - if ( $cacheSize == "all" ) { |
142 | | - $this->output( "Pre-caching all uncached diffs...\n" ); |
143 | | - } else { |
144 | | - if ( $cacheSize == 1 ) { |
145 | | - $this->output( "Pre-caching the latest diff...\n" ); |
146 | | - } else { |
147 | | - $this->output( "Pre-caching the latest $cacheSize diffs...\n" ); |
148 | | - } |
149 | | - $options['LIMIT'] = $cacheSize; |
150 | | - } |
151 | | - |
152 | | - // Get all rows for this repository that don't already have a diff filled in. |
153 | | - // This is LIMITed according to the $cacheSize setting, above, so only the |
154 | | - // rows that we plan to pre-cache are returned. |
155 | | - // TODO: This was optimised in order to skip rows that already have a diff, |
156 | | - // which is mostly what is required, but there may be situations where |
157 | | - // you want to re-calculate diffs (e.g. if $wgCodeReviewMaxDiffPaths |
158 | | - // changes). If these situations arise we will either want to revert |
159 | | - // this behaviour, or add a --force flag or something. |
160 | | - $res = $dbw->select( 'code_rev', 'cr_id', |
161 | | - array( 'cr_repo_id' => $repo->getId(), 'cr_diff IS NULL OR cr_diff = ""' ), |
162 | | - __METHOD__, |
163 | | - $options |
164 | | - ); |
165 | | - foreach ( $res as $row ) { |
166 | | - $repo->getRevision( $row->cr_id ); |
167 | | - $diff = $repo->getDiff( $row->cr_id ); // trigger caching |
168 | | - $msg = "Diff r{$row->cr_id} "; |
169 | | - if ( is_integer( $diff ) ) { |
170 | | - $msg .= "Skipped: " . CodeRepository::getDiffErrorMessage( $diff ); |
171 | | - } else { |
172 | | - $msg .= "done"; |
173 | | - } |
174 | | - $this->output( $msg . "\n" ); |
175 | | - } |
176 | | - } else { |
177 | | - $this->output( "Pre-caching skipped.\n" ); |
178 | | - } |
179 | | - $this->output( "Done!\n" ); |
180 | | - } |
181 | | -} |
182 | | - |
183 | | -$maintClass = "SvnImport"; |
184 | | -require_once( DO_MAINTENANCE ); |
Index: trunk/extensions/CodeReview/bulkStatusUpdate.php |
— | — | @@ -1,83 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -$IP = getenv( 'MW_INSTALL_PATH' ); |
5 | | -if ( $IP === false ) { |
6 | | - $IP = dirname( __FILE__ ) . '/../..'; |
7 | | -} |
8 | | -require( "$IP/maintenance/Maintenance.php" ); |
9 | | - |
10 | | -class BulkStatusUpdate extends Maintenance { |
11 | | - |
12 | | - public function __construct() { |
13 | | - parent::__construct(); |
14 | | - $this->mDescription = "Updates a range of revisions to a specific status"; |
15 | | - $this->addArg( 'repo', 'The name of the repo. Cannot be all.' ); |
16 | | - $this->addArg( 'revisions', "The revisions to set status for. Format: start:end" ); |
17 | | - $this->addArg( 'status', "Code States: 'new', 'fixme', 'reverted', " |
18 | | - . "'resolved', 'ok', 'deferred', 'old'" ); |
19 | | - $this->addArg( 'user', "Username for whom to accredit the state changes to." . |
20 | | - "The User needs to have the 'codereview-set-status' right" ); |
21 | | - } |
22 | | - |
23 | | - public function execute() { |
24 | | - $repoName = $this->getArg( 0 ); |
25 | | - |
26 | | - if ( $repoName == "all" ) { |
27 | | - $this->error( "Cannot use the 'all' repo", true ); |
28 | | - } |
29 | | - |
30 | | - $repo = CodeRepository::newFromName( $repoName ); |
31 | | - if ( !$repo ) { |
32 | | - $this->error( "Repo '{$repoName}' is not a valid Repository", true ); |
33 | | - } |
34 | | - |
35 | | - $revisions = $this->getArg( 1 ); |
36 | | - if ( strpos( $revisions, ':' ) !== false ) { |
37 | | - $revisionVals = explode( ':', $revisions, 2 ); |
38 | | - } else { |
39 | | - $this->error( "Invalid revision range", true ); |
40 | | - } |
41 | | - |
42 | | - $start = intval( $revisionVals[0] ); |
43 | | - $end = intval( $revisionVals[1] ); |
44 | | - |
45 | | - $revisions = range( $start, $end ); |
46 | | - |
47 | | - $status = $this->getArg( 2 ); |
48 | | - |
49 | | - if ( !CodeRevision::isValidStatus( $status ) ) { |
50 | | - $this->error( "'{$status}' is not a valid status", true ); |
51 | | - } |
52 | | - |
53 | | - $username = $this->getArg( 3 ); |
54 | | - $user = User::newFromName( $username ); |
55 | | - |
56 | | - if ( !$user ) { |
57 | | - $this->error( "'{$username}' is not a valid username ", true ); |
58 | | - } |
59 | | - |
60 | | - if ( !$user->isAllowed( 'codereview-set-status' ) ) { |
61 | | - $this->error( "'{$username}' does not have the 'codereview-set-status' right", true ); |
62 | | - } |
63 | | - |
64 | | - $dbr = wfGetDB( DB_SLAVE ); |
65 | | - |
66 | | - $res = $dbr->select( 'code_rev', '*', array( 'cr_id' => $revisions, 'cr_repo_id' => $repo->getId() ), |
67 | | - __METHOD__ ); |
68 | | - |
69 | | - foreach ( $res as $row ) { |
70 | | - $rev = CodeRevision::newFromRow( $repo, $row ); |
71 | | - |
72 | | - if ( $rev && $rev->setStatus( $status, $user ) ) { |
73 | | - $this->output( "r{$row->cr_id} updated\n" ); |
74 | | - } else { |
75 | | - $this->output( "r{$row->cr_id} not updated\n" ); |
76 | | - } |
77 | | - } |
78 | | - |
79 | | - $this->output( "Done!\n" ); |
80 | | - } |
81 | | -} |
82 | | - |
83 | | -$maintClass = "BulkStatusUpdate"; |
84 | | -require_once( DO_MAINTENANCE ); |
Index: trunk/extensions/CodeReview/show_emails.php |
— | — | @@ -1,107 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -$IP = getenv( 'MW_INSTALL_PATH' ); |
5 | | -if( $IP === false ) { |
6 | | - $IP = dirname( __FILE__ ) . '/../..'; |
7 | | -} |
8 | | -require( "$IP/maintenance/Maintenance.php" ); |
9 | | - |
10 | | -class CodeReviewShowEmails extends Maintenance { |
11 | | - private $EmailData = array( |
12 | | - 'author' => 'Author', |
13 | | - 'repo' => 'Repository', |
14 | | - 'rev' => 'r88888', |
15 | | - 'URL' => 'http://www.example.org/CR/repo/r88888', |
16 | | - 'prevrev' => 'r52100', |
17 | | - 'prevURL' => 'http://www.example.org/CR/repo/r52100', |
18 | | - 'summary' => 'This is a patch to fix a nasty bug |
19 | | -This is not the best commit summary but should be enough to: |
20 | | -* display something |
21 | | -* get a rough idea of message formatting |
22 | | -* some other thing |
23 | | -Follow up r52100 |
24 | | -', |
25 | | - 'follow-up-summary' => 'Fix up r52100', |
26 | | - 'comment' => 'My comment is that this revision is obviously wrong. |
27 | | -You missed a lot of points there and need to revert or fix your code |
28 | | -', |
29 | | - 'oldstatus' => 'new', |
30 | | - 'newstatus' => 'fixme', |
31 | | - ); |
32 | | - |
33 | | - public function __construct() { |
34 | | - parent::__construct(); |
35 | | - $this->mDescription = "Show example emails for CodeReview"; |
36 | | - } |
37 | | - |
38 | | - public function execute() { |
39 | | - $this->printSubject( '' ); |
40 | | - print wfMsg( 'codereview-email-body' |
41 | | - , $this->EmailData['author'] |
42 | | - , $this->EmailData['URL'] |
43 | | - , $this->EmailData['rev'] |
44 | | - , $this->EmailData['comment'] |
45 | | - , $this->EmailData['summary'] |
46 | | - ) . "\n" ; |
47 | | - $this->printRule(); |
48 | | - |
49 | | - $this->printSubject( 2 ); |
50 | | - print wfMsg( 'codereview-email-body2' |
51 | | - , $this->EmailData['author'] |
52 | | - , $this->EmailData['prevrev'] |
53 | | - , $this->EmailData['URL'] |
54 | | - , $this->EmailData['follow-up-summary'] |
55 | | - , $this->EmailData['prevURL'] |
56 | | - , $this->EmailData['summary'] |
57 | | - ). "\n"; |
58 | | - $this->printRule(); |
59 | | - |
60 | | - $this->printSubject( 3 ); |
61 | | - print wfMsg( 'codereview-email-body3' |
62 | | - , $this->EmailData['author'] |
63 | | - , $this->EmailData['rev'] |
64 | | - , $this->EmailData['oldstatus'] |
65 | | - , $this->EmailData['newstatus'] |
66 | | - , $this->EmailData['URL'] |
67 | | - , $this->EmailData['summary'] |
68 | | - ). "\n"; |
69 | | - $this->printRule(); |
70 | | - |
71 | | - $this->printSubject( 4 ); |
72 | | - print wfMsg( 'codereview-email-body4' |
73 | | - , $this->EmailData['author'] |
74 | | - , $this->EmailData['rev'] |
75 | | - , $this->EmailData['oldstatus'] |
76 | | - , $this->EmailData['newstatus'] |
77 | | - , $this->EmailData['URL'] |
78 | | - , $this->EmailData['summary'] |
79 | | - , $this->EmailData['follow-up-summary'] |
80 | | - ). "\n"; |
81 | | - $this->printRule(); |
82 | | - } |
83 | | - |
84 | | - /** |
85 | | - * Print the subject line. |
86 | | - * @param $type Either '', 2, 3 or 4 |
87 | | - */ |
88 | | - function printSubject( $type ) { |
89 | | - $repo = $this->EmailData['repo']; |
90 | | - if( $type == 2 ) { |
91 | | - $rev = $this->EmailData['prevrev']; |
92 | | - } else { |
93 | | - $rev = $this->EmailData['rev']; |
94 | | - } |
95 | | - printf( "Subject: %s\n\n", |
96 | | - wfMsg( 'codereview-email-subj'.$type |
97 | | - , $repo |
98 | | - , $rev |
99 | | - ) |
100 | | - ); |
101 | | - } |
102 | | - function printRule() { |
103 | | - print "===============================================\n"; |
104 | | - } |
105 | | -} |
106 | | - |
107 | | -$maintClass = 'CodeReviewShowEmails'; |
108 | | -require_once( DO_MAINTENANCE ); |
Index: trunk/extensions/CodeReview/repopulateCodePaths.php |
— | — | @@ -1,66 +0,0 @@ |
2 | | -<?php |
3 | | -$IP = getenv( 'MW_INSTALL_PATH' ); |
4 | | -if ( $IP === false ) { |
5 | | - $IP = dirname( __FILE__ ) . '/../..'; |
6 | | -} |
7 | | -require( "$IP/maintenance/Maintenance.php" ); |
8 | | - |
9 | | -class RepopulateCodePaths extends Maintenance { |
10 | | - public function __construct() { |
11 | | - parent::__construct(); |
12 | | - $this->mDescription = "Rebuilds all code paths to support more efficient searching"; |
13 | | - $this->addArg( 'repo', 'The name of the repo. Cannot be all.' ); |
14 | | - $this->addArg( 'revisions', "The revisions to set status for. Format: start:end" ); |
15 | | - } |
16 | | - |
17 | | - public function execute() { |
18 | | - $repoName = $this->getArg( 0 ); |
19 | | - |
20 | | - if ( $repoName == "all" ) { |
21 | | - $this->error( "Cannot use the 'all' repo", true ); |
22 | | - } |
23 | | - |
24 | | - $repo = CodeRepository::newFromName( $repoName ); |
25 | | - if ( !$repo ) { |
26 | | - $this->error( "Repo '{$repoName}' is not a valid Repository", true ); |
27 | | - } |
28 | | - |
29 | | - $revisions = $this->getArg( 1 ); |
30 | | - if ( strpos( $revisions, ':' ) !== false ) { |
31 | | - $revisionVals = explode( ':', $revisions, 2 ); |
32 | | - } else { |
33 | | - $this->error( "Invalid revision range", true ); |
34 | | - } |
35 | | - |
36 | | - $start = intval( $revisionVals[0] ); |
37 | | - $end = intval( $revisionVals[1] ); |
38 | | - |
39 | | - $revisions = range( $start, $end ); |
40 | | - |
41 | | - $dbr = wfGetDB( DB_SLAVE ); |
42 | | - |
43 | | - $res = $dbr->select( 'code_paths', '*', array( 'cp_rev_id' => $revisions, 'cp_repo_id' => $repo->getId() ), |
44 | | - __METHOD__ ); |
45 | | - |
46 | | - $dbw = wfGetDB( DB_MASTER ); |
47 | | - $dbw->begin(); |
48 | | - |
49 | | - foreach ( $res as $row ) { |
50 | | - $fragments = CodeRevision::getPathFragments( |
51 | | - array( array( 'path' => $row->cp_path, 'action' => $row->cp_action ) ) |
52 | | - ); |
53 | | - |
54 | | - CodeRevision::insertPaths( $dbw, $fragments, $repo->getId(), $row->cp_rev_id ); |
55 | | - |
56 | | - $this->output( "r{$row->cp_rev_id}, path: " . $row->cp_path . " Fragments: " . |
57 | | - count( $fragments ) . "\n" ); |
58 | | - } |
59 | | - |
60 | | - $dbw->commit(); |
61 | | - |
62 | | - $this->output( "Done!\n" ); |
63 | | - } |
64 | | -} |
65 | | - |
66 | | -$maintClass = "RepopulateCodePaths"; |
67 | | -require_once( DO_MAINTENANCE ); |
Index: trunk/extensions/CodeReview/populateFollowupRevisions.php |
— | — | @@ -1,71 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -$IP = getenv( 'MW_INSTALL_PATH' ); |
5 | | -if ( $IP === false ) { |
6 | | - $IP = dirname( __FILE__ ) . '/../..'; |
7 | | -} |
8 | | -require( "$IP/maintenance/Maintenance.php" ); |
9 | | - |
10 | | -class PopulateFollowupRevisions extends Maintenance { |
11 | | - public function __construct() { |
12 | | - parent::__construct(); |
13 | | - $this->mDescription = "Populates followup revisions. Useful for setting them on old revisions, without reimporting"; |
14 | | - $this->addArg( 'repo', 'The name of the repo. Cannot be all.' ); |
15 | | - $this->addArg( 'revisions', "The revisions to set followups revisions for. Format: start:end" ); |
16 | | - $this->addOption( 'dry-run', 'Perform a dry run' ); |
17 | | - } |
18 | | - |
19 | | - public function execute() { |
20 | | - $repoName = $this->getArg( 0 ); |
21 | | - |
22 | | - if ( $repoName == "all" ) { |
23 | | - $this->error( "Cannot use the 'all' repo", true ); |
24 | | - } |
25 | | - |
26 | | - $repo = CodeRepository::newFromName( $repoName ); |
27 | | - if ( !$repo ) { |
28 | | - $this->error( "Repo '{$repoName}' is not a valid Repository", true ); |
29 | | - } |
30 | | - |
31 | | - $revisions = $this->getArg( 1 ); |
32 | | - if ( strpos( $revisions, ':' ) !== false ) { |
33 | | - $revisionVals = explode( ':', $revisions, 2 ); |
34 | | - } else { |
35 | | - $this->error( "Invalid revision range", true ); |
36 | | - } |
37 | | - |
38 | | - $start = intval( $revisionVals[0] ); |
39 | | - $end = intval( $revisionVals[1] ); |
40 | | - |
41 | | - $revisions = range( $start, $end ); |
42 | | - |
43 | | - $dryrun = $this->hasOption( 'dry-run' ); |
44 | | - |
45 | | - $dbr = wfGetDB( DB_SLAVE ); |
46 | | - |
47 | | - $res = $dbr->select( 'code_rev', '*', array( 'cr_id' => $revisions, 'cr_repo_id' => $repo->getId() ), |
48 | | - __METHOD__ ); |
49 | | - |
50 | | - foreach ( $res as $row ) { |
51 | | - $rev = CodeRevision::newFromRow( $repo, $row ); |
52 | | - |
53 | | - $affectedRevs = $rev->getUniqueAffectedRevs(); |
54 | | - |
55 | | - $this->output( "r{$row->cr_id}: " ); |
56 | | - |
57 | | - if ( count( $affectedRevs ) ) { |
58 | | - $this->output( "associating revs " . implode( ',', $affectedRevs ) . "\n" ); |
59 | | - |
60 | | - if ( !$dryrun ) { |
61 | | - $rev->addReferencesTo( $affectedRevs ); |
62 | | - } |
63 | | - } else { |
64 | | - $this->output( "no revisions followed up\n" ); |
65 | | - } |
66 | | - } |
67 | | - $this->output( "Done!\n" ); |
68 | | - } |
69 | | -} |
70 | | - |
71 | | -$maintClass = "PopulateFollowupRevisions"; |
72 | | -require_once( DO_MAINTENANCE ); |
\ No newline at end of file |
Index: trunk/extensions/CodeReview/deleteBadTags.php |
— | — | @@ -1,22 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -$IP = getenv( 'MW_INSTALL_PATH' ); |
5 | | -if ( $IP === false ) |
6 | | - $IP = dirname( __FILE__ ) . '/../..'; |
7 | | -require "$IP/maintenance/commandLine.inc"; |
8 | | - |
9 | | -echo "Usage: php deleteBadTags.php [commit]\n"; |
10 | | - |
11 | | -echo "Deleting empty tags...\n"; |
12 | | - |
13 | | -$dbw = wfGetDB( DB_MASTER ); |
14 | | -$dbw->begin(); |
15 | | -$dbw->delete( 'code_tags', array('ct_tag' => ''), __METHOD__ ); |
16 | | -$count = $dbw->affectedRows(); |
17 | | -if( isset($args[0]) && $args[0] == 'commit' ) { |
18 | | - $dbw->commit(); |
19 | | - echo "$count bad tags deleted. Done!\n"; |
20 | | -} else { |
21 | | - $dbw->rollback(); |
22 | | - echo "$count bad tags. Not commited!\n"; |
23 | | -} |
Index: trunk/extensions/CodeReview/maintenance/repopulateCodePaths.php |
— | — | @@ -0,0 +1,66 @@ |
| 2 | +<?php |
| 3 | +$IP = getenv( 'MW_INSTALL_PATH' ); |
| 4 | +if ( $IP === false ) { |
| 5 | + $IP = dirname( __FILE__ ) . '/../..'; |
| 6 | +} |
| 7 | +require( "$IP/maintenance/Maintenance.php" ); |
| 8 | + |
| 9 | +class RepopulateCodePaths extends Maintenance { |
| 10 | + public function __construct() { |
| 11 | + parent::__construct(); |
| 12 | + $this->mDescription = "Rebuilds all code paths to support more efficient searching"; |
| 13 | + $this->addArg( 'repo', 'The name of the repo. Cannot be all.' ); |
| 14 | + $this->addArg( 'revisions', "The revisions to set status for. Format: start:end" ); |
| 15 | + } |
| 16 | + |
| 17 | + public function execute() { |
| 18 | + $repoName = $this->getArg( 0 ); |
| 19 | + |
| 20 | + if ( $repoName == "all" ) { |
| 21 | + $this->error( "Cannot use the 'all' repo", true ); |
| 22 | + } |
| 23 | + |
| 24 | + $repo = CodeRepository::newFromName( $repoName ); |
| 25 | + if ( !$repo ) { |
| 26 | + $this->error( "Repo '{$repoName}' is not a valid Repository", true ); |
| 27 | + } |
| 28 | + |
| 29 | + $revisions = $this->getArg( 1 ); |
| 30 | + if ( strpos( $revisions, ':' ) !== false ) { |
| 31 | + $revisionVals = explode( ':', $revisions, 2 ); |
| 32 | + } else { |
| 33 | + $this->error( "Invalid revision range", true ); |
| 34 | + } |
| 35 | + |
| 36 | + $start = intval( $revisionVals[0] ); |
| 37 | + $end = intval( $revisionVals[1] ); |
| 38 | + |
| 39 | + $revisions = range( $start, $end ); |
| 40 | + |
| 41 | + $dbr = wfGetDB( DB_SLAVE ); |
| 42 | + |
| 43 | + $res = $dbr->select( 'code_paths', '*', array( 'cp_rev_id' => $revisions, 'cp_repo_id' => $repo->getId() ), |
| 44 | + __METHOD__ ); |
| 45 | + |
| 46 | + $dbw = wfGetDB( DB_MASTER ); |
| 47 | + $dbw->begin(); |
| 48 | + |
| 49 | + foreach ( $res as $row ) { |
| 50 | + $fragments = CodeRevision::getPathFragments( |
| 51 | + array( array( 'path' => $row->cp_path, 'action' => $row->cp_action ) ) |
| 52 | + ); |
| 53 | + |
| 54 | + CodeRevision::insertPaths( $dbw, $fragments, $repo->getId(), $row->cp_rev_id ); |
| 55 | + |
| 56 | + $this->output( "r{$row->cp_rev_id}, path: " . $row->cp_path . " Fragments: " . |
| 57 | + count( $fragments ) . "\n" ); |
| 58 | + } |
| 59 | + |
| 60 | + $dbw->commit(); |
| 61 | + |
| 62 | + $this->output( "Done!\n" ); |
| 63 | + } |
| 64 | +} |
| 65 | + |
| 66 | +$maintClass = "RepopulateCodePaths"; |
| 67 | +require_once( DO_MAINTENANCE ); |
Property changes on: trunk/extensions/CodeReview/maintenance/repopulateCodePaths.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 68 | + native |
Index: trunk/extensions/CodeReview/maintenance/showEmails.php |
— | — | @@ -0,0 +1,107 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +$IP = getenv( 'MW_INSTALL_PATH' ); |
| 5 | +if( $IP === false ) { |
| 6 | + $IP = dirname( __FILE__ ) . '/../..'; |
| 7 | +} |
| 8 | +require( "$IP/maintenance/Maintenance.php" ); |
| 9 | + |
| 10 | +class CodeReviewShowEmails extends Maintenance { |
| 11 | + private $EmailData = array( |
| 12 | + 'author' => 'Author', |
| 13 | + 'repo' => 'Repository', |
| 14 | + 'rev' => 'r88888', |
| 15 | + 'URL' => 'http://www.example.org/CR/repo/r88888', |
| 16 | + 'prevrev' => 'r52100', |
| 17 | + 'prevURL' => 'http://www.example.org/CR/repo/r52100', |
| 18 | + 'summary' => 'This is a patch to fix a nasty bug |
| 19 | +This is not the best commit summary but should be enough to: |
| 20 | +* display something |
| 21 | +* get a rough idea of message formatting |
| 22 | +* some other thing |
| 23 | +Follow up r52100 |
| 24 | +', |
| 25 | + 'follow-up-summary' => 'Fix up r52100', |
| 26 | + 'comment' => 'My comment is that this revision is obviously wrong. |
| 27 | +You missed a lot of points there and need to revert or fix your code |
| 28 | +', |
| 29 | + 'oldstatus' => 'new', |
| 30 | + 'newstatus' => 'fixme', |
| 31 | + ); |
| 32 | + |
| 33 | + public function __construct() { |
| 34 | + parent::__construct(); |
| 35 | + $this->mDescription = "Show example emails for CodeReview"; |
| 36 | + } |
| 37 | + |
| 38 | + public function execute() { |
| 39 | + $this->printSubject( '' ); |
| 40 | + print wfMsg( 'codereview-email-body' |
| 41 | + , $this->EmailData['author'] |
| 42 | + , $this->EmailData['URL'] |
| 43 | + , $this->EmailData['rev'] |
| 44 | + , $this->EmailData['comment'] |
| 45 | + , $this->EmailData['summary'] |
| 46 | + ) . "\n" ; |
| 47 | + $this->printRule(); |
| 48 | + |
| 49 | + $this->printSubject( 2 ); |
| 50 | + print wfMsg( 'codereview-email-body2' |
| 51 | + , $this->EmailData['author'] |
| 52 | + , $this->EmailData['prevrev'] |
| 53 | + , $this->EmailData['URL'] |
| 54 | + , $this->EmailData['follow-up-summary'] |
| 55 | + , $this->EmailData['prevURL'] |
| 56 | + , $this->EmailData['summary'] |
| 57 | + ). "\n"; |
| 58 | + $this->printRule(); |
| 59 | + |
| 60 | + $this->printSubject( 3 ); |
| 61 | + print wfMsg( 'codereview-email-body3' |
| 62 | + , $this->EmailData['author'] |
| 63 | + , $this->EmailData['rev'] |
| 64 | + , $this->EmailData['oldstatus'] |
| 65 | + , $this->EmailData['newstatus'] |
| 66 | + , $this->EmailData['URL'] |
| 67 | + , $this->EmailData['summary'] |
| 68 | + ). "\n"; |
| 69 | + $this->printRule(); |
| 70 | + |
| 71 | + $this->printSubject( 4 ); |
| 72 | + print wfMsg( 'codereview-email-body4' |
| 73 | + , $this->EmailData['author'] |
| 74 | + , $this->EmailData['rev'] |
| 75 | + , $this->EmailData['oldstatus'] |
| 76 | + , $this->EmailData['newstatus'] |
| 77 | + , $this->EmailData['URL'] |
| 78 | + , $this->EmailData['summary'] |
| 79 | + , $this->EmailData['follow-up-summary'] |
| 80 | + ). "\n"; |
| 81 | + $this->printRule(); |
| 82 | + } |
| 83 | + |
| 84 | + /** |
| 85 | + * Print the subject line. |
| 86 | + * @param $type Either '', 2, 3 or 4 |
| 87 | + */ |
| 88 | + function printSubject( $type ) { |
| 89 | + $repo = $this->EmailData['repo']; |
| 90 | + if( $type == 2 ) { |
| 91 | + $rev = $this->EmailData['prevrev']; |
| 92 | + } else { |
| 93 | + $rev = $this->EmailData['rev']; |
| 94 | + } |
| 95 | + printf( "Subject: %s\n\n", |
| 96 | + wfMsg( 'codereview-email-subj'.$type |
| 97 | + , $repo |
| 98 | + , $rev |
| 99 | + ) |
| 100 | + ); |
| 101 | + } |
| 102 | + function printRule() { |
| 103 | + print "===============================================\n"; |
| 104 | + } |
| 105 | +} |
| 106 | + |
| 107 | +$maintClass = 'CodeReviewShowEmails'; |
| 108 | +require_once( DO_MAINTENANCE ); |
Property changes on: trunk/extensions/CodeReview/maintenance/showEmails.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 109 | + native |
Index: trunk/extensions/CodeReview/maintenance/svnImport.php |
— | — | @@ -0,0 +1,183 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +$IP = getenv( 'MW_INSTALL_PATH' ); |
| 5 | +if ( $IP === false ) { |
| 6 | + $IP = dirname( __FILE__ ) . '/../..'; |
| 7 | +} |
| 8 | +require( "$IP/maintenance/Maintenance.php" ); |
| 9 | + |
| 10 | +class SvnImport extends Maintenance { |
| 11 | + |
| 12 | + /* Initialize various stuff to make this a useful command line script */ |
| 13 | + public function __construct() { |
| 14 | + parent::__construct(); |
| 15 | + $this->mDescription = "Import revisions to Code Review from a Subversion repo"; |
| 16 | + $this->addOption( 'precache', 'Pre-cache diffs for last N revisions. ' . |
| 17 | + 'May be a positive integer, 0 (for none) or \'all\'. Default is 0', false, true ); |
| 18 | + $this->addArg( 'repo', 'The name of the repo. Use \'all\' to import from all defined repos' ); |
| 19 | + $this->addArg( 'start', "The revision to begin the import from. If not specified then " . |
| 20 | + "it starts from the last repo imported to the wiki. Ignored if " . |
| 21 | + "'all' is specified for <repo>", false ); |
| 22 | + } |
| 23 | + |
| 24 | + public function execute() { |
| 25 | + $cacheSize = 0; |
| 26 | + if ( $this->hasOption( 'precache' ) ) { |
| 27 | + $cacheSize = $this->getOption( 'precache' ); |
| 28 | + if ( strtolower( $cacheSize ) !== "all" ) { |
| 29 | + if ( preg_match( '/^\d+$/', $cacheSize ) ) { |
| 30 | + $cacheSize = intval( $cacheSize ); |
| 31 | + } else { |
| 32 | + $this->error( "Invalid argument for --precache (must be a positive integer, 0 or 'all')", true ); |
| 33 | + } |
| 34 | + } |
| 35 | + } |
| 36 | + |
| 37 | + $repo = $this->getArg( 0 ); |
| 38 | + |
| 39 | + if ( $repo == "all" ) { |
| 40 | + $repoList = CodeRepository::getRepoList(); |
| 41 | + foreach ( $repoList as $repoInfo ) { |
| 42 | + $this->importRepo( $repoInfo->getName(), null, $cacheSize ); |
| 43 | + } |
| 44 | + } else { |
| 45 | + $startRev = null; |
| 46 | + if ( $this->hasArg( 1 ) ) { |
| 47 | + $startRev = $this->getArg( 1 ); |
| 48 | + } |
| 49 | + $this->importRepo( $repo, $startRev, $cacheSize ); |
| 50 | + } |
| 51 | + } |
| 52 | + |
| 53 | + /** |
| 54 | + * Import a repository in the local database. |
| 55 | + * @param $repoName String Local name of repository |
| 56 | + * @param $start Int Revision to begin the import from (Default: null, means last stored revision); |
| 57 | + */ |
| 58 | + private function importRepo( $repoName, $start = null, $cacheSize = 0 ) { |
| 59 | + global $wgCodeReviewImportBatchSize; |
| 60 | + static $adaptorReported = false; |
| 61 | + |
| 62 | + $repo = CodeRepository::newFromName( $repoName ); |
| 63 | + |
| 64 | + if ( !$repo ) { |
| 65 | + $this->error( "Invalid repo $repoName" ); |
| 66 | + return; |
| 67 | + } |
| 68 | + |
| 69 | + $svn = SubversionAdaptor::newFromRepo( $repo->getPath() ); |
| 70 | + if ( !$adaptorReported ) { |
| 71 | + $this->output( "Using " . get_class($svn). " adaptor\n" ); |
| 72 | + $adaptorReported = true; |
| 73 | + } |
| 74 | + |
| 75 | + $this->output( "IMPORT FROM REPO: $repoName\n" ); |
| 76 | + $lastStoredRev = $repo->getLastStoredRev(); |
| 77 | + $this->output( "Last stored revision: $lastStoredRev\n" ); |
| 78 | + |
| 79 | + $chunkSize = $wgCodeReviewImportBatchSize; |
| 80 | + |
| 81 | + $startTime = microtime( true ); |
| 82 | + $revCount = 0; |
| 83 | + $start = ( $start !== null ) ? intval( $start ) : $lastStoredRev + 1; |
| 84 | + |
| 85 | + /* |
| 86 | + * FIXME: when importing only a part of a repository, the given path |
| 87 | + * might not have been created with revision 1. For example, the |
| 88 | + * mediawiki '/trunk/phase3' got created with r1284. |
| 89 | + */ |
| 90 | + if ( $start > ( $lastStoredRev + 1 ) ) { |
| 91 | + $this->error( "Invalid starting point. r{$start} is beyond last stored revision: r" . ($lastStoredRev + 1) ); |
| 92 | + return; |
| 93 | + } |
| 94 | + |
| 95 | + $this->output( "Syncing from r$start to HEAD...\n" ); |
| 96 | + |
| 97 | + if ( !$svn->canConnect() ) { |
| 98 | + $this->error( "Unable to connect to repository." ); |
| 99 | + return; |
| 100 | + } |
| 101 | + |
| 102 | + while ( true ) { |
| 103 | + $log = $svn->getLog( '', $start, $start + $chunkSize - 1 ); |
| 104 | + if ( empty( $log ) ) { |
| 105 | + # Repo seems to give a blank when max rev is invalid, which |
| 106 | + # stops new revisions from being added. Try to avoid this |
| 107 | + # by trying less at a time from the last point. |
| 108 | + if ( $chunkSize <= 1 ) { |
| 109 | + break; // done! |
| 110 | + } |
| 111 | + $chunkSize = max( 1, floor( $chunkSize / 4 ) ); |
| 112 | + continue; |
| 113 | + } else { |
| 114 | + $start += $chunkSize; |
| 115 | + } |
| 116 | + if ( !is_array( $log ) ) { |
| 117 | + var_dump( $log ); // @TODO: cleanup :) |
| 118 | + $this->error( 'Log entry is not an array! See content above.', true ); |
| 119 | + } |
| 120 | + foreach ( $log as $data ) { |
| 121 | + $revCount++; |
| 122 | + $delta = microtime( true ) - $startTime; |
| 123 | + $revSpeed = $revCount / $delta; |
| 124 | + |
| 125 | + $codeRev = CodeRevision::newFromSvn( $repo, $data ); |
| 126 | + $codeRev->save(); |
| 127 | + |
| 128 | + $this->output( sprintf( "%d %s %s (%0.1f revs/sec)\n", |
| 129 | + $codeRev->getId(), |
| 130 | + wfTimestamp( TS_DB, $codeRev->getTimestamp() ), |
| 131 | + $codeRev->getAuthor(), |
| 132 | + $revSpeed ) ); |
| 133 | + } |
| 134 | + wfWaitForSlaves( 5 ); |
| 135 | + } |
| 136 | + |
| 137 | + if ( $cacheSize !== 0 ) { |
| 138 | + $dbw = wfGetDB( DB_MASTER ); |
| 139 | + $options = array( 'ORDER BY' => 'cr_id DESC' ); |
| 140 | + |
| 141 | + if ( $cacheSize == "all" ) { |
| 142 | + $this->output( "Pre-caching all uncached diffs...\n" ); |
| 143 | + } else { |
| 144 | + if ( $cacheSize == 1 ) { |
| 145 | + $this->output( "Pre-caching the latest diff...\n" ); |
| 146 | + } else { |
| 147 | + $this->output( "Pre-caching the latest $cacheSize diffs...\n" ); |
| 148 | + } |
| 149 | + $options['LIMIT'] = $cacheSize; |
| 150 | + } |
| 151 | + |
| 152 | + // Get all rows for this repository that don't already have a diff filled in. |
| 153 | + // This is LIMITed according to the $cacheSize setting, above, so only the |
| 154 | + // rows that we plan to pre-cache are returned. |
| 155 | + // TODO: This was optimised in order to skip rows that already have a diff, |
| 156 | + // which is mostly what is required, but there may be situations where |
| 157 | + // you want to re-calculate diffs (e.g. if $wgCodeReviewMaxDiffPaths |
| 158 | + // changes). If these situations arise we will either want to revert |
| 159 | + // this behaviour, or add a --force flag or something. |
| 160 | + $res = $dbw->select( 'code_rev', 'cr_id', |
| 161 | + array( 'cr_repo_id' => $repo->getId(), 'cr_diff IS NULL OR cr_diff = ""' ), |
| 162 | + __METHOD__, |
| 163 | + $options |
| 164 | + ); |
| 165 | + foreach ( $res as $row ) { |
| 166 | + $repo->getRevision( $row->cr_id ); |
| 167 | + $diff = $repo->getDiff( $row->cr_id ); // trigger caching |
| 168 | + $msg = "Diff r{$row->cr_id} "; |
| 169 | + if ( is_integer( $diff ) ) { |
| 170 | + $msg .= "Skipped: " . CodeRepository::getDiffErrorMessage( $diff ); |
| 171 | + } else { |
| 172 | + $msg .= "done"; |
| 173 | + } |
| 174 | + $this->output( $msg . "\n" ); |
| 175 | + } |
| 176 | + } else { |
| 177 | + $this->output( "Pre-caching skipped.\n" ); |
| 178 | + } |
| 179 | + $this->output( "Done!\n" ); |
| 180 | + } |
| 181 | +} |
| 182 | + |
| 183 | +$maintClass = "SvnImport"; |
| 184 | +require_once( DO_MAINTENANCE ); |
Property changes on: trunk/extensions/CodeReview/maintenance/svnImport.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 185 | + native |
Index: trunk/extensions/CodeReview/maintenance/populateFollowupRevisions.php |
— | — | @@ -0,0 +1,71 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +$IP = getenv( 'MW_INSTALL_PATH' ); |
| 5 | +if ( $IP === false ) { |
| 6 | + $IP = dirname( __FILE__ ) . '/../..'; |
| 7 | +} |
| 8 | +require( "$IP/maintenance/Maintenance.php" ); |
| 9 | + |
| 10 | +class PopulateFollowupRevisions extends Maintenance { |
| 11 | + public function __construct() { |
| 12 | + parent::__construct(); |
| 13 | + $this->mDescription = "Populates followup revisions. Useful for setting them on old revisions, without reimporting"; |
| 14 | + $this->addArg( 'repo', 'The name of the repo. Cannot be all.' ); |
| 15 | + $this->addArg( 'revisions', "The revisions to set followups revisions for. Format: start:end" ); |
| 16 | + $this->addOption( 'dry-run', 'Perform a dry run' ); |
| 17 | + } |
| 18 | + |
| 19 | + public function execute() { |
| 20 | + $repoName = $this->getArg( 0 ); |
| 21 | + |
| 22 | + if ( $repoName == "all" ) { |
| 23 | + $this->error( "Cannot use the 'all' repo", true ); |
| 24 | + } |
| 25 | + |
| 26 | + $repo = CodeRepository::newFromName( $repoName ); |
| 27 | + if ( !$repo ) { |
| 28 | + $this->error( "Repo '{$repoName}' is not a valid Repository", true ); |
| 29 | + } |
| 30 | + |
| 31 | + $revisions = $this->getArg( 1 ); |
| 32 | + if ( strpos( $revisions, ':' ) !== false ) { |
| 33 | + $revisionVals = explode( ':', $revisions, 2 ); |
| 34 | + } else { |
| 35 | + $this->error( "Invalid revision range", true ); |
| 36 | + } |
| 37 | + |
| 38 | + $start = intval( $revisionVals[0] ); |
| 39 | + $end = intval( $revisionVals[1] ); |
| 40 | + |
| 41 | + $revisions = range( $start, $end ); |
| 42 | + |
| 43 | + $dryrun = $this->hasOption( 'dry-run' ); |
| 44 | + |
| 45 | + $dbr = wfGetDB( DB_SLAVE ); |
| 46 | + |
| 47 | + $res = $dbr->select( 'code_rev', '*', array( 'cr_id' => $revisions, 'cr_repo_id' => $repo->getId() ), |
| 48 | + __METHOD__ ); |
| 49 | + |
| 50 | + foreach ( $res as $row ) { |
| 51 | + $rev = CodeRevision::newFromRow( $repo, $row ); |
| 52 | + |
| 53 | + $affectedRevs = $rev->getUniqueAffectedRevs(); |
| 54 | + |
| 55 | + $this->output( "r{$row->cr_id}: " ); |
| 56 | + |
| 57 | + if ( count( $affectedRevs ) ) { |
| 58 | + $this->output( "associating revs " . implode( ',', $affectedRevs ) . "\n" ); |
| 59 | + |
| 60 | + if ( !$dryrun ) { |
| 61 | + $rev->addReferencesTo( $affectedRevs ); |
| 62 | + } |
| 63 | + } else { |
| 64 | + $this->output( "no revisions followed up\n" ); |
| 65 | + } |
| 66 | + } |
| 67 | + $this->output( "Done!\n" ); |
| 68 | + } |
| 69 | +} |
| 70 | + |
| 71 | +$maintClass = "PopulateFollowupRevisions"; |
| 72 | +require_once( DO_MAINTENANCE ); |
\ No newline at end of file |
Property changes on: trunk/extensions/CodeReview/maintenance/populateFollowupRevisions.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 73 | + native |
Index: trunk/extensions/CodeReview/maintenance/bulkStatusUpdate.php |
— | — | @@ -0,0 +1,83 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +$IP = getenv( 'MW_INSTALL_PATH' ); |
| 5 | +if ( $IP === false ) { |
| 6 | + $IP = dirname( __FILE__ ) . '/../..'; |
| 7 | +} |
| 8 | +require( "$IP/maintenance/Maintenance.php" ); |
| 9 | + |
| 10 | +class BulkStatusUpdate extends Maintenance { |
| 11 | + |
| 12 | + public function __construct() { |
| 13 | + parent::__construct(); |
| 14 | + $this->mDescription = "Updates a range of revisions to a specific status"; |
| 15 | + $this->addArg( 'repo', 'The name of the repo. Cannot be all.' ); |
| 16 | + $this->addArg( 'revisions', "The revisions to set status for. Format: start:end" ); |
| 17 | + $this->addArg( 'status', "Code States: 'new', 'fixme', 'reverted', " |
| 18 | + . "'resolved', 'ok', 'deferred', 'old'" ); |
| 19 | + $this->addArg( 'user', "Username for whom to accredit the state changes to." . |
| 20 | + "The User needs to have the 'codereview-set-status' right" ); |
| 21 | + } |
| 22 | + |
| 23 | + public function execute() { |
| 24 | + $repoName = $this->getArg( 0 ); |
| 25 | + |
| 26 | + if ( $repoName == "all" ) { |
| 27 | + $this->error( "Cannot use the 'all' repo", true ); |
| 28 | + } |
| 29 | + |
| 30 | + $repo = CodeRepository::newFromName( $repoName ); |
| 31 | + if ( !$repo ) { |
| 32 | + $this->error( "Repo '{$repoName}' is not a valid Repository", true ); |
| 33 | + } |
| 34 | + |
| 35 | + $revisions = $this->getArg( 1 ); |
| 36 | + if ( strpos( $revisions, ':' ) !== false ) { |
| 37 | + $revisionVals = explode( ':', $revisions, 2 ); |
| 38 | + } else { |
| 39 | + $this->error( "Invalid revision range", true ); |
| 40 | + } |
| 41 | + |
| 42 | + $start = intval( $revisionVals[0] ); |
| 43 | + $end = intval( $revisionVals[1] ); |
| 44 | + |
| 45 | + $revisions = range( $start, $end ); |
| 46 | + |
| 47 | + $status = $this->getArg( 2 ); |
| 48 | + |
| 49 | + if ( !CodeRevision::isValidStatus( $status ) ) { |
| 50 | + $this->error( "'{$status}' is not a valid status", true ); |
| 51 | + } |
| 52 | + |
| 53 | + $username = $this->getArg( 3 ); |
| 54 | + $user = User::newFromName( $username ); |
| 55 | + |
| 56 | + if ( !$user ) { |
| 57 | + $this->error( "'{$username}' is not a valid username ", true ); |
| 58 | + } |
| 59 | + |
| 60 | + if ( !$user->isAllowed( 'codereview-set-status' ) ) { |
| 61 | + $this->error( "'{$username}' does not have the 'codereview-set-status' right", true ); |
| 62 | + } |
| 63 | + |
| 64 | + $dbr = wfGetDB( DB_SLAVE ); |
| 65 | + |
| 66 | + $res = $dbr->select( 'code_rev', '*', array( 'cr_id' => $revisions, 'cr_repo_id' => $repo->getId() ), |
| 67 | + __METHOD__ ); |
| 68 | + |
| 69 | + foreach ( $res as $row ) { |
| 70 | + $rev = CodeRevision::newFromRow( $repo, $row ); |
| 71 | + |
| 72 | + if ( $rev && $rev->setStatus( $status, $user ) ) { |
| 73 | + $this->output( "r{$row->cr_id} updated\n" ); |
| 74 | + } else { |
| 75 | + $this->output( "r{$row->cr_id} not updated\n" ); |
| 76 | + } |
| 77 | + } |
| 78 | + |
| 79 | + $this->output( "Done!\n" ); |
| 80 | + } |
| 81 | +} |
| 82 | + |
| 83 | +$maintClass = "BulkStatusUpdate"; |
| 84 | +require_once( DO_MAINTENANCE ); |
Property changes on: trunk/extensions/CodeReview/maintenance/bulkStatusUpdate.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 85 | + native |
Index: trunk/extensions/CodeReview/maintenance/deleteBadTags.php |
— | — | @@ -0,0 +1,22 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +$IP = getenv( 'MW_INSTALL_PATH' ); |
| 5 | +if ( $IP === false ) |
| 6 | + $IP = dirname( __FILE__ ) . '/../..'; |
| 7 | +require "$IP/maintenance/commandLine.inc"; |
| 8 | + |
| 9 | +echo "Usage: php deleteBadTags.php [commit]\n"; |
| 10 | + |
| 11 | +echo "Deleting empty tags...\n"; |
| 12 | + |
| 13 | +$dbw = wfGetDB( DB_MASTER ); |
| 14 | +$dbw->begin(); |
| 15 | +$dbw->delete( 'code_tags', array('ct_tag' => ''), __METHOD__ ); |
| 16 | +$count = $dbw->affectedRows(); |
| 17 | +if( isset($args[0]) && $args[0] == 'commit' ) { |
| 18 | + $dbw->commit(); |
| 19 | + echo "$count bad tags deleted. Done!\n"; |
| 20 | +} else { |
| 21 | + $dbw->rollback(); |
| 22 | + echo "$count bad tags. Not commited!\n"; |
| 23 | +} |
Property changes on: trunk/extensions/CodeReview/maintenance/deleteBadTags.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 24 | + native |