Allow loading Project Access when there is no refs/meta/config

If the project does not have refs/meta/config the revision is
null. Enable loading the access screen anyway with a null revision
field, and on save of any edits require the branch to be new.
This is already handled by MetaDataUpdate, provided that the base
revision we supply is null, so make it @Nullable inside of the
ChangeProjectAccess handler.

Change-Id: I4417bf802e329eb7193a7cb514f7ebcd7d68f26e
This commit is contained in:
Shawn O. Pearce 2012-01-09 10:07:03 -08:00 committed by Martin Fick
parent 730c71903c
commit 23f2e7096c
3 changed files with 14 additions and 4 deletions

View File

@ -53,7 +53,8 @@ import javax.annotation.Nullable;
class ChangeProjectAccess extends Handler<ProjectAccess> {
interface Factory {
ChangeProjectAccess create(@Assisted Project.NameKey projectName,
@Assisted ObjectId base, @Assisted List<AccessSection> sectionList,
@Nullable @Assisted ObjectId base,
@Assisted List<AccessSection> sectionList,
@Nullable @Assisted String message);
}
@ -75,7 +76,8 @@ class ChangeProjectAccess extends Handler<ProjectAccess> {
final MetaDataUpdate.User metaDataUpdateFactory,
@Assisted final Project.NameKey projectName,
@Assisted final ObjectId base, @Assisted List<AccessSection> sectionList,
@Nullable @Assisted final ObjectId base,
@Assisted List<AccessSection> sectionList,
@Nullable @Assisted String message) {
this.projectAccessFactory = projectAccessFactory;
this.projectControlFactory = projectControlFactory;

View File

@ -177,7 +177,10 @@ class ProjectAccessFactory extends Handler<ProjectAccess> {
}
final ProjectAccess detail = new ProjectAccess();
detail.setRevision(config.getRevision().name());
if (config.getRevision() != null) {
detail.setRevision(config.getRevision().name());
}
if (projectName.equals(allProjectsName)) {
if (pc.isOwner()) {

View File

@ -85,7 +85,12 @@ class ProjectAdminServiceImpl implements ProjectAdminService {
public void changeProjectAccess(Project.NameKey projectName,
String baseRevision, String msg, List<AccessSection> sections,
AsyncCallback<ProjectAccess> cb) {
ObjectId base = ObjectId.fromString(baseRevision);
ObjectId base;
if (baseRevision != null && !baseRevision.isEmpty()) {
base = ObjectId.fromString(baseRevision);
} else {
base = null;
}
changeProjectAccessFactory.create(projectName, base, sections, msg).to(cb);
}