Rename "topic:" to "intopic:" and "exacttopic:" to "topic:"

"Exact topic" is unwieldy to say/type. We wanted to get the change
that introduced it in faster so we could fix the correctness issue
with submitWholeTopic and get the schema upgrade process started. Now
we can go back and change the names to something more sensible.

The new name "intopic" is shorter and parallels the standard Google
search operator "inurl".

Change-Id: Ic7a41947392f24752a5524ad8365c0453c931a8b
This commit is contained in:
Dave Borowitz
2015-06-01 10:00:04 -07:00
parent 3736824e98
commit c751799f6d
12 changed files with 25 additions and 23 deletions

View File

@@ -153,8 +153,8 @@ expression patterns. The
link:http://www.brics.dk/automaton/[dk.brics.automaton
library] is used for evaluation of such patterns.
[[topic]]
topic:'TOPIC'::
[[intopic]]
intopic:'TOPIC'::
+
Changes whose designated topic contains 'TOPIC', using a full-text search.
+
@@ -163,8 +163,8 @@ expression patterns. The
link:http://www.brics.dk/automaton/[dk.brics.automaton
library] is used for evaluation of such patterns.
[[exacttopic]]
exacttopic:'TOPIC'::
[[topic]]
topic:'TOPIC'::
+
Changes whose designated topic matches 'TOPIC' exactly. This is
often combined with 'branch:' and 'project:' operators to select

View File

@@ -85,6 +85,7 @@ public class SearchSuggestOracle extends HighlightSuggestOracle {
suggestions.add("parentproject:");
suggestions.add("branch:");
suggestions.add("topic:");
suggestions.add("intopic:");
suggestions.add("ref:");
suggestions.add("tr:");
suggestions.add("bug:");

View File

@@ -200,7 +200,7 @@ public class RelatedChanges extends TabPanel {
if (info.topic() != null && !"".equals(info.topic())) {
StringBuilder topicQuery = new StringBuilder();
topicQuery.append("status:open");
topicQuery.append(" ").append(op("exacttopic", info.topic()));
topicQuery.append(" ").append(op("topic", info.topic()));
ChangeList.query(topicQuery.toString(),
EnumSet.of(ListChangesOption.CURRENT_REVISION,
ListChangesOption.CURRENT_COMMIT,

View File

@@ -86,7 +86,7 @@ class Topic extends Composite {
text.setText(info.topic());
text.setTargetHistoryToken(
PageLinks.toChangeQuery(
PageLinks.op("exacttopic", info.topic())));
PageLinks.op("topic", info.topic())));
}
}

View File

@@ -76,7 +76,7 @@ public class BranchLink extends InlineHyperlink {
}
if (topic != null && !topic.isEmpty()) {
query += " " + PageLinks.op("exacttopic", topic);
query += " " + PageLinks.op("topic", topic);
}
return query;

View File

@@ -67,7 +67,7 @@ public class GetRevisionActions implements ETagView<RevisionResource> {
Hasher h = Hashing.md5().newHasher();
CurrentUser user = rsrc.getControl().getCurrentUser();
try {
for (ChangeData c : queryProvider.get().byExactTopicOpen(topic)) {
for (ChangeData c : queryProvider.get().byTopicOpen(topic)) {
new ChangeResource(c.changeControl(), rebaseChange).prepareETag(h, user);
}
} catch (OrmException e){

View File

@@ -697,7 +697,7 @@ public class Submit implements RestModifyView<RevisionResource, SubmitInput>,
private List<ChangeData> getChangesByTopic(String topic) {
try {
return queryProvider.get().byExactTopicOpen(topic);
return queryProvider.get().byTopicOpen(topic);
} catch (OrmException e) {
throw new OrmRuntimeException(e);
}

View File

@@ -478,19 +478,19 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
}
@Operator
public Predicate<ChangeData> exacttopic(String name) {
public Predicate<ChangeData> topic(String name) {
return new ExactTopicPredicate(args.getSchema(), name);
}
@Operator
public Predicate<ChangeData> topic(String name) {
public Predicate<ChangeData> intopic(String name) {
if (name.startsWith("^")) {
return new RegexTopicPredicate(args.getSchema(), name);
}
if (name.isEmpty()) {
return new ExactTopicPredicate(args.getSchema(), name);
}
return new TopicPredicate(args.getSchema(), name, args.index);
return new FuzzyTopicPredicate(args.getSchema(), name, args.index);
}
@Operator

View File

@@ -28,7 +28,7 @@ import com.google.gerrit.server.query.Predicate;
import com.google.gerrit.server.query.QueryParseException;
import com.google.gwtorm.server.OrmException;
class TopicPredicate extends IndexPredicate<ChangeData> {
class FuzzyTopicPredicate extends IndexPredicate<ChangeData> {
private final ChangeIndex index;
@SuppressWarnings("deprecation")
@@ -36,7 +36,8 @@ class TopicPredicate extends IndexPredicate<ChangeData> {
return schema.getField(FUZZY_TOPIC, LEGACY_TOPIC3, LEGACY_TOPIC2).get();
}
TopicPredicate(Schema<ChangeData> schema, String topic, ChangeIndex index) {
FuzzyTopicPredicate(Schema<ChangeData> schema, String topic,
ChangeIndex index) {
super(topicField(schema), topic);
this.index = index;
}

View File

@@ -131,7 +131,7 @@ public class InternalChangeQuery {
return query(and(project(project), open()));
}
public List<ChangeData> byExactTopicOpen(String topic)
public List<ChangeData> byTopicOpen(String topic)
throws OrmException {
return query(and(new ExactTopicPredicate(schema(indexes), topic), open()));
}

View File

@@ -26,7 +26,7 @@ class RegexTopicPredicate extends RegexPredicate<ChangeData> {
private final RunAutomaton pattern;
RegexTopicPredicate(Schema<ChangeData> schema, String re) {
super(TopicPredicate.topicField(schema), re);
super(FuzzyTopicPredicate.topicField(schema), re);
if (re.startsWith("^")) {
re = re.substring(1);

View File

@@ -453,14 +453,14 @@ public abstract class AbstractQueryChangesTest {
Change change5 = newChange(repo, null, null, null, null).insert();
assertQuery("topic:foo");
assertQuery("topic:feature1", change1);
assertQuery("topic:feature2", change4, change3, change2);
assertQuery("exacttopic:feature2", change2);
assertQuery("topic:feature2", change4, change3, change2);
assertQuery("topic:fixup", change4);
assertQuery("exacttopic:\"\"", change5);
assertQuery("intopic:foo");
assertQuery("intopic:feature1", change1);
assertQuery("intopic:feature2", change4, change3, change2);
assertQuery("topic:feature2", change2);
assertQuery("intopic:feature2", change4, change3, change2);
assertQuery("intopic:fixup", change4);
assertQuery("topic:\"\"", change5);
assertQuery("intopic:\"\"", change5);
}
@Test