public static class MetaDataUpdate.User
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
MetaDataUpdate |
create(com.google.gerrit.reviewdb.client.Project.NameKey name) |
MetaDataUpdate |
create(com.google.gerrit.reviewdb.client.Project.NameKey name,
IdentifiedUser user) |
MetaDataUpdate |
create(com.google.gerrit.reviewdb.client.Project.NameKey name,
IdentifiedUser user,
org.eclipse.jgit.lib.BatchRefUpdate batch)
Create an update using an existing batch ref update.
|
MetaDataUpdate |
create(com.google.gerrit.reviewdb.client.Project.NameKey name,
org.eclipse.jgit.lib.Repository repository,
IdentifiedUser user,
org.eclipse.jgit.lib.BatchRefUpdate batch)
Create an update using an existing batch ref update.
|
org.eclipse.jgit.lib.PersonIdent |
getUserPersonIdent() |
public org.eclipse.jgit.lib.PersonIdent getUserPersonIdent()
public MetaDataUpdate create(com.google.gerrit.reviewdb.client.Project.NameKey name) throws org.eclipse.jgit.errors.RepositoryNotFoundException, java.io.IOException
org.eclipse.jgit.errors.RepositoryNotFoundException
java.io.IOException
public MetaDataUpdate create(com.google.gerrit.reviewdb.client.Project.NameKey name, IdentifiedUser user) throws org.eclipse.jgit.errors.RepositoryNotFoundException, java.io.IOException
org.eclipse.jgit.errors.RepositoryNotFoundException
java.io.IOException
public MetaDataUpdate create(com.google.gerrit.reviewdb.client.Project.NameKey name, IdentifiedUser user, org.eclipse.jgit.lib.BatchRefUpdate batch) throws org.eclipse.jgit.errors.RepositoryNotFoundException, java.io.IOException
This allows batching together updates to multiple metadata refs. For making
multiple commits to a single metadata ref, see
VersionedMetaData.openUpdate(MetaDataUpdate)
.
name
- project name.user
- user for the update.batch
- batch update to use; the caller is responsible for committing
the update.org.eclipse.jgit.errors.RepositoryNotFoundException
java.io.IOException
public MetaDataUpdate create(com.google.gerrit.reviewdb.client.Project.NameKey name, org.eclipse.jgit.lib.Repository repository, IdentifiedUser user, org.eclipse.jgit.lib.BatchRefUpdate batch)
This allows batching together updates to multiple metadata refs. For making
multiple commits to a single metadata ref, see
VersionedMetaData.openUpdate(MetaDataUpdate)
.
Important: Create a new MetaDataUpdate instance for each update:
try (Repository repo = repoMgr.openRepository(allUsersName);
RevWalk rw = new RevWalk(repo) {
BatchRefUpdate batchUpdate = repo.getRefDatabase().newBatchUpdate();
// WRONG: create the MetaDataUpdate instance here and reuse it for
// all updates in the loop
for(Map.Entry<Account.Id, DiffPreferencesInfo> e : diffPrefsFromDb)
{
// CORRECT: create a new MetaDataUpdate instance for each update
try (MetaDataUpdate md =
metaDataUpdateFactory.create(allUsersName, batchUpdate)) {
md.setMessage("Import diff preferences from reviewdb\n");
VersionedAccountPreferences vPrefs =
VersionedAccountPreferences.forUser(e.getKey());
storeSection(vPrefs.getConfig(), UserConfigSections.DIFF, null,
e.getValue(), DiffPreferencesInfo.defaults());
vPrefs.commit(md);
} catch (ConfigInvalidException e) {
// TODO handle exception
}
}
batchUpdate.execute(rw, NullProgressMonitor.INSTANCE);
}
name
- project name.repository
- the repository to update; the caller is responsible for
closing the repository.user
- user for the update.batch
- batch update to use; the caller is responsible for committing
the update.