0

Since its difficult for me to understand P4 API documentation, I need help. 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.

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)

Can anyone please help? Regards

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Niyojan
  • 544
  • 1
  • 6
  • 23

1 Answers1

0

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.

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):

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 sync -n @123

which is (I think) the command you are trying to run from your API program.

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.

Bryan Pendleton
  • 16,128
  • 3
  • 32
  • 56