r78937 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78936‎ | r78937 | r78938 >
Date:23:38, 23 December 2010
Author:reedy
Status:ok
Tags:
Comment:
*(bug 26299) Create maintenance script to populate followup revision tracking for before the feature was implemented
Modified paths:
  • /trunk/extensions/CodeReview/populateFollowupRevisions.php (added) (history)

Diff [purge]

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
161 + native

Follow-up revisions

RevisionCommit summaryAuthorDate
r79062Followup r78937, fix tab fail. Add some useful debugging outputreedy15:17, 27 December 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r78936Refactor out getting of referenced bugs and revisions when saving a commit, s...reedy23:36, 23 December 2010

Status & tagging log