Merge branch 'stable-2.6' into stable-2.7

* stable-2.6:
  Use user's full name even when email is not configured
  Only handle last value change event for attached change screens
  Update the 2.6 release notes
  Fixed: Draft patch sets are visible in diff screens

Conflicts:
	gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeScreen.java

Change-Id: I81caac73d26869f7be875118cc1e312a54e43a07
This commit is contained in:
Shawn Pearce
2013-06-13 21:49:46 -07:00
6 changed files with 45 additions and 9 deletions

View File

@@ -1192,7 +1192,7 @@ but was coming up black on initial page load due to a style setup
ordering issue between the SearchPanel and the HintTextBox. ordering issue between the SearchPanel and the HintTextBox.
* link:https://code.google.com/p/gerrit/issues/detail?id=1661[Issue 1661]: * link:https://code.google.com/p/gerrit/issues/detail?id=1661[Issue 1661]:
Update links to Change-Id and Signed-off-by docu on project info Update links to Change-Id and Signed-off-by documentation on project info
screen screen
* Use href="javascript;" for All {Side-by-Side,Unified} links * Use href="javascript;" for All {Side-by-Side,Unified} links
@@ -1232,6 +1232,9 @@ Correctly handle paths with URL-escaped characters
URL-unescape the path portion of a change history token to correctly URL-unescape the path portion of a change history token to correctly
handle paths with URL-escapable characters, i.e. '+', ' ', etc. handle paths with URL-escapable characters, i.e. '+', ' ', etc.
* link:https://code.google.com/p/gerrit/issues/detail?id=1915[Issue 1915]:
Don't show non-visible drafts in the diff screens.
REST API REST API
~~~~~~~~ ~~~~~~~~

View File

@@ -88,6 +88,7 @@ public class ChangeScreen extends Screen
private KeyCommandSet keysAction; private KeyCommandSet keysAction;
private HandlerRegistration regNavigation; private HandlerRegistration regNavigation;
private HandlerRegistration regAction; private HandlerRegistration regAction;
private HandlerRegistration regDetailCache;
private Grid patchesGrid; private Grid patchesGrid;
private ListBox patchesList; private ListBox patchesList;
@@ -132,6 +133,10 @@ public class ChangeScreen extends Screen
regAction.removeHandler(); regAction.removeHandler();
regAction = null; regAction = null;
} }
if (regDetailCache != null) {
regDetailCache.removeHandler();
regDetailCache = null;
}
super.onUnload(); super.onUnload();
} }
@@ -152,7 +157,7 @@ public class ChangeScreen extends Screen
ChangeCache cache = ChangeCache.get(changeId); ChangeCache cache = ChangeCache.get(changeId);
detailCache = cache.getChangeDetailCache(); detailCache = cache.getChangeDetailCache();
detailCache.addValueChangeHandler(this); regDetailCache = detailCache.addValueChangeHandler(this);
addStyleName(Gerrit.RESOURCES.css().changeScreen()); addStyleName(Gerrit.RESOURCES.css().changeScreen());
addStyleName(Gerrit.RESOURCES.css().screenNoHeader()); addStyleName(Gerrit.RESOURCES.css().screenNoHeader());
@@ -263,7 +268,7 @@ public class ChangeScreen extends Screen
@Override @Override
public void onValueChange(final ValueChangeEvent<ChangeDetail> event) { public void onValueChange(final ValueChangeEvent<ChangeDetail> event) {
if (isAttached()) { if (isAttached() && isLastValueChangeHandler()) {
// Until this screen is fully migrated to the new API, these calls must // Until this screen is fully migrated to the new API, these calls must
// happen sequentially after the ChangeDetail lookup, because we can't // happen sequentially after the ChangeDetail lookup, because we can't
// start an async get at the source of every call that might trigger a // start an async get at the source of every call that might trigger a
@@ -295,6 +300,15 @@ public class ChangeScreen extends Screen
} }
} }
// Find the last attached screen.
// When DialogBox is used (i. e. CommentedActionDialog) then the original
// ChangeScreen is still in attached state.
// Use here the fact, that the handlers (ChangeScreen) are sorted.
private boolean isLastValueChangeHandler() {
int count = detailCache.getHandlerCount();
return count > 0 && detailCache.getHandler(count - 1) == this;
}
private void display(final ChangeDetail detail) { private void display(final ChangeDetail detail) {
displayTitle(detail.getChange().getKey(), detail.getChange().getSubject()); displayTitle(detail.getChange().getKey(), detail.getChange().getSubject());
discardDiffBaseIfNotApplicable(detail.getChange().getId()); discardDiffBaseIfNotApplicable(detail.getChange().getId());

View File

@@ -45,4 +45,13 @@ public class ListenableValue<T> implements HasValueChangeHandlers<T> {
ValueChangeHandler<T> handler) { ValueChangeHandler<T> handler) {
return manager.addHandler(ValueChangeEvent.getType(), handler); return manager.addHandler(ValueChangeEvent.getType(), handler);
} }
public int getHandlerCount() {
return manager.getHandlerCount(ValueChangeEvent.getType());
}
public ValueChangeHandler<?> getHandler(int index) {
return manager.getHandler(ValueChangeEvent.getType(), index);
}
} }

View File

@@ -138,6 +138,11 @@ class PatchScriptFactory extends Handler<PatchScript> {
aId = psa != null ? toObjectId(db, psa) : null; aId = psa != null ? toObjectId(db, psa) : null;
bId = toObjectId(db, psb); bId = toObjectId(db, psb);
if ((psa != null && !control.isPatchVisible(db.patchSets().get(psa), db)) ||
(psb != null && !control.isPatchVisible(db.patchSets().get(psb), db))) {
throw new NoSuchChangeException(changeId);
}
final Repository git; final Repository git;
try { try {
git = repoManager.openRepository(projectKey); git = repoManager.openRepository(projectKey);
@@ -232,6 +237,9 @@ class PatchScriptFactory extends Handler<PatchScript> {
// proper rename detection between the patch sets. // proper rename detection between the patch sets.
// //
for (final PatchSet ps : db.patchSets().byChange(changeId)) { for (final PatchSet ps : db.patchSets().byChange(changeId)) {
if (!control.isPatchVisible(ps, db)) {
continue;
}
String name = patchKey.get(); String name = patchKey.get();
if (psa != null) { if (psa != null) {
switch (changeType) { switch (changeType) {

View File

@@ -98,10 +98,11 @@ public class FromAddressGeneratorProvider implements
@Override @Override
public Address from(final Account.Id fromId) { public Address from(final Account.Id fromId) {
if (fromId != null) { if (fromId != null) {
final Account a = accountCache.get(fromId).getAccount(); Account a = accountCache.get(fromId).getAccount();
if (a.getPreferredEmail() != null) { String userEmail = a.getPreferredEmail();
return new Address(a.getFullName(), a.getPreferredEmail()); return new Address(
} a.getFullName(),
userEmail != null ? userEmail : srvAddr.getEmail());
} }
return srvAddr; return srvAddr;
} }

View File

@@ -102,12 +102,13 @@ public class FromAddressGeneratorProviderTest extends TestCase {
public void testUSER_NoPreferredEmailUser() { public void testUSER_NoPreferredEmailUser() {
setFrom("USER"); setFrom("USER");
final Account.Id user = user("A U. Thor", null); final String name = "A U. Thor";
final Account.Id user = user(name, null);
replay(accountCache); replay(accountCache);
final Address r = create().from(user); final Address r = create().from(user);
assertNotNull(r); assertNotNull(r);
assertEquals(ident.getName(), r.name); assertEquals(name, r.name);
assertEquals(ident.getEmailAddress(), r.email); assertEquals(ident.getEmailAddress(), r.email);
verify(accountCache); verify(accountCache);
} }