Question

How do I commit files to TFS Version Control, using the Java SDK, but without having to create a workspace?

Having to create (and manipulate, then destroy) a workspace every time you want to do a simple TFS Version Control operation is complicated, time consuming and error-prone, so I would rather avoid that (it's especially challenging when an arbitrary number of processes may be performing different operations on different things at the same time).

I can enumerate and retrieve files just fine:

TFSTeamProjectCollection tpc = new TFSTeamProjectCollection(new URI("http://tfs/"), new DefaultNTCredentials());
VersionControlClient versionControlClient = tpc.getVersionControlClient();
Item item = versionControlClient.getItem("$/Project/some/file.txt", LatestVersionSpec.INSTANCE, DeletedState.NON_DELETED, true);
versionControlClient.downloadFileToStream(new DownloadSpec(item.getDownloadURL()), outputStream, true);

What about the reverse? Is there a way to push a file or changeset into TFS programmatically, without having to map a workspace?

Was it helpful?

Solution

You can't. You need to always create a workspace first. Then batch the pending changes and then commit them. I suppose this is due to the fact that TFS will always commit all files at once when submitting multiple changes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top