r41686 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41685‎ | r41686 | r41687 >
Date:06:01, 5 October 2008
Author:nicdumz
Status:old
Tags:
Comment:
Adding a 'cr_path' field to store the common base path of the modifications ( e.g. /trunk/extensions/CodeReview for this commit )
This field is displayed on the Revision List, for easier readability of commits :)
Modified paths:
  • /trunk/extensions/CodeReview/CodeReview.i18n.php (modified) (history)
  • /trunk/extensions/CodeReview/CodeRevision.php (modified) (history)
  • /trunk/extensions/CodeReview/CodeRevisionListView.php (modified) (history)
  • /trunk/extensions/CodeReview/codereview.sql (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/CodeRevision.php
@@ -11,6 +11,35 @@
1212 $rev->mMessage = rtrim( $data['msg'] );
1313 $rev->mPaths = $data['paths'];
1414 $rev->mStatus = 'new';
 15+
 16+ $common = null;
 17+ if( $rev->mPaths ) {
 18+ if (count($rev->mPaths) == 1)
 19+ $common = $rev->mPaths[0]['path'];
 20+ else {
 21+ $first = array_shift( $rev->mPaths );
 22+
 23+ $common = explode( '/', $first['path'] );
 24+
 25+ foreach( $rev->mPaths as $path ) {
 26+ $compare = explode( '/', $path['path'] );
 27+
 28+ // make sure $common is the shortest path
 29+ if ( count($compare) < count($common) )
 30+ list( $compare, $common ) = array( $common, $compare );
 31+
 32+ $tmp = array();
 33+ foreach ( $common as $k => $v )
 34+ if ( $v==$compare[$k] ) $tmp[]= $v;
 35+ else break;
 36+ $common = $tmp;
 37+ }
 38+ $common = implode( '/', $common);
 39+
 40+ array_unshift( $rev->mPaths, $first );
 41+ }
 42+ }
 43+ $rev->mCommonPath = $common;
1544 return $rev;
1645 }
1746
@@ -22,6 +51,7 @@
2352 $rev->mTimestamp = wfTimestamp( TS_MW, $row->cr_timestamp );
2453 $rev->mMessage = $row->cr_message;
2554 $rev->mStatus = $row->cr_status;
 55+ $rev->mCommonPath = $row->cr_path;
2656 return $rev;
2757 }
2858
@@ -44,6 +74,10 @@
4575 function getStatus() {
4676 return $this->mStatus;
4777 }
 78+
 79+ function getCommonPath() {
 80+ return $this->mCommonPath;
 81+ }
4882
4983 static function getPossibleStates() {
5084 return array( 'new', 'fixme', 'resolved', 'ok' );
@@ -80,12 +114,14 @@
81115 'cr_author' => $this->mAuthor,
82116 'cr_timestamp' => $dbw->timestamp( $this->mTimestamp ),
83117 'cr_message' => $this->mMessage,
84 - 'cr_status' => $this->mStatus ),
 118+ 'cr_status' => $this->mStatus,
 119+ 'cr_path' => $this->mCommonPath ),
85120 __METHOD__,
86121 array( 'IGNORE' ) );
87122
88123 if( $this->mPaths ) {
89124 $data = array();
 125+ $common = explode( '/', $this->mPaths[0]['path'] );
90126 foreach( $this->mPaths as $path ) {
91127 $data[] = array(
92128 'cp_repo_id' => $this->mRepo,
@@ -98,7 +134,7 @@
99135 __METHOD__,
100136 array( 'IGNORE' ) );
101137 }
102 -
 138+
103139 $dbw->commit();
104140 }
105141
Index: trunk/extensions/CodeReview/codereview.sql
@@ -53,6 +53,11 @@
5454 -- 'ok': Reviewed, no issues
5555 cr_status enum('new', 'fixme', 'resolved', 'ok') not null default 'new',
5656
 57+ -- Base path of this revision :
 58+ -- * if the revision change only one file, the file path
 59+ -- * else, common directory for all changes (e.g. trunk/phase3/includes/ )
 60+ cr_path varchar(255) binary,
 61+
5762 primary key (cr_repo_id, cr_id),
5863 key (cr_repo_id, cr_timestamp),
5964 key cr_repo_author (cr_repo_id, cr_author, cr_timestamp)
Index: trunk/extensions/CodeReview/CodeReview.i18n.php
@@ -34,6 +34,7 @@
3535 'code-field-status' => 'Status',
3636 'code-field-timestamp' => 'Date',
3737 'code-field-comments' => 'Notes',
 38+ 'code-field-path' => 'Path',
3839 'code-field-text' => 'Note',
3940 'code-rev-author' => 'Author:',
4041 'code-rev-message' => 'Comment:',
Index: trunk/extensions/CodeReview/CodeRevisionListView.php
@@ -65,6 +65,7 @@
6666 'COUNT(cc_rev_id)' => wfMsg( 'code-field-comments' ),
6767 'cr_message' => wfMsg( 'code-field-message' ),
6868 'cr_author' => wfMsg( 'code-field-author' ),
 69+ 'cr_path' => wfMsg( 'code-field-path' ),
6970 'cr_timestamp' => wfMsg( 'code-field-timestamp' ),
7071 );
7172 }
@@ -90,6 +91,8 @@
9192 return $wgLang->timeanddate( $value );
9293 case 'COUNT(cc_rev_id)':
9394 return intval( $value );
 95+ case 'cr_path':
 96+ return $wgLang->truncate( $value, 30, '...' );
9497 }
9598 }
9699

Follow-up revisions

RevisionCommit summaryAuthorDate
r41869Tweak display for code review path (added in r41686)...brion22:32, 8 October 2008

Status & tagging log