1

作为从 P4 过渡到 TFS 的过程的一部分,我需要将一些调用该p4命令的自动化脚本翻译成它们的 TFS 等价物。

我的一个脚本执行几个命令:

p4 <server-and-login-options> -c <wksp_name> client -i < <definition>
p4 <server-and-login-options> -c <wksp_name> sync [-f]

在 Perforce 中,这足以(可选地)更改和完全同步特定的工作空间。这可以在 Windows 和 Linux 上无缝运行。

在 MSDN 文档中徘徊了几个星期之后,我似乎没能在 TFS 中找到一个等价物。

我尝试使用 TFS Java SDK 来完成这项工作:

...
WorkingFolder[] workingFolders = ...;
Workspace wksp = null;
try
{
    wksp = vcs.getWorkspace(workspaceName, VersionControlConstants.AUTHENTICATED_USER);
    wksp.update(null, WORKSPACE_COMMENT, workingFolders, true);
}
catch (WorkspaceNotFoundException ex)
{
    wksp = vcs.createWorkspace(
        workingFolders,
        workspaceName,
        WORKSPACE_COMMENT,
        WorkspaceLocation.SERVER,
        WorkspaceOptions.NONE);
}

final VersionSpec versionSpec = LatestVersionSpec.INSTANCE;
GetOptions getOptions = GetOptions.NONE;
if (force)
    getOptions = getOptions.combine(GetOptions.GET_ALL);

final GetStatus getStatus = wksp.get(versionSpec, getOptions);
...

这适用于我在 Windows 上。

但不是在 Linux 上。getWorkspace/部分可以正常工作,createWorkspace效果可以通过 验证tf workfold。但是,在Workspace.get程序内部崩溃并显示以下消息:

Exception in thread "main" java.lang.NoSuchMethodError: <init>
    at com.microsoft.tfs.jni.internal.filesystem.NativeFileSystem.nativeGetAttributes(Native Method)
    at com.microsoft.tfs.jni.internal.filesystem.NativeFileSystem.getAttributes(NativeFileSystem.java:74)
    at com.microsoft.tfs.jni.FileSystemUtils.getAttributes(FileSystemUtils.java:39)
    at com.microsoft.tfs.core.clients.versioncontrol.engines.internal.GetEngine.processOperation(GetEngine.java:1800)
    at com.microsoft.tfs.core.clients.versioncontrol.engines.internal.GetEngine.processOperationsInternal(GetEngine.java:1163)
    at com.microsoft.tfs.core.clients.versioncontrol.engines.internal.GetEngine.processOperations(GetEngine.java:957)
    at com.microsoft.tfs.core.clients.versioncontrol.engines.internal.GetEngine.processGetOperations(GetEngine.java:782)
    at com.microsoft.tfs.core.clients.versioncontrol.soapextensions.Workspace.get(Workspace.java:2429)
    at com.microsoft.tfs.core.clients.versioncontrol.soapextensions.Workspace.get(Workspace.java:2307)
    at com.microsoft.tfs.core.clients.versioncontrol.soapextensions.Workspace.get(Workspace.java:2295)
    at com.microsoft.tfs.core.clients.versioncontrol.soapextensions.Workspace.get(Workspace.java:2271)
    at TfsGet.main(TfsGet.java:181)

好吧,我不是 Unix 男孩,也不知道如何诊断和修复它。所以我试图将getWorkspace/createWorkspace部分留在 Java 中并调用tf get. 但是,我似乎需要指定要更新的特定目录和文件。

我觉得这项工作一定很普通,不能相信没有人能完成它。

4

1 回答 1

1

Thanks everyone, the error in Workspace.get turned out to be the result of my own inattention. The versions of the com.microsoft.tfs.sdk-11.0.0.jar and the libnative_*.so files did not match. Now that I've made sure that all files match each other, the problem is solved.

于 2013-09-06T15:10:49.750 回答