Skip to content

Commit

Permalink
getDetailedHistory() now uses the TFS API.
Browse files Browse the repository at this point in the history
  • Loading branch information
olivierdagenais committed Oct 4, 2013
1 parent 77bd362 commit fbd0a44
Showing 1 changed file with 35 additions and 6 deletions.
41 changes: 35 additions & 6 deletions src/main/java/hudson/plugins/tfs/model/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.io.IOException;
import java.io.Reader;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
Expand All @@ -18,7 +19,12 @@
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

import com.microsoft.tfs.core.TFSTeamProjectCollection;
import com.microsoft.tfs.core.clients.versioncontrol.VersionControlClient;
import com.microsoft.tfs.core.clients.versioncontrol.soapextensions.Change;
import com.microsoft.tfs.core.clients.versioncontrol.soapextensions.Changeset;
import com.microsoft.tfs.core.clients.versioncontrol.soapextensions.RecursionType;
import com.microsoft.tfs.core.clients.versioncontrol.specs.version.DateVersionSpec;

public class Project {

Expand Down Expand Up @@ -65,13 +71,36 @@ public String getProjectPath() {
* @return a list of change sets
*/
public List<ChangeSet> getDetailedHistory(Calendar fromTimestamp, Calendar toTimestamp) throws IOException, InterruptedException, ParseException {
DetailedHistoryCommand command = new DetailedHistoryCommand(server, projectPath, fromTimestamp, toTimestamp);
Reader reader = null;
final TFSTeamProjectCollection tpc = server.getTeamProjectCollection();
final VersionControlClient vcc = tpc.getVersionControlClient();
try {
reader = server.execute(command.getArguments());
return command.parse(reader);
} finally {
IOUtils.closeQuietly(reader);
final DateVersionSpec fromVersion = new DateVersionSpec(fromTimestamp);
final DateVersionSpec toVersion = new DateVersionSpec(toTimestamp);
final Changeset[] serverChangesets = vcc.queryHistory(
projectPath,
fromVersion,
0 /* deletionId */,
RecursionType.FULL,
null /* user */,
fromVersion,
toVersion,
Integer.MAX_VALUE,
true /* includeFileDetails */,
true /* slotMode */,
false /* includeDownloadInfo */,
false /* sortAscending */
);
final List<ChangeSet> result = new ArrayList<ChangeSet>();
if (serverChangesets != null) {
for (final Changeset serverChangeset : serverChangesets) {
final ChangeSet changeSet = convertServerChangeset(serverChangeset);
result.add(changeSet);
}
}
return result;
}
finally {
vcc.close();
}
}

Expand Down

0 comments on commit fbd0a44

Please sign in to comment.