r57660 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57659‎ | r57660 | r57661 >
Date:01:55, 13 October 2009
Author:aaron
Status:ok
Tags:
Comment:
* bug 18012 CodeReview "Next unresolved" et al should remember search details
* Fixed bogus var
Modified paths:
  • /trunk/extensions/CodeReview/CodeReview.i18n.php (modified) (history)
  • /trunk/extensions/CodeReview/backend/CodeRevision.php (modified) (history)
  • /trunk/extensions/CodeReview/ui/CodeRevisionCommitter.php (modified) (history)
  • /trunk/extensions/CodeReview/ui/CodeRevisionListView.php (modified) (history)
  • /trunk/extensions/CodeReview/ui/CodeRevisionView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/CodeReview.i18n.php
@@ -40,6 +40,7 @@
4141 'code-author-link' => 'link?',
4242 'code-author-unlink' => 'unlink?',
4343 'code-author-unlinksuccess' => 'Author $1 has been unlinked',
 44+ 'code-browsing-path' => "Browsing revisions in '''$1'''",
4445 'code-field-id' => 'Revision',
4546 'code-field-author' => 'Author',
4647 'code-field-user' => 'Commenter',
Index: trunk/extensions/CodeReview/backend/CodeRevision.php
@@ -629,28 +629,49 @@
630630 return $out;
631631 }
632632
633 - public function getPrevious() {
634 - // hack!
635 - if ( $this->mId > 1 ) {
636 - return $this->mId - 1;
 633+ public function getPrevious( $path = '' ) {
 634+ $dbr = wfGetDB( DB_SLAVE );
 635+ $encId = $dbr->addQuotes( $this->mId );
 636+ $tables = array( 'code_rev' );
 637+ if ( $path != '' ) {
 638+ $conds = $this->getPathConds( $path );
 639+ $order = 'cp_rev_id DESC';
 640+ $tables[] = 'code_paths';
637641 } else {
 642+ $conds = array( 'cr_repo_id' => $this->mRepoId );
 643+ $order = 'cr_id DESC';
 644+ }
 645+ $conds[] = "cr_id < $encId";
 646+ $row = $dbr->selectRow( $tables, 'cr_id',
 647+ $conds,
 648+ __METHOD__,
 649+ array( 'ORDER BY' => $order )
 650+ );
 651+ if ( $row ) {
 652+ return intval( $row->cr_id );
 653+ } else {
638654 return false;
639655 }
640656 }
641657
642 - public function getNext() {
 658+ public function getNext( $path = '' ) {
643659 $dbr = wfGetDB( DB_SLAVE );
644660 $encId = $dbr->addQuotes( $this->mId );
645 - $row = $dbr->selectRow( 'code_rev',
646 - 'cr_id',
647 - array(
648 - 'cr_repo_id' => $this->mRepoId,
649 - "cr_id > $encId" ),
 661+ $tables = array( 'code_rev' );
 662+ if ( $path != '' ) {
 663+ $conds = $this->getPathConds( $path );
 664+ $order = 'cp_rev_id ASC';
 665+ $tables[] = 'code_paths';
 666+ } else {
 667+ $conds = array( 'cr_repo_id' => $this->mRepoId );
 668+ $order = 'cr_id ASC';
 669+ }
 670+ $conds[] = "cr_id > $encId";
 671+ $row = $dbr->selectRow( $tables, 'cr_id',
 672+ $conds,
650673 __METHOD__,
651 - array(
652 - 'ORDER BY' => 'cr_repo_id, cr_id',
653 - 'LIMIT' => 1 ) );
654 -
 674+ array( 'ORDER BY' => $order )
 675+ );
655676 if ( $row ) {
656677 return intval( $row->cr_id );
657678 } else {
@@ -658,19 +679,37 @@
659680 }
660681 }
661682
662 - public function getNextUnresolved() {
 683+ protected function getPathConds( $path ) {
663684 $dbr = wfGetDB( DB_SLAVE );
 685+ return array(
 686+ 'cp_repo_id' => $this->mRepoId,
 687+ 'cp_path LIKE ' . $dbr->addQuotes( $dbr->escapeLike( $path ) . '%' ),
 688+ // performance
 689+ 'cp_rev_id > ' . $this->mRepo->getLastStoredRev() - 20000,
 690+ // join conds
 691+ 'cr_repo_id = cp_repo_id',
 692+ 'cr_id = cp_rev_id'
 693+ );
 694+ }
 695+
 696+ public function getNextUnresolved( $path = '' ) {
 697+ $dbr = wfGetDB( DB_SLAVE );
664698 $encId = $dbr->addQuotes( $this->mId );
665 - $row = $dbr->selectRow( 'code_rev',
666 - 'cr_id',
667 - array(
668 - 'cr_repo_id' => $this->mRepoId,
669 - "cr_id > $encId",
670 - 'cr_status' => array( 'new', 'fixme' ) ),
 699+ $tables = array( 'code_rev' );
 700+ if ( $path != '' ) {
 701+ $conds = $this->getPathConds( $path );
 702+ $order = 'cp_rev_id ASC';
 703+ $tables[] = 'code_paths';
 704+ } else {
 705+ $conds = array( 'cr_repo_id' => $this->mRepoId );
 706+ $order = 'cr_id ASC';
 707+ }
 708+ $conds[] = "cr_id > $encId";
 709+ $conds['cr_status'] = array( 'new', 'fixme' );
 710+ $row = $dbr->selectRow( $tables, 'cr_id',
 711+ $conds,
671712 __METHOD__,
672 - array(
673 - 'ORDER BY' => 'cr_repo_id, cr_id',
674 - 'LIMIT' => 1 )
 713+ array( 'ORDER BY' => $order )
675714 );
676715 if ( $row ) {
677716 return intval( $row->cr_id );
Index: trunk/extensions/CodeReview/ui/CodeRevisionCommitter.php
@@ -53,9 +53,10 @@
5454 $dbw->commit();
5555
5656 // Return to rev page
57 - if ( !$redirTitle ) {
 57+ if ( !$redirTarget ) {
5858 if ( $this->jumpToNext ) {
59 - if ( $next = $this->mRev->getNextUnresolved() ) {
 59+ $next = $this->mRev->getNextUnresolved( $this->mPath );
 60+ if ( $next ) {
6061 $redirTitle = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() . '/' . $next );
6162 } else {
6263 $redirTitle = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() );
@@ -65,7 +66,7 @@
6667 $redirTitle = $redirTarget ? $redirTarget : $this->revLink();
6768 }
6869 }
69 - $wgOut->redirect( $redirTitle->getFullUrl() );
 70+ $wgOut->redirect( $redirTitle->getFullUrl( array('path' => $this->mPath) ) );
7071 }
7172
7273 public function validPost( $permission ) {
Index: trunk/extensions/CodeReview/ui/CodeRevisionListView.php
@@ -238,7 +238,10 @@
239239 case 'cr_id':
240240 return $this->mView->mSkin->link(
241241 SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() . '/' . $value ),
242 - htmlspecialchars( $value ) );
 242+ htmlspecialchars( $value ),
 243+ array(),
 244+ array( 'path' => $this->mView->mPath )
 245+ );
243246 case 'cr_status':
244247 return $this->mView->mSkin->link(
245248 SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() . '/status/' . $value ),
Index: trunk/extensions/CodeReview/ui/CodeRevisionView.php
@@ -7,8 +7,14 @@
88 global $wgRequest;
99 parent::__construct();
1010 $this->mRepo = CodeRepository::newFromName( $repoName );
11 - $this->mRev = $this->mRepo ? $this->mRepo->getRevision( intval( ltrim( $rev, 'r' ) ) ) : null;
 11+ $this->mRev = $this->mRepo ?
 12+ $this->mRepo->getRevision( intval( ltrim( $rev, 'r' ) ) ) : null;
1213 $this->mPreviewText = false;
 14+ # Search path for navigation links
 15+ $this->mPath = htmlspecialchars( trim( $wgRequest->getVal( 'path' ) ) );
 16+ if ( strlen( $this->mPath ) && $this->mPath[0] !== '/' ) {
 17+ $this->mPath = "/{$this->mPath}"; // make sure this is a valid path
 18+ }
1319 # URL params...
1420 $this->mAddTags = $wgRequest->getText( 'wpTag' );
1521 $this->mRemoveTags = $wgRequest->getText( 'wpRemoveTag' );
@@ -74,7 +80,12 @@
7581 );
7682 $special = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() . '/' . $this->mRev->getId() );
7783
78 - $html = Xml::openElement( 'form', array( 'action' => $special->getLocalUrl(), 'method' => 'post' ) );
 84+ $html = '';
 85+ if( $this->mPath != '' ) {
 86+ $html .= wfMsgExt( 'code-browsing-path', 'parse', $this->mPath );
 87+ }
 88+ # Output form
 89+ $html .= Xml::openElement( 'form', array( 'action' => $special->getLocalUrl(), 'method' => 'post' ) );
7990
8091 if ( $this->canPostComments() ) {
8192 $html .= $this->addActionButtons();
@@ -134,15 +145,16 @@
135146 global $wgLang;
136147
137148 $rev = $this->mRev->getId();
138 - $prev = $this->mRev->getPrevious();
139 - $next = $this->mRev->getNext();
 149+ $prev = $this->mRev->getPrevious( $this->mPath );
 150+ $next = $this->mRev->getNext( $this->mPath );
140151 $repo = $this->mRepo->getName();
141152
142153 $links = array();
143154
144155 if ( $prev ) {
145156 $prevTarget = SpecialPage::getTitleFor( 'Code', "$repo/$prev" );
146 - $links[] = '&lt;&nbsp;' . $this->mSkin->link( $prevTarget, "r$prev" );
 157+ $links[] = '&lt;&nbsp;' . $this->mSkin->link( $prevTarget, "r$prev",
 158+ array(), array('path' => $this->mPath) );
147159 }
148160
149161 $revText = "<b>r$rev</b>";
@@ -156,7 +168,8 @@
157169
158170 if ( $next ) {
159171 $nextTarget = SpecialPage::getTitleFor( 'Code', "$repo/$next" );
160 - $links[] = $this->mSkin->link( $nextTarget, "r$next" ) . '&nbsp;&gt;';
 172+ $links[] = $this->mSkin->link( $nextTarget, "r$next",
 173+ array(), array('path' => $this->mPath) ) . '&nbsp;&gt;';
161174 }
162175
163176 return $wgLang->pipeList( $links );
@@ -608,6 +621,7 @@
609622 return '<div class="mw-codereview-post-comment">' .
610623 $preview .
611624 Xml::hidden( 'wpEditToken', $wgUser->editToken() ) .
 625+ Xml::hidden( 'path', $this->mPath ) .
612626 ( $parent ? Xml::hidden( 'wpParent', $parent ) : '' ) .
613627 '<div>' .
614628 Xml::openElement( 'textarea', array(

Status & tagging log