Label abbreviation feature is dead; kill it

Note: because this feature wasn't used at all, there is no need for
new schema version with automagic gerrit.config clean up.

Bug: issue 2618
Change-Id: Ic129ca43c21c1955b842d61b84c515d622711ced
This commit is contained in:
David Ostrovsky
2014-06-12 10:06:35 +02:00
committed by Dave Borowitz
parent 1e05b52046
commit 4f0c338788
7 changed files with 3 additions and 43 deletions

View File

@@ -183,14 +183,6 @@ range for a user. In that case the score that will get set in the Reply
box will be either the lowest or highest score in the permissible range. box will be either the lowest or highest score in the permissible range.
[[label_abbreviation]]
=== `label.Label-Name.abbreviation`
An abbreviated name for a label shown as a compact column header, for
example on project dashboards. Defaults to all the uppercase characters
in the label name, e.g. `Label-Name` is abbreviated by default as `LN`.
[[label_function]] [[label_function]]
=== `label.Label-Name.function` === `label.Label-Name.function`

View File

@@ -60,7 +60,7 @@ public class LabelType {
return name; return name;
} }
public static String defaultAbbreviation(String name) { private static String getAbbreviation(String name) {
StringBuilder abbr = new StringBuilder(); StringBuilder abbr = new StringBuilder();
for (int i = 0; i < name.length(); i++) { for (int i = 0; i < name.length(); i++) {
char c = name.charAt(i); char c = name.charAt(i);
@@ -128,7 +128,7 @@ public class LabelType {
values = sortValues(valueList); values = sortValues(valueList);
defaultValue = 0; defaultValue = 0;
abbreviation = defaultAbbreviation(name); abbreviation = getAbbreviation(name);
functionName = "MaxWithBlock"; functionName = "MaxWithBlock";
maxNegative = Short.MIN_VALUE; maxNegative = Short.MIN_VALUE;
@@ -151,14 +151,6 @@ public class LabelType {
return psa.getLabelId().get().equalsIgnoreCase(name); return psa.getLabelId().get().equalsIgnoreCase(name);
} }
public String getAbbreviation() {
return abbreviation;
}
public void setAbbreviation(String abbreviation) {
this.abbreviation = abbreviation;
}
public String getFunctionName() { public String getFunctionName() {
return functionName; return functionName;
} }

View File

@@ -130,7 +130,6 @@ public class ProjectConfig extends VersionedMetaData {
private static final String KEY_LOCAL_DEFAULT = "local-default"; private static final String KEY_LOCAL_DEFAULT = "local-default";
private static final String LABEL = "label"; private static final String LABEL = "label";
private static final String KEY_ABBREVIATION = "abbreviation";
private static final String KEY_FUNCTION = "function"; private static final String KEY_FUNCTION = "function";
private static final String KEY_DEFAULT_VALUE = "defaultValue"; private static final String KEY_DEFAULT_VALUE = "defaultValue";
private static final String KEY_COPY_MIN_SCORE = "copyMinScore"; private static final String KEY_COPY_MIN_SCORE = "copyMinScore";
@@ -673,10 +672,6 @@ public class ProjectConfig extends VersionedMetaData {
"Invalid label \"%s\"", name))); "Invalid label \"%s\"", name)));
continue; continue;
} }
String abbr = rc.getString(LABEL, name, KEY_ABBREVIATION);
if (abbr != null) {
label.setAbbreviation(abbr);
}
String functionName = Objects.firstNonNull( String functionName = Objects.firstNonNull(
rc.getString(LABEL, name, KEY_FUNCTION), "MaxWithBlock"); rc.getString(LABEL, name, KEY_FUNCTION), "MaxWithBlock");
@@ -1050,15 +1045,6 @@ public class ProjectConfig extends VersionedMetaData {
LabelType label = e.getValue(); LabelType label = e.getValue();
toUnset.remove(name); toUnset.remove(name);
rc.setString(LABEL, name, KEY_FUNCTION, label.getFunctionName()); rc.setString(LABEL, name, KEY_FUNCTION, label.getFunctionName());
if (!LabelType.defaultAbbreviation(name)
.equals(label.getAbbreviation())) {
rc.setString(
LABEL, name, KEY_ABBREVIATION, label.getAbbreviation());
} else {
rc.unset(LABEL, name, KEY_ABBREVIATION);
}
rc.setInt(LABEL, name, KEY_DEFAULT_VALUE, label.getDefaultValue()); rc.setInt(LABEL, name, KEY_DEFAULT_VALUE, label.getDefaultValue());
if (label.isCopyMinScore()) { if (label.isCopyMinScore()) {
rc.setBoolean(LABEL, name, KEY_COPY_MIN_SCORE, true); rc.setBoolean(LABEL, name, KEY_COPY_MIN_SCORE, true);

View File

@@ -103,12 +103,6 @@ class EqualsLabelPredicate extends IndexPredicate<ChangeData> {
return lt; return lt;
} }
} }
for (LabelType lt : types.getLabelTypes()) {
if (toFind.equalsIgnoreCase(lt.getAbbreviation())) {
return lt;
}
}
return null; return null;
} }

View File

@@ -215,7 +215,6 @@ public class AllProjectsCreator {
new LabelValue((short) 0, "No score"), new LabelValue((short) 0, "No score"),
new LabelValue((short) -1, "I would prefer this is not merged as is"), new LabelValue((short) -1, "I would prefer this is not merged as is"),
new LabelValue((short) -2, "This shall not be merged"))); new LabelValue((short) -2, "This shall not be merged")));
type.setAbbreviation("CR");
type.setCopyMinScore(true); type.setCopyMinScore(true);
c.getLabelSections().put(type.getName(), type); c.getLabelSections().put(type.getName(), type);
return type; return type;

View File

@@ -203,8 +203,7 @@ public class Schema_77 extends SchemaVersion {
Statement catStmt = ((JdbcSchema) db).getConnection().createStatement(); Statement catStmt = ((JdbcSchema) db).getConnection().createStatement();
try { try {
ResultSet catRs = catStmt.executeQuery( ResultSet catRs = catStmt.executeQuery(
"SELECT category_id, name, abbreviated_name, function_name, " "SELECT category_id, name, function_name, copy_min_score"
+ " copy_min_score"
+ " FROM approval_categories" + " FROM approval_categories"
+ " ORDER BY position, name"); + " ORDER BY position, name");
PreparedStatement valStmt = ((JdbcSchema) db).getConnection().prepareStatement( PreparedStatement valStmt = ((JdbcSchema) db).getConnection().prepareStatement(
@@ -224,7 +223,6 @@ public class Schema_77 extends SchemaVersion {
LegacyLabelType type = LegacyLabelType type =
new LegacyLabelType(getLabelName(catRs.getString("name")), values); new LegacyLabelType(getLabelName(catRs.getString("name")), values);
type.setId(id); type.setId(id);
type.setAbbreviation(catRs.getString("abbreviated_name"));
type.setFunctionName(catRs.getString("function_name")); type.setFunctionName(catRs.getString("function_name"));
type.setCopyMinScore("Y".equals(catRs.getString("copy_min_score"))); type.setCopyMinScore("Y".equals(catRs.getString("copy_min_score")));
types.add(type); types.add(type);

View File

@@ -128,7 +128,6 @@ public class SchemaCreatorTest {
LabelType codeReview = getLabelTypes().byLabel("Code-Review"); LabelType codeReview = getLabelTypes().byLabel("Code-Review");
assertNotNull(codeReview); assertNotNull(codeReview);
assertEquals("Code-Review", codeReview.getName()); assertEquals("Code-Review", codeReview.getName());
assertEquals("CR", codeReview.getAbbreviation());
assertEquals(0, codeReview.getDefaultValue()); assertEquals(0, codeReview.getDefaultValue());
assertEquals("MaxWithBlock", codeReview.getFunctionName()); assertEquals("MaxWithBlock", codeReview.getFunctionName());
assertTrue(codeReview.isCopyMinScore()); assertTrue(codeReview.isCopyMinScore());