public static class MetaDataUpdate.User extends Object
Modifier and Type | Method and Description |
---|---|
MetaDataUpdate |
create(Project.NameKey name) |
MetaDataUpdate |
create(Project.NameKey name,
IdentifiedUser user) |
MetaDataUpdate |
create(Project.NameKey name,
IdentifiedUser user,
org.eclipse.jgit.lib.BatchRefUpdate batch)
Create an update using an existing batch ref update.
|
MetaDataUpdate |
create(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(Project.NameKey name) throws org.eclipse.jgit.errors.RepositoryNotFoundException, IOException
org.eclipse.jgit.errors.RepositoryNotFoundException
IOException
public MetaDataUpdate create(Project.NameKey name, IdentifiedUser user) throws org.eclipse.jgit.errors.RepositoryNotFoundException, IOException
org.eclipse.jgit.errors.RepositoryNotFoundException
IOException
public MetaDataUpdate create(Project.NameKey name, IdentifiedUser user, org.eclipse.jgit.lib.BatchRefUpdate batch) throws org.eclipse.jgit.errors.RepositoryNotFoundException, 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
IOException
public MetaDataUpdate create(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.