ChangeScreen#loadConfigInfo: factor out current revision initialization
Current revision initialization is needed only once when change info is loaded. Factor it out from loadConfigInfo() method that is called multiple times on different actions. Change-Id: I5687092475b2892a885f131ae021c8bfb0609fb0
This commit is contained in:
parent
4a13634636
commit
2c71febfee
@ -279,11 +279,51 @@ public class ChangeScreen extends Screen {
|
||||
public void onSuccess(ChangeInfo info) {
|
||||
info.init();
|
||||
addExtensionPoints(info);
|
||||
initCurrentRevision(info);
|
||||
loadConfigInfo(info, base);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
private RevisionInfo initCurrentRevision(ChangeInfo info) {
|
||||
info.revisions().copyKeysIntoChildren("name");
|
||||
if (edit != null) {
|
||||
edit.setName(edit.commit().commit());
|
||||
info.setEdit(edit);
|
||||
if (edit.hasFiles()) {
|
||||
edit.files().copyKeysIntoChildren("path");
|
||||
}
|
||||
info.revisions().put(edit.name(), RevisionInfo.fromEdit(edit));
|
||||
JsArray<RevisionInfo> list = info.revisions().values();
|
||||
|
||||
// Edit is converted to a regular revision (with number = 0) and
|
||||
// added to the list of revisions. Additionally under certain
|
||||
// circumstances change edit is assigned to be the current revision
|
||||
// and is selected to be shown on the change screen.
|
||||
// We have two different strategies to assign edit to the current ps:
|
||||
// 1. revision == null: no revision is selected, so use the edit only
|
||||
// if it is based on the latest patch set
|
||||
// 2. edit was selected explicitly from ps drop down:
|
||||
// use the edit regardless of which patch set it is based on
|
||||
if (revision == null) {
|
||||
RevisionInfo.sortRevisionInfoByNumber(list);
|
||||
RevisionInfo rev = list.get(list.length() - 1);
|
||||
if (rev.isEdit()) {
|
||||
info.setCurrentRevision(rev.name());
|
||||
}
|
||||
} else if (revision.equals("edit") || revision.equals("0")) {
|
||||
for (int i = 0; i < list.length(); i++) {
|
||||
RevisionInfo r = list.get(i);
|
||||
if (r.isEdit()) {
|
||||
info.setCurrentRevision(r.name());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return resolveRevisionToDisplay(info);
|
||||
}
|
||||
|
||||
private void addExtensionPoints(ChangeInfo change) {
|
||||
addExtensionPoint(GerritUiExtensionPoint.CHANGE_SCREEN_HEADER,
|
||||
headerExtension, change);
|
||||
@ -859,42 +899,7 @@ public class ChangeScreen extends Screen {
|
||||
}
|
||||
|
||||
private void loadConfigInfo(final ChangeInfo info, String base) {
|
||||
info.revisions().copyKeysIntoChildren("name");
|
||||
if (edit != null) {
|
||||
edit.setName(edit.commit().commit());
|
||||
info.setEdit(edit);
|
||||
if (edit.hasFiles()) {
|
||||
edit.files().copyKeysIntoChildren("path");
|
||||
}
|
||||
info.revisions().put(edit.name(), RevisionInfo.fromEdit(edit));
|
||||
JsArray<RevisionInfo> list = info.revisions().values();
|
||||
|
||||
// Edit is converted to a regular revision (with number = 0) and
|
||||
// added to the list of revisions. Additionally under certain
|
||||
// circumstances change edit is assigned to be the current revision
|
||||
// and is selected to be shown on the change screen.
|
||||
// We have two different strategies to assign edit to the current ps:
|
||||
// 1. revision == null: no revision is selected, so use the edit only
|
||||
// if it is based on the latest patch set
|
||||
// 2. edit was selected explicitly from ps drop down:
|
||||
// use the edit regardless of which patch set it is based on
|
||||
if (revision == null) {
|
||||
RevisionInfo.sortRevisionInfoByNumber(list);
|
||||
RevisionInfo rev = list.get(list.length() - 1);
|
||||
if (rev.isEdit()) {
|
||||
info.setCurrentRevision(rev.name());
|
||||
}
|
||||
} else if (revision.equals("edit") || revision.equals("0")) {
|
||||
for (int i = 0; i < list.length(); i++) {
|
||||
RevisionInfo r = list.get(i);
|
||||
if (r.isEdit()) {
|
||||
info.setCurrentRevision(r.name());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
RevisionInfo rev = resolveRevisionToDisplay(info);
|
||||
RevisionInfo rev = info.revision(revision);
|
||||
RevisionInfo b = resolveRevisionOrPatchSetId(info, base, null);
|
||||
|
||||
CallbackGroup group = new CallbackGroup();
|
||||
|
Loading…
x
Reference in New Issue
Block a user