Index: includes/DifferenceEngine.php
===================================================================
--- includes/DifferenceEngine.php	(revision 17247)
+++ includes/DifferenceEngine.php	(working copy)
@@ -173,11 +173,11 @@
 
 		$oldHeader = "<strong>{$this->mOldtitle}</strong><br />" .
 			$sk->revUserTools( $this->mOldRev ) . "<br />" .
-			$sk->revComment( $this->mOldRev ) . "<br />" .
+			$sk->revComment( $this->mOldRev, true ) . "<br />" .
 			$prevlink;
 		$newHeader = "<strong>{$this->mNewtitle}</strong><br />" .
 			$sk->revUserTools( $this->mNewRev ) . " $rollback<br />" .
-			$sk->revComment( $this->mNewRev ) . "<br />" .
+			$sk->revComment( $this->mNewRev, true ) . "<br />" .
 			$nextlink . $patrol;
 
 		$this->showDiff( $oldHeader, $newHeader );
Index: includes/Linker.php
===================================================================
--- includes/Linker.php	(revision 17247)
+++ includes/Linker.php	(working copy)
@@ -877,11 +877,14 @@
 	 * direct link to the section in the autocomment.
 	 * @author Erik Moeller <moeller@scireview.de>
 	 *
+	 * If $local is true, then section link anchors will refer to the local page
+	 * rather than making a link to the article. Used for viewing diffs.
+	 *
 	 * Note: there's not always a title to pass to this function.
 	 * Since you can't set a default parameter for a reference, I've turned it
 	 * temporarily to a value pass. Should be adjusted further. --brion
 	 */
-	function formatComment($comment, $title = NULL) {
+	function formatComment($comment, $title = NULL, $local = false) {
 		$fname = 'Linker::formatComment';
 		wfProfileIn( $fname );
 
@@ -909,8 +912,14 @@
 				$section = str_replace( '[[:', '', $section );
 				$section = str_replace( '[[', '', $section );
 				$section = str_replace( ']]', '', $section );
-				$sectionTitle = wfClone( $title );
-				$sectionTitle->mFragment = $section;
+
+				if ( $local ) {
+					$sectionTitle = Title::newFromText( '#' . $section);
+				} else {
+					$sectionTitle = wfClone( $title );
+					$sectionTitle->mFragment = $section;
+				}
+
 				$link = $this->makeKnownLinkObj( $sectionTitle, wfMsg( 'sectionlink' ) );
 			}
 			$sep='-';
@@ -959,17 +968,18 @@
 	 *
 	 * @param $comment String: the comment.
 	 * @param $title Title object.
+	 * @param $local boolean: if section anchors should refer to the local page
 	 *
 	 * @return string
 	 */
-	function commentBlock( $comment, $title = NULL ) {
+	function commentBlock( $comment, $title = NULL, $local = false ) {
 		// '*' used to be the comment inserted by the software way back
 		// in antiquity in case none was provided, here for backwards
 		// compatability, acc. to brion -ævar
 		if( $comment == '' || $comment == '*' ) {
 			return '';
 		} else {
-			$formatted = $this->formatComment( $comment, $title );
+			$formatted = $this->formatComment( $comment, $title, $local );
 			return " <span class=\"comment\">($formatted)</span>";
 		}
 	}
@@ -978,11 +988,12 @@
 	 * Wrap and format the given revision's comment block, if the current
 	 * user is allowed to view it.
 	 * @param $rev Revision object.
+	 * @param $local boolean: if section anchors should refer to the local page
 	 * @return string HTML
 	 */
-	function revComment( $rev ) {
+	function revComment( $rev, $local = false ) {
 		if( $rev->userCan( Revision::DELETED_COMMENT ) ) {
-			$block = $this->commentBlock( $rev->getRawComment(), $rev->getTitle() );
+			$block = $this->commentBlock( $rev->getRawComment(), $rev->getTitle(), $local );
 		} else {
 			$block = " <span class=\"comment\">" .
 				wfMsgHtml( 'rev-deleted-comment' ) . "</span>";
