Cleanup assumption of Branch.NameKey parent is Project.NameKey

Often we are pulling the Project.NameKey off a Branch.NameKey, but
this is really obtuse.  Its cleaner to just ask the change object
what project it is a member of.

Change-Id: I422845dbeb00de95ffc309125226f7427a9a20be
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2009-08-28 17:53:32 -07:00
parent b6b99cfe38
commit 015cde4165
13 changed files with 17 additions and 13 deletions

View File

@@ -200,7 +200,7 @@ public abstract class OutgoingEmail {
/** Setup the message headers and envelope (TO, CC, BCC). */
protected void init() {
if (change != null && projectCache != null) {
projectState = projectCache.get(change.getDest().getParentKey());
projectState = projectCache.get(change.getProject());
projectName =
projectState != null ? projectState.getProject().getName() : null;
} else {
@@ -482,7 +482,7 @@ public abstract class OutgoingEmail {
protected Set<AccountGroup.Id> getProjectOwners() {
final ProjectState r;
r = projectCache.get(change.getDest().getParentKey());
r = projectCache.get(change.getProject());
return r != null ? r.getOwners() : Collections.<AccountGroup.Id> emptySet();
}

View File

@@ -75,7 +75,7 @@ public class PatchSetInfoFactory {
db = schemaFactory.open();
final PatchSet patchSet = db.patchSets().get(patchSetId);
final Change change = db.changes().get(patchSet.getId().getParentKey());
final Project.NameKey projectKey = change.getDest().getParentKey();
final Project.NameKey projectKey = change.getProject();
final String projectName = projectKey.get();
repo = gs.openRepository(projectName);
final RevWalk rw = new RevWalk(repo);

View File

@@ -52,7 +52,7 @@ public class ChangeControl {
public ChangeControl controlFor(final Change change)
throws NoSuchChangeException {
try {
final Project.NameKey projectKey = change.getDest().getParentKey();
final Project.NameKey projectKey = change.getProject();
return projectControl.validateFor(projectKey).controlFor(change);
} catch (NoSuchProjectException e) {
throw new NoSuchChangeException(change.getId(), e);

View File

@@ -124,7 +124,7 @@ final class PatchSetPublishDetailFactory extends Handler<PatchSetPublishDetail>
private void computeAllowed() {
final Set<AccountGroup.Id> am = user.getEffectiveGroups();
final ProjectState pe = projectCache.get(change.getDest().getParentKey());
final ProjectState pe = projectCache.get(change.getProject());
computeAllowed(am, pe.getRights());
computeAllowed(am, projectCache.getWildcardRights());
}

View File

@@ -121,7 +121,7 @@ class PatchScriptFactory extends Handler<PatchScript> {
throw new NoSuchChangeException(changeId);
}
projectKey = change.getDest().getParentKey();
projectKey = change.getProject();
try {
git = server.openRepository(projectKey.get());
} catch (RepositoryNotFoundException e) {

View File

@@ -642,7 +642,7 @@ final class Receive extends AbstractGitCommand {
reject(cmd, "change " + changeId + " not found");
return;
}
if (!project.getNameKey().equals(changeEnt.getDest().getParentKey())) {
if (!project.getNameKey().equals(changeEnt.getProject())) {
reject(cmd, "change " + changeId + " not found");
return;
}

View File

@@ -74,7 +74,7 @@ public class FunctionState {
projectCache = pc;
change = c;
project = projectCache.get(change.getDest().getParentKey());
project = projectCache.get(change.getProject());
for (final PatchSetApproval ca : all) {
if (psId.equals(ca.getPatchSetId())) {