mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-01 11:05:56 +01:00
separate methods for reading modification from transaction and from revision
This commit is contained in:
@@ -21,41 +21,51 @@ public class SvnModificationsCommand extends AbstractSvnCommand implements Modif
|
|||||||
super(context, repository);
|
super(context, repository);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
public Modifications getModifications(String revisionOrTransactionId) {
|
||||||
public Modifications getModifications(String revision) {
|
Modifications modifications;
|
||||||
final Modifications modifications = new Modifications();
|
|
||||||
log.debug("get modifications {}", revision);
|
|
||||||
try {
|
try {
|
||||||
if (SvnUtil.isTransactionEntryId(revision)) {
|
if (SvnUtil.isTransactionEntryId(revisionOrTransactionId)) {
|
||||||
|
modifications = getModificationsFromTransaction(SvnUtil.getTransactionId(revisionOrTransactionId));
|
||||||
SVNLookClient client = SVNClientManager.newInstance().getLookClient();
|
|
||||||
client.doGetChanged(context.getDirectory(), SvnUtil.getTransactionId(revision),
|
|
||||||
e -> SvnUtil.appendModification(modifications, e.getType(), e.getPath()), true);
|
|
||||||
|
|
||||||
return modifications;
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
modifications = getModificationFromRevision(revisionOrTransactionId);
|
||||||
long revisionNumber = SvnUtil.getRevisionNumber(revision, repository);
|
|
||||||
SVNRepository repo = open();
|
|
||||||
Collection<SVNLogEntry> entries = repo.log(null, null, revisionNumber,
|
|
||||||
revisionNumber, true, true);
|
|
||||||
if (Util.isNotEmpty(entries)) {
|
|
||||||
return SvnUtil.createModifications(entries.iterator().next(), revision);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return modifications;
|
||||||
} catch (SVNException ex) {
|
} catch (SVNException ex) {
|
||||||
throw new InternalRepositoryException(repository, "could not open repository", ex);
|
throw new InternalRepositoryException(
|
||||||
|
repository,
|
||||||
|
"failed to get svn modifications for " + revisionOrTransactionId,
|
||||||
|
ex
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private Modifications getModificationFromRevision(String revision) throws SVNException {
|
||||||
|
log.debug("get svn modifications from revision: {}", revision);
|
||||||
|
long revisionNumber = SvnUtil.getRevisionNumber(revision, repository);
|
||||||
|
SVNRepository repo = open();
|
||||||
|
Collection<SVNLogEntry> entries = repo.log(null, null, revisionNumber,
|
||||||
|
revisionNumber, true, true);
|
||||||
|
if (Util.isNotEmpty(entries)) {
|
||||||
|
return SvnUtil.createModifications(entries.iterator().next(), revision);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Modifications getModificationsFromTransaction(String transaction) throws SVNException {
|
||||||
|
log.debug("get svn modifications from transaction: {}", transaction);
|
||||||
|
final Modifications modifications = new Modifications();
|
||||||
|
SVNLookClient client = SVNClientManager.newInstance().getLookClient();
|
||||||
|
client.doGetChanged(context.getDirectory(), transaction,
|
||||||
|
e -> SvnUtil.appendModification(modifications, e.getType(), e.getPath()), true);
|
||||||
|
|
||||||
|
return modifications;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Modifications getModifications(ModificationsCommandRequest request) {
|
public Modifications getModifications(ModificationsCommandRequest request) {
|
||||||
return getModifications(request.getRevision());
|
return getModifications(request.getRevision());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user