Option to display line endings
Displays Windows EOL/Cr-Lf on patch diff screen. This is optional and is controlled by a checkbox. A new column show_line_endings is added in account_diff_preferences. Display is similar to gitweb i.e. '\r' in dotted-line box Bug: issue 626 Change-Id: I6128575bd2f0869a3c59e3d2fd409d5ee431ecc5
This commit is contained in:

committed by
Sasa Zivkov

parent
e6ec46892f
commit
632653c2d0
@@ -75,6 +75,9 @@ public class PatchScriptSettingsPanel extends Composite implements
|
|||||||
@UiField
|
@UiField
|
||||||
CheckBox whitespaceErrors;
|
CheckBox whitespaceErrors;
|
||||||
|
|
||||||
|
@UiField
|
||||||
|
CheckBox showLineEndings;
|
||||||
|
|
||||||
@UiField
|
@UiField
|
||||||
CheckBox showTabs;
|
CheckBox showTabs;
|
||||||
|
|
||||||
@@ -210,6 +213,7 @@ public class PatchScriptSettingsPanel extends Composite implements
|
|||||||
colWidth.setIntValue(dp.getLineLength());
|
colWidth.setIntValue(dp.getLineLength());
|
||||||
intralineDifference.setValue(dp.isIntralineDifference());
|
intralineDifference.setValue(dp.isIntralineDifference());
|
||||||
whitespaceErrors.setValue(dp.isShowWhitespaceErrors());
|
whitespaceErrors.setValue(dp.isShowWhitespaceErrors());
|
||||||
|
showLineEndings.setValue(dp.isShowLineEndings());
|
||||||
showTabs.setValue(dp.isShowTabs());
|
showTabs.setValue(dp.isShowTabs());
|
||||||
skipDeleted.setValue(dp.isSkipDeleted());
|
skipDeleted.setValue(dp.isSkipDeleted());
|
||||||
skipUncommented.setValue(dp.isSkipUncommented());
|
skipUncommented.setValue(dp.isSkipUncommented());
|
||||||
@@ -242,6 +246,7 @@ public class PatchScriptSettingsPanel extends Composite implements
|
|||||||
dp.setSyntaxHighlighting(syntaxHighlighting.getValue());
|
dp.setSyntaxHighlighting(syntaxHighlighting.getValue());
|
||||||
dp.setIntralineDifference(intralineDifference.getValue());
|
dp.setIntralineDifference(intralineDifference.getValue());
|
||||||
dp.setShowWhitespaceErrors(whitespaceErrors.getValue());
|
dp.setShowWhitespaceErrors(whitespaceErrors.getValue());
|
||||||
|
dp.setShowLineEndings(showLineEndings.getValue());
|
||||||
dp.setShowTabs(showTabs.getValue());
|
dp.setShowTabs(showTabs.getValue());
|
||||||
dp.setSkipDeleted(skipDeleted.getValue());
|
dp.setSkipDeleted(skipDeleted.getValue());
|
||||||
dp.setSkipUncommented(skipUncommented.getValue());
|
dp.setSkipUncommented(skipUncommented.getValue());
|
||||||
|
@@ -108,8 +108,8 @@ limitations under the License.
|
|||||||
</g:CheckBox>
|
</g:CheckBox>
|
||||||
<br/>
|
<br/>
|
||||||
<g:CheckBox
|
<g:CheckBox
|
||||||
ui:field='showTabs'
|
ui:field='showLineEndings'
|
||||||
text='Show Tabs'
|
text='Show Line Endings'
|
||||||
tabIndex='8'>
|
tabIndex='8'>
|
||||||
<ui:attribute name='text'/>
|
<ui:attribute name='text'/>
|
||||||
</g:CheckBox>
|
</g:CheckBox>
|
||||||
@@ -117,15 +117,15 @@ limitations under the License.
|
|||||||
|
|
||||||
<td rowspan='2'>
|
<td rowspan='2'>
|
||||||
<g:CheckBox
|
<g:CheckBox
|
||||||
ui:field='expandAllComments'
|
ui:field='showTabs'
|
||||||
text='Expand All Comments'
|
text='Show Tabs'
|
||||||
tabIndex='9'>
|
tabIndex='9'>
|
||||||
<ui:attribute name='text'/>
|
<ui:attribute name='text'/>
|
||||||
</g:CheckBox>
|
</g:CheckBox>
|
||||||
<br/>
|
<br/>
|
||||||
<g:CheckBox
|
<g:CheckBox
|
||||||
ui:field='retainHeader'
|
ui:field='expandAllComments'
|
||||||
text='Retain Header On File Switch'
|
text='Expand All Comments'
|
||||||
tabIndex='10'>
|
tabIndex='10'>
|
||||||
<ui:attribute name='text'/>
|
<ui:attribute name='text'/>
|
||||||
</g:CheckBox>
|
</g:CheckBox>
|
||||||
@@ -133,25 +133,32 @@ limitations under the License.
|
|||||||
|
|
||||||
<td rowspan='2'>
|
<td rowspan='2'>
|
||||||
<g:CheckBox
|
<g:CheckBox
|
||||||
ui:field='skipUncommented'
|
ui:field='retainHeader'
|
||||||
text='Skip Uncommented Files'
|
text='Retain Header On File Switch'
|
||||||
tabIndex='11'>
|
tabIndex='11'>
|
||||||
<ui:attribute name='text'/>
|
<ui:attribute name='text'/>
|
||||||
</g:CheckBox>
|
</g:CheckBox>
|
||||||
<br/>
|
<br/>
|
||||||
<g:CheckBox
|
<g:CheckBox
|
||||||
ui:field='skipDeleted'
|
ui:field='skipUncommented'
|
||||||
text='Skip Deleted Files'
|
text='Skip Uncommented Files'
|
||||||
tabIndex='12'>
|
tabIndex='12'>
|
||||||
<ui:attribute name='text'/>
|
<ui:attribute name='text'/>
|
||||||
</g:CheckBox>
|
</g:CheckBox>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td valign='bottom' rowspan='2'>
|
<td valign='bottom' rowspan='2'>
|
||||||
|
<g:CheckBox
|
||||||
|
ui:field='skipDeleted'
|
||||||
|
text='Skip Deleted Files'
|
||||||
|
tabIndex='13'>
|
||||||
|
<ui:attribute name='text'/>
|
||||||
|
</g:CheckBox>
|
||||||
|
<br/>
|
||||||
<g:CheckBox
|
<g:CheckBox
|
||||||
ui:field='manualReview'
|
ui:field='manualReview'
|
||||||
text='Manual Review'
|
text='Manual Review'
|
||||||
tabIndex='13'>
|
tabIndex='14'>
|
||||||
<ui:attribute name='text'/>
|
<ui:attribute name='text'/>
|
||||||
</g:CheckBox>
|
</g:CheckBox>
|
||||||
</td>
|
</td>
|
||||||
@@ -162,14 +169,14 @@ limitations under the License.
|
|||||||
ui:field='update'
|
ui:field='update'
|
||||||
text='Update'
|
text='Update'
|
||||||
styleName='{style.updateButton}'
|
styleName='{style.updateButton}'
|
||||||
tabIndex='14'>
|
tabIndex='15'>
|
||||||
<ui:attribute name='text'/>
|
<ui:attribute name='text'/>
|
||||||
</g:Button>
|
</g:Button>
|
||||||
<g:Button
|
<g:Button
|
||||||
ui:field='save'
|
ui:field='save'
|
||||||
text='Save'
|
text='Save'
|
||||||
styleName='{style.updateButton}'
|
styleName='{style.updateButton}'
|
||||||
tabIndex='15'>
|
tabIndex='16'>
|
||||||
<ui:attribute name='text'/>
|
<ui:attribute name='text'/>
|
||||||
</g:Button>
|
</g:Button>
|
||||||
</td>
|
</td>
|
||||||
|
@@ -23,4 +23,5 @@ public interface PrettifyConstants extends Constants {
|
|||||||
String wseTabAfterSpace();
|
String wseTabAfterSpace();
|
||||||
String wseTrailingSpace();
|
String wseTrailingSpace();
|
||||||
String wseBareCR();
|
String wseBareCR();
|
||||||
|
String leCR();
|
||||||
}
|
}
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
wseTabAfterSpace=Whitespace error: Tab after space
|
wseTabAfterSpace=Whitespace error: Tab after space
|
||||||
wseTrailingSpace=Whitespace error: Trailing space at end of line
|
wseTrailingSpace=Whitespace error: Trailing space at end of line
|
||||||
wseBareCR=Whitespace error: CR without LF
|
wseBareCR=CR without LF
|
||||||
|
leCR=Carriage Return
|
||||||
|
@@ -335,6 +335,10 @@ public abstract class PrettyFormatter implements SparseHtmlFile {
|
|||||||
html = showTrailingWhitespace(html);
|
html = showTrailingWhitespace(html);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (diffPrefs.isShowLineEndings()){
|
||||||
|
html = showLineEndings(html);
|
||||||
|
}
|
||||||
|
|
||||||
if (diffPrefs.isShowTabs()) {
|
if (diffPrefs.isShowTabs()) {
|
||||||
String t = 1 < diffPrefs.getTabSize() ? "\t" : "";
|
String t = 1 < diffPrefs.getTabSize() ? "\t" : "";
|
||||||
html = html.replaceAll("\t", "<span class=\"vt\">\u00BB</span>" + t);
|
html = html.replaceAll("\t", "<span class=\"vt\">\u00BB</span>" + t);
|
||||||
@@ -449,12 +453,11 @@ public abstract class PrettyFormatter implements SparseHtmlFile {
|
|||||||
|
|
||||||
} else if (end) {
|
} else if (end) {
|
||||||
if (cr == src.length() - 1) {
|
if (cr == src.length() - 1) {
|
||||||
buf.append(src.substring(0, cr));
|
buf.append(src.substring(0, cr + 1));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (cr == src.length() - 2 && src.charAt(cr + 1) == '\n') {
|
} else if (cr == src.length() - 2 && src.charAt(cr + 1) == '\n') {
|
||||||
buf.append(src.substring(0, cr));
|
buf.append(src);
|
||||||
buf.append('\n');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -499,6 +502,14 @@ public abstract class PrettyFormatter implements SparseHtmlFile {
|
|||||||
return src;
|
return src;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SafeHtml showLineEndings(SafeHtml src) {
|
||||||
|
final String r = "<span class=\"lecr\""
|
||||||
|
+ " title=\"" + PrettifyConstants.C.leCR() + "\"" //
|
||||||
|
+ ">\\\\r</span>";
|
||||||
|
src = src.replaceAll("\r", r);
|
||||||
|
return src;
|
||||||
|
}
|
||||||
|
|
||||||
private String expandTabs(String html) {
|
private String expandTabs(String html) {
|
||||||
StringBuilder tmp = new StringBuilder();
|
StringBuilder tmp = new StringBuilder();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@external .wse;
|
@external .wse;
|
||||||
|
@external .lecr;
|
||||||
@external .vt;
|
@external .vt;
|
||||||
@external .wdd;
|
@external .wdd;
|
||||||
@external .wdi;
|
@external .wdi;
|
||||||
@@ -35,6 +36,19 @@
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.lecr {
|
||||||
|
border-bottom: #aaaaaa 1px dashed;
|
||||||
|
border-left: #aaaaaa 1px dashed;
|
||||||
|
padding-bottom: 0px;
|
||||||
|
margin: 0px 2px;
|
||||||
|
padding-left: 2px;
|
||||||
|
padding-right: 2px;
|
||||||
|
border-top: #aaaaaa 1px dashed;
|
||||||
|
border-right: #aaaaaa 1px dashed;
|
||||||
|
padding-top: 0px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
.vt,
|
.vt,
|
||||||
.vt .str,
|
.vt .str,
|
||||||
.vt .kwd,
|
.vt .kwd,
|
||||||
|
@@ -62,6 +62,7 @@ public class AccountDiffPreference {
|
|||||||
p.setLineLength(100);
|
p.setLineLength(100);
|
||||||
p.setSyntaxHighlighting(true);
|
p.setSyntaxHighlighting(true);
|
||||||
p.setShowWhitespaceErrors(true);
|
p.setShowWhitespaceErrors(true);
|
||||||
|
p.setShowLineEndings(true);
|
||||||
p.setIntralineDifference(true);
|
p.setIntralineDifference(true);
|
||||||
p.setShowTabs(true);
|
p.setShowTabs(true);
|
||||||
p.setContext(DEFAULT_CONTEXT);
|
p.setContext(DEFAULT_CONTEXT);
|
||||||
@@ -88,28 +89,31 @@ public class AccountDiffPreference {
|
|||||||
protected boolean showWhitespaceErrors;
|
protected boolean showWhitespaceErrors;
|
||||||
|
|
||||||
@Column(id = 7)
|
@Column(id = 7)
|
||||||
protected boolean intralineDifference;
|
protected boolean showLineEndings;
|
||||||
|
|
||||||
@Column(id = 8)
|
@Column(id = 8)
|
||||||
|
protected boolean intralineDifference;
|
||||||
|
|
||||||
|
@Column(id = 9)
|
||||||
protected boolean showTabs;
|
protected boolean showTabs;
|
||||||
|
|
||||||
/** Number of lines of context when viewing a patch. */
|
/** Number of lines of context when viewing a patch. */
|
||||||
@Column(id = 9)
|
@Column(id = 10)
|
||||||
protected short context;
|
protected short context;
|
||||||
|
|
||||||
@Column(id = 10)
|
@Column(id = 11)
|
||||||
protected boolean skipDeleted;
|
protected boolean skipDeleted;
|
||||||
|
|
||||||
@Column(id = 11)
|
@Column(id = 12)
|
||||||
protected boolean skipUncommented;
|
protected boolean skipUncommented;
|
||||||
|
|
||||||
@Column(id = 12)
|
@Column(id = 13)
|
||||||
protected boolean expandAllComments;
|
protected boolean expandAllComments;
|
||||||
|
|
||||||
@Column(id = 13)
|
@Column(id = 14)
|
||||||
protected boolean retainHeader;
|
protected boolean retainHeader;
|
||||||
|
|
||||||
@Column(id = 14)
|
@Column(id = 15)
|
||||||
protected boolean manualReview;
|
protected boolean manualReview;
|
||||||
|
|
||||||
protected AccountDiffPreference() {
|
protected AccountDiffPreference() {
|
||||||
@@ -126,6 +130,7 @@ public class AccountDiffPreference {
|
|||||||
this.lineLength = p.lineLength;
|
this.lineLength = p.lineLength;
|
||||||
this.syntaxHighlighting = p.syntaxHighlighting;
|
this.syntaxHighlighting = p.syntaxHighlighting;
|
||||||
this.showWhitespaceErrors = p.showWhitespaceErrors;
|
this.showWhitespaceErrors = p.showWhitespaceErrors;
|
||||||
|
this.showLineEndings = p.showLineEndings;
|
||||||
this.intralineDifference = p.intralineDifference;
|
this.intralineDifference = p.intralineDifference;
|
||||||
this.showTabs = p.showTabs;
|
this.showTabs = p.showTabs;
|
||||||
this.skipDeleted = p.skipDeleted;
|
this.skipDeleted = p.skipDeleted;
|
||||||
@@ -180,6 +185,14 @@ public class AccountDiffPreference {
|
|||||||
this.showWhitespaceErrors = showWhitespaceErrors;
|
this.showWhitespaceErrors = showWhitespaceErrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isShowLineEndings() {
|
||||||
|
return showLineEndings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShowLineEndings(boolean showLineEndings) {
|
||||||
|
this.showLineEndings = showLineEndings;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isIntralineDifference() {
|
public boolean isIntralineDifference() {
|
||||||
return intralineDifference;
|
return intralineDifference;
|
||||||
}
|
}
|
||||||
|
@@ -32,7 +32,7 @@ import java.util.List;
|
|||||||
/** A version of the database schema. */
|
/** A version of the database schema. */
|
||||||
public abstract class SchemaVersion {
|
public abstract class SchemaVersion {
|
||||||
/** The current schema version. */
|
/** The current schema version. */
|
||||||
public static final Class<Schema_70> C = Schema_70.class;
|
public static final Class<Schema_71> C = Schema_71.class;
|
||||||
|
|
||||||
public static class Module extends AbstractModule {
|
public static class Module extends AbstractModule {
|
||||||
@Override
|
@Override
|
||||||
|
@@ -0,0 +1,43 @@
|
|||||||
|
// Copyright (C) 2012 The Android Open Source Project
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package com.google.gerrit.server.schema;
|
||||||
|
|
||||||
|
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||||
|
import com.google.gwtorm.jdbc.JdbcSchema;
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.Provider;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
|
||||||
|
|
||||||
|
public class Schema_71 extends SchemaVersion {
|
||||||
|
@Inject
|
||||||
|
Schema_71(Provider<Schema_70> prior) {
|
||||||
|
super(prior);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void migrateData(final ReviewDb db, final UpdateUI ui)
|
||||||
|
throws SQLException {
|
||||||
|
final Statement stmt = ((JdbcSchema) db).getConnection().createStatement();
|
||||||
|
try {
|
||||||
|
stmt.executeUpdate("UPDATE account_diff_preferences SET show_line_endings='Y'");
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
stmt.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user