ChangeScreen: Update token when 'Diff Against' selection is changed
Otherwise there can be a mismatch between the URL and what the screen
shows. E.g. if the user selects the first parent of a merge commit
and then navigates to a diff and back, the site token is set to
something like '/c/123/-1..1'. This token stayed when the user
selected something else from the 'Diff Against' drop-down list. This
means the screen was updated but the update was not reflected in the
URL.
Bug: Issue 4021
Change-Id: I51f888f8cde83cd446122316c3b6dbb5f676504b
Signed-off-by: Edwin Kempin <ekempin@google.com>
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/ChangeScreen.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/ChangeScreen.java
index 443e18b..436e0c3 100644
--- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/ChangeScreen.java
+++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/ChangeScreen.java
@@ -981,6 +981,8 @@
Gerrit.display(getToken(), new NotFoundScreen());
}
+ updateToken(info, base, rev);
+
RevisionInfo baseRev =
resolveRevisionOrPatchSetId(info, base.asString(), null);
@@ -1033,6 +1035,21 @@
});
}
+ private void updateToken(ChangeInfo info, DiffObject base, RevisionInfo rev) {
+ StringBuilder token = new StringBuilder("/c/")
+ .append(info._number())
+ .append("/");
+ if (base.asString() != null) {
+ token.append(base.asString())
+ .append("..");
+ }
+ if (base.asString() != null
+ || !rev.name().equals(info.currentRevision())) {
+ token.append(rev._number());
+ }
+ setToken(token.toString());
+ }
+
static Timestamp myLastReply(ChangeInfo info) {
if (Gerrit.isSignedIn() && info.messages() != null) {
int self = Gerrit.getUserAccount()._accountId();