Merge changes I340efe7f,I7fdccee7

* changes:
  ChangeScreen2: add Gerrit config and user preference
  Create buck.properties during tools/eclipse/project.py
This commit is contained in:
Shawn Pearce 2013-09-24 19:36:11 +00:00 committed by Gerrit Code Review
commit 2dd0fc86a5
32 changed files with 164 additions and 59 deletions

View File

@ -1334,6 +1334,7 @@ form:
----
fetch-cmd some://url/to/commit-msg .git/hooks/commit-msg ; chmod +x .git/hooks/commit-msg
----
+
By default unset; falls back to using scp from the canonical SSH host,
or curl from the canonical HTTP URL for the server. Only necessary if a
@ -1357,6 +1358,11 @@ Gerrit service. By default this links to the upstream Gerrit
Code Review's own bug tracker but could be directed to the system
administrator's ticket queue.
[[gerrit.changeScreen]]gerrit.changeScreen::
+
Default change screen UI to direct users to. Valid values are
`OLD_UI` and `CHANGE_SCREEN2`. Default is `OLD_UI`.
[[gitweb]]Section gitweb
~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -54,12 +54,8 @@ public class PageLinks {
return "/c/" + c + "/";
}
public static String toChange2(final Change.Id c) {
return "/c2/" + c + "/";
}
public static String toChange2(Change.Id c, String p) {
return "/c2/" + c + "/" + p;
public static String toChange(Change.Id c, String p) {
return "/c/" + c + "/" + p;
}
public static String toChange(final PatchSet.Id ps) {

View File

@ -16,6 +16,7 @@ package com.google.gerrit.common.data;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Account.FieldName;
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences;
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DownloadCommand;
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DownloadScheme;
import com.google.gerrit.reviewdb.client.AuthType;
@ -51,6 +52,7 @@ public class GerritConfig implements Cloneable {
protected String anonymousCowardName;
protected int suggestFrom;
protected int changeUpdateDelay;
protected AccountGeneralPreferences.ChangeScreen changeScreen;
public String getLoginUrl() {
return loginUrl;
@ -270,4 +272,12 @@ public class GerritConfig implements Cloneable {
public void setChangeUpdateDelay(int seconds) {
changeUpdateDelay = seconds;
}
public AccountGeneralPreferences.ChangeScreen getChangeScreen() {
return changeScreen;
}
public void setChangeScreen(AccountGeneralPreferences.ChangeScreen ui) {
this.changeScreen = ui;
}
}

View File

@ -81,6 +81,7 @@ import com.google.gerrit.common.PageLinks;
import com.google.gerrit.common.data.PatchSetDetail;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DiffView;
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences;
import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Patch;
@ -93,8 +94,6 @@ import com.google.gwt.user.client.Window;
import com.google.gwtorm.client.KeyUtil;
public class Dispatcher {
private static boolean useChangeScreen2;
public static String toPatchSideBySide(final Patch.Key id) {
return toPatch("", null, id);
}
@ -203,9 +202,6 @@ public class Dispatcher {
} else if (matchPrefix("/c/", token)) {
change(token);
} else if (matchPrefix("/c2/", token)) {
change2(token);
} else if (matchExact(MINE, token)) {
Gerrit.display(token, mine(token));
@ -480,7 +476,7 @@ public class Dispatcher {
if (rest.isEmpty()) {
Gerrit.display(token, panel== null
? (useChangeScreen2
? (isChangeScreen2()
? new ChangeScreen2(id, null, false)
: new ChangeScreen(id))
: new NotFoundScreen());
@ -513,7 +509,7 @@ public class Dispatcher {
patch(token, base, p, 0, null, null, panel);
} else {
if (panel == null) {
Gerrit.display(token, useChangeScreen2
Gerrit.display(token, isChangeScreen2()
? new ChangeScreen2(id, String.valueOf(ps.get()), false)
: new ChangeScreen(id));
} else if ("publish".equals(panel)) {
@ -524,19 +520,17 @@ public class Dispatcher {
}
}
private static void change2(final String token) {
String rest = skip(token);
Change.Id id;
int s = rest.indexOf('/');
if (0 <= s) {
id = Change.Id.parse(rest.substring(0, s));
rest = rest.substring(s + 1);
} else {
id = Change.Id.parse(rest);
rest = "";
private static boolean isChangeScreen2() {
AccountGeneralPreferences.ChangeScreen ui = null;
if (Gerrit.isSignedIn()) {
ui = Gerrit.getUserAccount()
.getGeneralPreferences()
.getChangeScreen();
}
useChangeScreen2 = true;
Gerrit.display(token, new ChangeScreen2(id, rest, false));
if (ui == null) {
ui = Gerrit.getConfig().getChangeScreen();
}
return ui == AccountGeneralPreferences.ChangeScreen.CHANGE_SCREEN2;
}
private static void publish(final PatchSet.Id ps) {

View File

@ -26,6 +26,7 @@ public interface AccountConstants extends Constants {
String accountId();
String commentVisibilityLabel();
String changeScreenLabel();
String diffViewLabel();
String maximumPageSizeFieldLabel();
String dateFormatLabel();
@ -38,6 +39,9 @@ public interface AccountConstants extends Constants {
String buttonSaveChanges();
String showRelativeDateInChangeTable();
String changeScreenOldUi();
String changeScreenNewUi();
String tabAccountSummary();
String tabPreferences();
String tabWatchedProjects();

View File

@ -12,12 +12,16 @@ reversePatchSetOrder = Display Patch Sets In Reverse Order
showUsernameInReviewCategory = Display Person Name In Review Category
maximumPageSizeFieldLabel = Maximum Page Size:
commentVisibilityLabel = Comment Visibility:
diffViewLabel = Diff View (ChangeScreen2 only):
changeScreenLabel = Change View:
diffViewLabel = Diff View (Change Screen 2):
dateFormatLabel = Date/Time Format:
contextWholeFile = Whole File
buttonSaveChanges = Save Changes
showRelativeDateInChangeTable = Show Relative Dates in Changes Table
changeScreenOldUi = Old Screen
changeScreenNewUi = Change Screen 2
tabAccountSummary = Profile
tabPreferences = Preferences
tabWatchedProjects = Watched Projects

View File

@ -21,6 +21,7 @@ import java.util.Date;
public interface AccountMessages extends Messages {
String lines(short cnt);
String rowsPerPage(short cnt);
String changeScreenServerDefault(String d);
String enterIAGREE(String iagree);
String contactOnFile(Date lastDate);
}

View File

@ -1,5 +1,7 @@
lines = {0} lines
rowsPerPage = {0} rows per page
changeScreenServerDefault = Server Default ({0})
enterIAGREE = (enter {0} in the box to the left)
contactOnFile = Contact information last updated on {0,date,medium} at {0,time,short}.

View File

@ -48,6 +48,7 @@ public class MyPreferencesScreen extends SettingsScreen {
private ListBox dateFormat;
private ListBox timeFormat;
private ListBox commentVisibilityStrategy;
private ListBox changeScreen;
private ListBox diffView;
private Button save;
@ -68,30 +69,36 @@ public class MyPreferencesScreen extends SettingsScreen {
commentVisibilityStrategy = new ListBox();
commentVisibilityStrategy.addItem(
com.google.gerrit.client.changes.Util.C.messageCollapseAll(),
AccountGeneralPreferences.CommentVisibilityStrategy.COLLAPSE_ALL.name()
);
AccountGeneralPreferences.CommentVisibilityStrategy.COLLAPSE_ALL.name());
commentVisibilityStrategy.addItem(
com.google.gerrit.client.changes.Util.C.messageExpandMostRecent(),
AccountGeneralPreferences.CommentVisibilityStrategy.EXPAND_MOST_RECENT.name()
);
AccountGeneralPreferences.CommentVisibilityStrategy.EXPAND_MOST_RECENT.name());
commentVisibilityStrategy.addItem(
com.google.gerrit.client.changes.Util.C.messageExpandRecent(),
AccountGeneralPreferences.CommentVisibilityStrategy.EXPAND_RECENT.name()
);
AccountGeneralPreferences.CommentVisibilityStrategy.EXPAND_RECENT.name());
commentVisibilityStrategy.addItem(
com.google.gerrit.client.changes.Util.C.messageExpandAll(),
AccountGeneralPreferences.CommentVisibilityStrategy.EXPAND_ALL.name()
);
AccountGeneralPreferences.CommentVisibilityStrategy.EXPAND_ALL.name());
changeScreen = new ListBox();
changeScreen.addItem(
Util.M.changeScreenServerDefault(
getLabel(Gerrit.getConfig().getChangeScreen())),
"");
changeScreen.addItem(
Util.C.changeScreenOldUi(),
AccountGeneralPreferences.ChangeScreen.OLD_UI.name());
changeScreen.addItem(
Util.C.changeScreenNewUi(),
AccountGeneralPreferences.ChangeScreen.CHANGE_SCREEN2.name());
diffView = new ListBox();
diffView.addItem(
com.google.gerrit.client.changes.Util.C.sideBySide(),
AccountGeneralPreferences.DiffView.SIDE_BY_SIDE.name()
);
AccountGeneralPreferences.DiffView.SIDE_BY_SIDE.name());
diffView.addItem(
com.google.gerrit.client.changes.Util.C.unifiedDiff(),
AccountGeneralPreferences.DiffView.UNIFIED_DIFF.name()
);
AccountGeneralPreferences.DiffView.UNIFIED_DIFF.name());
Date now = new Date();
dateFormat = new ListBox();
@ -129,7 +136,7 @@ public class MyPreferencesScreen extends SettingsScreen {
relativeDateInChangeTable = new CheckBox(Util.C.showRelativeDateInChangeTable());
final Grid formGrid = new Grid(10, 2);
final Grid formGrid = new Grid(11, 2);
int row = 0;
formGrid.setText(row, labelIdx, "");
@ -168,6 +175,10 @@ public class MyPreferencesScreen extends SettingsScreen {
formGrid.setWidget(row, fieldIdx, commentVisibilityStrategy);
row++;
formGrid.setText(row, labelIdx, Util.C.changeScreenLabel());
formGrid.setWidget(row, fieldIdx, changeScreen);
row++;
formGrid.setText(row, labelIdx, Util.C.diffViewLabel());
formGrid.setWidget(row, fieldIdx, diffView);
row++;
@ -195,6 +206,7 @@ public class MyPreferencesScreen extends SettingsScreen {
e.listenTo(timeFormat);
e.listenTo(relativeDateInChangeTable);
e.listenTo(commentVisibilityStrategy);
e.listenTo(changeScreen);
e.listenTo(diffView);
}
@ -219,6 +231,7 @@ public class MyPreferencesScreen extends SettingsScreen {
timeFormat.setEnabled(on);
relativeDateInChangeTable.setEnabled(on);
commentVisibilityStrategy.setEnabled(on);
changeScreen.setEnabled(on);
diffView.setEnabled(on);
}
@ -237,6 +250,9 @@ public class MyPreferencesScreen extends SettingsScreen {
setListBox(commentVisibilityStrategy,
AccountGeneralPreferences.CommentVisibilityStrategy.EXPAND_RECENT,
p.getCommentVisibilityStrategy());
setListBox(changeScreen,
null,
p.getChangeScreen());
setListBox(diffView,
AccountGeneralPreferences.DiffView.SIDE_BY_SIDE,
p.getDiffView());
@ -249,7 +265,8 @@ public class MyPreferencesScreen extends SettingsScreen {
private <T extends Enum<?>> void setListBox(final ListBox f,
final T defaultValue, final T currentValue) {
setListBox(f, defaultValue.name(), //
setListBox(f,
defaultValue != null ? defaultValue.name() : "",
currentValue != null ? currentValue.name() : "");
}
@ -280,6 +297,9 @@ public class MyPreferencesScreen extends SettingsScreen {
final int idx = f.getSelectedIndex();
if (0 <= idx) {
String v = f.getValue(idx);
if ("".equals(v)) {
return defaultValue;
}
for (T t : all) {
if (t.name().equals(v)) {
return t;
@ -310,6 +330,9 @@ public class MyPreferencesScreen extends SettingsScreen {
p.setDiffView(getListBox(diffView,
AccountGeneralPreferences.DiffView.SIDE_BY_SIDE,
AccountGeneralPreferences.DiffView.values()));
p.setChangeScreen(getListBox(changeScreen,
null,
AccountGeneralPreferences.ChangeScreen.values()));
enable(false);
save.setEnabled(false);
@ -330,4 +353,18 @@ public class MyPreferencesScreen extends SettingsScreen {
}
});
}
private static String getLabel(AccountGeneralPreferences.ChangeScreen ui) {
if (ui == null) {
return "";
}
switch (ui) {
case OLD_UI:
return Util.C.changeScreenOldUi();
case CHANGE_SCREEN2:
return Util.C.changeScreenNewUi();
default:
return ui.name();
}
}
}

View File

@ -38,7 +38,7 @@ class DefaultActions {
Window.alert(str.asString());
}
}
Gerrit.display(PageLinks.toChange2(id));
Gerrit.display(PageLinks.toChange(id));
}
};
if ("PUT".equalsIgnoreCase(action.method())) {

View File

@ -34,7 +34,7 @@ class AbandonAction extends ActionMessageBox {
ChangeApi.abandon(id.get(), message, new GerritCallback<ChangeInfo>() {
@Override
public void onSuccess(ChangeInfo result) {
Gerrit.display(PageLinks.toChange2(id));
Gerrit.display(PageLinks.toChange(id));
hide();
}
});

View File

@ -51,7 +51,7 @@ class CherryPickAction {
public void onSuccess(ChangeInfo result) {
sent = true;
hide();
Gerrit.display(PageLinks.toChange2(result.legacy_id()));
Gerrit.display(PageLinks.toChange(result.legacy_id()));
}
@Override

View File

@ -80,7 +80,7 @@ class EditMessageBox extends Composite {
new GerritCallback<JavaScriptObject>() {
@Override
public void onSuccess(JavaScriptObject msg) {
Gerrit.display(PageLinks.toChange2(changeId));
Gerrit.display(PageLinks.toChange(changeId));
hide();
};
});

View File

@ -112,7 +112,7 @@ class QuickApprove extends Button implements ClickHandler {
.post(input, new GerritCallback<ReviewInput>() {
@Override
public void onSuccess(ReviewInput result) {
Gerrit.display(PageLinks.toChange2(changeId));
Gerrit.display(PageLinks.toChange(changeId));
}
});
}

View File

@ -26,7 +26,7 @@ class RebaseAction {
ChangeApi.rebase(id.get(), revision,
new GerritCallback<ChangeInfo>() {
public void onSuccess(ChangeInfo result) {
Gerrit.display(PageLinks.toChange2(id));
Gerrit.display(PageLinks.toChange(id));
}
});
}

View File

@ -174,7 +174,7 @@ class RelatedChanges extends Composite {
private String url(ChangeAndCommit c) {
if (c.has_change_number() && c.has_revision_number()) {
PatchSet.Id id = c.patch_set_id();
return "#" + PageLinks.toChange2(
return "#" + PageLinks.toChange(
id.getParentKey(),
String.valueOf(id.get()));
}

View File

@ -47,7 +47,7 @@ class Reload extends Image implements ClickHandler,
}
void reload() {
Gerrit.display(PageLinks.toChange2(changeId));
Gerrit.display(PageLinks.toChange(changeId));
}
@Override

View File

@ -144,7 +144,7 @@ class ReplyBox extends Composite {
.post(in, new GerritCallback<ReviewInput>() {
@Override
public void onSuccess(ReviewInput result) {
Gerrit.display(PageLinks.toChange2(
Gerrit.display(PageLinks.toChange(
psId.getParentKey(),
String.valueOf(psId.get())));
}

View File

@ -34,7 +34,7 @@ class RestoreAction extends ActionMessageBox {
ChangeApi.restore(id.get(), message, new GerritCallback<ChangeInfo>() {
@Override
public void onSuccess(ChangeInfo result) {
Gerrit.display(PageLinks.toChange2(id));
Gerrit.display(PageLinks.toChange(id));
hide();
}
});

View File

@ -46,7 +46,7 @@ class RevertAction {
public void onSuccess(ChangeInfo result) {
sent = true;
hide();
Gerrit.display(PageLinks.toChange2(result.legacy_id()));
Gerrit.display(PageLinks.toChange(result.legacy_id()));
}
@Override

View File

@ -203,7 +203,7 @@ class RevisionsBox extends Composite {
}
private String url(RevisionInfo r) {
return PageLinks.toChange2(
return PageLinks.toChange(
changeId,
String.valueOf(r._number()));
}

View File

@ -40,7 +40,7 @@ class SubmitAction {
}
private void redisplay() {
Gerrit.display(PageLinks.toChange2(id));
Gerrit.display(PageLinks.toChange(id));
}
});
}

View File

@ -134,7 +134,7 @@ class Topic extends Composite {
new GerritCallback<String>() {
@Override
public void onSuccess(String result) {
Gerrit.display(PageLinks.toChange2(
Gerrit.display(PageLinks.toChange(
psId.getParentKey(),
String.valueOf(psId.get())));
}

View File

@ -73,7 +73,7 @@ class Header extends Composite {
this.path = path;
SafeHtml.setInnerHTML(filePath, formatPath(path));
up.setTargetHistoryToken(PageLinks.toChange2(
up.setTargetHistoryToken(PageLinks.toChange(
patchSetId.getParentKey(),
String.valueOf(patchSetId.get())));
}

View File

@ -1096,7 +1096,7 @@ public class SideBySide2 extends Screen {
public void run() {
String rev = String.valueOf(revision.get());
Gerrit.display(
PageLinks.toChange2(changeId, rev),
PageLinks.toChange(changeId, rev),
new ChangeScreen2(changeId, rev, openReplyBox));
}
};

View File

@ -31,7 +31,7 @@ class UpToChangeCommand2 extends KeyCommand {
@Override
public void onKeyPress(final KeyPressEvent event) {
Gerrit.display(PageLinks.toChange2(
Gerrit.display(PageLinks.toChange(
revision.getParentKey(),
String.valueOf(revision.get())));
}

View File

@ -17,6 +17,7 @@ package com.google.gerrit.httpd;
import com.google.gerrit.common.data.GerritConfig;
import com.google.gerrit.common.data.GitwebConfig;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences;
import com.google.gerrit.server.account.Realm;
import com.google.gerrit.server.config.AllProjectsName;
import com.google.gerrit.server.config.AnonymousCowardName;
@ -124,6 +125,9 @@ class GerritConfigProvider implements Provider<GerritConfig> {
config.setSuggestFrom(cfg.getInt("suggest", "from", 0));
config.setChangeUpdateDelay((int) ConfigUtil.getTimeUnit(
cfg, "change", null, "updateDelay", 30, TimeUnit.SECONDS));
config.setChangeScreen(cfg.getEnum(
"gerrit", null, "changeScreen",
AccountGeneralPreferences.ChangeScreen.OLD_UI));
config.setReportBugUrl(cfg.getString("gerrit", null, "reportBugUrl"));
if (config.getReportBugUrl() == null) {

View File

@ -77,6 +77,11 @@ public final class AccountGeneralPreferences {
UNIFIED_DIFF
}
public static enum ChangeScreen {
OLD_UI,
CHANGE_SCREEN2
}
public static enum TimeFormat {
/** 12-hour clock: 1:15 am, 2:13 pm */
HHMM_12("h:mm a"),
@ -144,6 +149,9 @@ public final class AccountGeneralPreferences {
@Column(id = 14, length = 20, notNull = false)
protected String diffView;
@Column(id = 15, length = 20, notNull = false)
protected String changeScreen;
public AccountGeneralPreferences() {
}
@ -278,6 +286,14 @@ public final class AccountGeneralPreferences {
this.diffView = diffView.name();
}
public ChangeScreen getChangeScreen() {
return changeScreen != null ? ChangeScreen.valueOf(changeScreen) : null;
}
public void setChangeScreen(ChangeScreen ui) {
changeScreen = ui != null ? ui.name() : null;
}
public void resetToDefaults() {
maximumPageSize = DEFAULT_PAGESIZE;
showSiteHeader = true;
@ -292,5 +308,6 @@ public final class AccountGeneralPreferences {
relativeDateInChangeTable = false;
commentVisibilityStrategy = null;
diffView = null;
changeScreen = null;
}
}

View File

@ -17,6 +17,7 @@ package com.google.gerrit.server.account;
import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.RestReadView;
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences;
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.ChangeScreen;
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.CommentVisibilityStrategy;
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DateFormat;
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DiffView;
@ -61,6 +62,7 @@ public class GetPreferences implements RestReadView<AccountResource> {
Boolean relativeDateInChangeTable;
CommentVisibilityStrategy commentVisibilityStrategy;
DiffView diffView;
ChangeScreen changeScreen;
PreferenceInfo(AccountGeneralPreferences p) {
changesPerPage = p.getMaximumPageSize();
@ -76,6 +78,7 @@ public class GetPreferences implements RestReadView<AccountResource> {
relativeDateInChangeTable = p.isRelativeDateInChangeTable() ? true : null;
commentVisibilityStrategy = p.getCommentVisibilityStrategy();
diffView = p.getDiffView();
changeScreen = p.getChangeScreen();
}
}
}

View File

@ -32,7 +32,7 @@ import java.util.List;
/** A version of the database schema. */
public abstract class SchemaVersion {
/** The current schema version. */
public static final Class<Schema_83> C = Schema_83.class;
public static final Class<Schema_84> C = Schema_84.class;
public static class Module extends AbstractModule {
@Override

View File

@ -0,0 +1,26 @@
// Copyright (C) 2013 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.inject.Inject;
import com.google.inject.Provider;
public class Schema_84 extends SchemaVersion {
@Inject
Schema_84(Provider<Schema_83> prior) {
super(prior);
}
}

View File

@ -151,6 +151,7 @@ gen_project()
gen_classpath()
try:
check_call(['buck', 'build'] + MAIN + GWT)
targets = ['//tools:buck.properties'] + MAIN + GWT
check_call(['buck', 'build'] + targets)
except CalledProcessError as err:
exit(1)