Index: trunk/extensions/CodeReview/populateFollowupRevisions.php |
— | — | @@ -0,0 +1,59 @@ |
| 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 status for. Format: start:end" ); |
| 16 | + } |
| 17 | + |
| 18 | + public function execute() { |
| 19 | + $repoName = $this->getArg( 0 ); |
| 20 | + |
| 21 | + if ( $repoName == "all" ) { |
| 22 | + $this->error( "Cannot use the 'all' repo", true ); |
| 23 | + } |
| 24 | + |
| 25 | + $repo = CodeRepository::newFromName( $repoName ); |
| 26 | + if ( !$repo ) { |
| 27 | + $this->error( "Repo '{$repoName}' is not a valid Repository", true ); |
| 28 | + } |
| 29 | + |
| 30 | + $revisions = $this->getArg( 1 ); |
| 31 | + if ( strpos( $revisions, ':' ) !== false ) { |
| 32 | + $revisionVals = explode( ':', $revisions, 2 ); |
| 33 | + } else { |
| 34 | + $this->error( "Invalid revision range", true ); |
| 35 | + } |
| 36 | + |
| 37 | + $start = intval( $revisionVals[0] ); |
| 38 | + $end = intval( $revisionVals[1] ); |
| 39 | + |
| 40 | + $revisions = range( $start, $end ); |
| 41 | + |
| 42 | + $dbr = wfGetDB( DB_SLAVE ); |
| 43 | + |
| 44 | + $res = $dbr->select( 'code_rev', '*', array( 'cr_id' => $revisions, 'cr_repo_id' => $repo->getId() ), |
| 45 | + __METHOD__ ); |
| 46 | + |
| 47 | + foreach ( $res as $row ) { |
| 48 | + $rev = CodeRevision::newFromRow( $repo, $row ); |
| 49 | + |
| 50 | + $affectedRevs = $rev->getUniqueAffectedRevs(); |
| 51 | + |
| 52 | + if ( count( $affectedRevs ) ) { |
| 53 | + $rev->addReferencesTo( $affectedRevs ); |
| 54 | + } |
| 55 | + } |
| 56 | + } |
| 57 | +} |
| 58 | + |
| 59 | +$maintClass = "PopulateFollowupRevisions"; |
| 60 | +require_once( DO_MAINTENANCE ); |
\ No newline at end of file |
Property changes on: trunk/extensions/CodeReview/populateFollowupRevisions.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 61 | + native |