简体   繁体   English

Perforce .net API同步软件仓库文件

[英]Perforce .net API sync depot files

Since its difficult for me to understand P4 API documentation, I need help. 由于我难以理解P4 API文档,因此我需要帮助。 I have a folder in a depot, say //root/a/... first I am running a preview to know the number of files going to be synced on a changelist, say 123 . 我在软件仓库中有一个文件夹,例如//root/a/...首先,我正在运行预览,以了解要在变更列表上同步的文件数,例如123

Client.ViewMap = new ViewMap();
Client.ViewMap.Add("//root/a/...", "//" + myWrkSpace + "/a/...", MapType.Include);
Options sFlags = new Options( SyncFilesCmdFlags.Preview, 123 );
rFiles = rep.Connection.Client.SyncFiles(sFlags, null);

In rFiles I should get the file list that are going to be synced (sync preview, I will be syncing each file in a background worker), but its returning me all the depot files (files in //root) rFiles我应该获取将要同步的文件列表(同步预览,我将在后台工作器中同步每个文件),但是它返回了所有软件仓库文件(// root中的文件)

Can anyone please help? 谁能帮忙吗? Regards 问候

When you do: 当您这样做时:

Client.ViewMap = new ViewMap();
Client.ViewMap.Add("//root/a/...", "//" + myWrkSpace + "/a/...", MapType.Include);

you are just setting some data locally in the Client object in your program, not on the server. 您只是在程序的Client对象中本地设置了一些数据,而不是在服务器上。

When the server runs: 服务器运行时:

rFiles = rep.Connection.Client.SyncFiles(sFlags, null);

it is using the view map that is stored on the server. 它正在使用存储在服务器上的视图图。

If you run (from the CMD.EXE prompt, and using the real name of your workspace): 如果运行(从CMD.EXE提示符下,并使用工作区的真实名称):

p4 client -o myWrkSpace

you will see the actual view map for your workspace on the server. 您将在服务器上看到工作区的实际视图。

And I bet you will see that it is: 我敢打赌,您会看到它是:

//root/... //myWrkSpace/...

Which is why you are getting all the depot files in your sync. 这就是为什么要在同步中获取所有软件仓库文件的原因。

So if you want to change your view map, you have to do more than just set it locally, you have to update the workspace definition on the server, prior to running the sync. 因此,如果要更改视图地图,除了要做本地设置之外,还需要做更多的事情,还必须在运行同步之前更新服务器上的工作区定义。

One thing that will help you debug these sorts of things is to become adequately familiar with the p4 command line tool to allow you to run commands from the CMD.EXE prompt, such as: 可以帮助您调试这类事情的一件事是充分熟悉p4命令行工具,以使您可以从CMD.EXE提示符运行命令,例如:

p4 sync -n @123

which is (I think) the command you are trying to run from your API program. (我认为)这是您尝试从API程序运行的命令。

Then you can see how that command works from the command line, and then you can look in your server's log and see what actual commands your API program is issuing, and compare those commands to the ones you run from the command line. 然后,您可以从命令行查看该命令的工作方式,然后可以查看服务器的日志,查看API程序正在发出的实际命令,并将这些命令与您从命令行运行的命令进行比较。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM