Index: trunk/extensions/CodeReview/CodeRevision.php |
— | — | @@ -11,6 +11,35 @@ |
12 | 12 | $rev->mMessage = rtrim( $data['msg'] ); |
13 | 13 | $rev->mPaths = $data['paths']; |
14 | 14 | $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; |
15 | 44 | return $rev; |
16 | 45 | } |
17 | 46 | |
— | — | @@ -22,6 +51,7 @@ |
23 | 52 | $rev->mTimestamp = wfTimestamp( TS_MW, $row->cr_timestamp ); |
24 | 53 | $rev->mMessage = $row->cr_message; |
25 | 54 | $rev->mStatus = $row->cr_status; |
| 55 | + $rev->mCommonPath = $row->cr_path; |
26 | 56 | return $rev; |
27 | 57 | } |
28 | 58 | |
— | — | @@ -44,6 +74,10 @@ |
45 | 75 | function getStatus() { |
46 | 76 | return $this->mStatus; |
47 | 77 | } |
| 78 | + |
| 79 | + function getCommonPath() { |
| 80 | + return $this->mCommonPath; |
| 81 | + } |
48 | 82 | |
49 | 83 | static function getPossibleStates() { |
50 | 84 | return array( 'new', 'fixme', 'resolved', 'ok' ); |
— | — | @@ -80,12 +114,14 @@ |
81 | 115 | 'cr_author' => $this->mAuthor, |
82 | 116 | 'cr_timestamp' => $dbw->timestamp( $this->mTimestamp ), |
83 | 117 | 'cr_message' => $this->mMessage, |
84 | | - 'cr_status' => $this->mStatus ), |
| 118 | + 'cr_status' => $this->mStatus, |
| 119 | + 'cr_path' => $this->mCommonPath ), |
85 | 120 | __METHOD__, |
86 | 121 | array( 'IGNORE' ) ); |
87 | 122 | |
88 | 123 | if( $this->mPaths ) { |
89 | 124 | $data = array(); |
| 125 | + $common = explode( '/', $this->mPaths[0]['path'] ); |
90 | 126 | foreach( $this->mPaths as $path ) { |
91 | 127 | $data[] = array( |
92 | 128 | 'cp_repo_id' => $this->mRepo, |
— | — | @@ -98,7 +134,7 @@ |
99 | 135 | __METHOD__, |
100 | 136 | array( 'IGNORE' ) ); |
101 | 137 | } |
102 | | - |
| 138 | + |
103 | 139 | $dbw->commit(); |
104 | 140 | } |
105 | 141 | |
Index: trunk/extensions/CodeReview/codereview.sql |
— | — | @@ -53,6 +53,11 @@ |
54 | 54 | -- 'ok': Reviewed, no issues |
55 | 55 | cr_status enum('new', 'fixme', 'resolved', 'ok') not null default 'new', |
56 | 56 | |
| 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 | + |
57 | 62 | primary key (cr_repo_id, cr_id), |
58 | 63 | key (cr_repo_id, cr_timestamp), |
59 | 64 | key cr_repo_author (cr_repo_id, cr_author, cr_timestamp) |
Index: trunk/extensions/CodeReview/CodeReview.i18n.php |
— | — | @@ -34,6 +34,7 @@ |
35 | 35 | 'code-field-status' => 'Status', |
36 | 36 | 'code-field-timestamp' => 'Date', |
37 | 37 | 'code-field-comments' => 'Notes', |
| 38 | + 'code-field-path' => 'Path', |
38 | 39 | 'code-field-text' => 'Note', |
39 | 40 | 'code-rev-author' => 'Author:', |
40 | 41 | 'code-rev-message' => 'Comment:', |
Index: trunk/extensions/CodeReview/CodeRevisionListView.php |
— | — | @@ -65,6 +65,7 @@ |
66 | 66 | 'COUNT(cc_rev_id)' => wfMsg( 'code-field-comments' ), |
67 | 67 | 'cr_message' => wfMsg( 'code-field-message' ), |
68 | 68 | 'cr_author' => wfMsg( 'code-field-author' ), |
| 69 | + 'cr_path' => wfMsg( 'code-field-path' ), |
69 | 70 | 'cr_timestamp' => wfMsg( 'code-field-timestamp' ), |
70 | 71 | ); |
71 | 72 | } |
— | — | @@ -90,6 +91,8 @@ |
91 | 92 | return $wgLang->timeanddate( $value ); |
92 | 93 | case 'COUNT(cc_rev_id)': |
93 | 94 | return intval( $value ); |
| 95 | + case 'cr_path': |
| 96 | + return $wgLang->truncate( $value, 30, '...' ); |
94 | 97 | } |
95 | 98 | } |
96 | 99 | |