Jump to content


p4bill

Member Since 06 Sep 2011
Offline Last Active Yesterday, 10:10 PM
-----

Posts I've Made

In Topic: GetDepotDirs() - client map too twisted for directory list

Yesterday, 04:10 AM

Here is what you should use for p4 sync -n -f
FileSpec fileSpec = new FileSpec(new DepotPath("//..."), null, null, null);
SyncFilesCmdOptions opts = new SyncFilesCmdOptions(SyncFilesCmdFlags.Preview|
SyncFilesCmdFlags.Force);
IList<FileSpec> syncedFilesPreview =rep.Connection.Client.SyncFiles(opts, fileSpec);

I add the -f because if you have any files that are already synced, they will not appear in syncedFilesPreview. So, if you want to see all the files that would be synced to an empty workspace (whether it is or not), you need to use -f (force).

syncedFilesPreview will be a list showing depot path and local/client path for each file, including revision.

In Topic: GetDepotDirs() - client map too twisted for directory list

04 December 2019 - 02:53 PM

And an example of GetClientfileMappings:
List<String> localDirs = new List<string>();
List<String> workspaceDirs = new List<string>();
foreach (string dir in allDepotDirs)
{
if (!dir.TrimStart('/').Contains("/"))
{
continue;
}
FileSpec fileSpec = new FileSpec(new DepotPath(dir), null, null, null);
IList<FileSpec> fileSpecs = rep.Connection.Client.GetClientFileMappings(fileSpec);
foreach(FileSpec mappings in fileSpecs)
{
localDirs.Add(mappings.LocalPath.Path);
workspaceDirs.Add(mappings.ClientPath.Path);
}
}
GetClientFileMappings does not work on depots, so that is what the .Contains("/) check is for - ensuring that the dir that p4 where is running against is at least one level below //depot.

In Topic: GetDepotDirs() - client map too twisted for directory list

04 December 2019 - 02:31 PM

Your first example is the correct way:
D:\test_ws>p4 where //depot/changenotify
//depot/changenotify //test_ws/changenotify D:\test_ws\changenotify
My guess on the "file(s) not in client view" message that you are seeing is that either //path/to/dir is not in your workspace mapping or you might not have the workspace set in your environment. You can see what P4PORT, P4USER, and P4CLIENT are set to with p4 set. Or you can add global variables to the command, specifying them:
p4 -p<port> -u<user> -c<client> where //depot/changenotify
If you use p4api.net, (GetClientFileMappings) you should just be getting the expected port, user, client from the connection you've established.

In Topic: GetDepotDirs() - client map too twisted for directory list

03 December 2019 - 10:54 PM

I think the best way to achieve that is by running GetDepotDirs on the depot root (//*) and then running GetDepotDirs on the directories returned from the initial command, repeating and building a list until running GetDepotDirs does not return any directories.
The GetDepotDirsCmdFlags.CurrentClientOnly command flag will filter //* to only include directories in the current client view.

The reason //my_workspace works for p4 files is that command will take client(workspace) syntax when specifying the file argument. p4 dirs only takes a depot directory for the dir argument.

Something like this should work:
List<String> allDepotDirs = new List<string>();
List<String> dirsToCheck = new List<string>();
List<String> lowerDirs = new List<string>();
GetDepotDirsCmdOptions opts =
new GetDepotDirsCmdOptions(GetDepotDirsCmdFlags.CurrentClientOnly, null);
List<String> topDepotDirs = (List<string>)rep.GetDepotDirs(opts, "//*"); ;
while (topDepotDirs != null && topDepotDirs.Count>0)
{
lowerDirs = new List<string>();
foreach (string dir in topDepotDirs)
{
allDepotDirs.Add(dir);
dirsToCheck.Add(dir);
}
foreach (string dir in dirsToCheck)
{
lowerDirs.AddRange(rep.GetDepotDirs(opts, dir + "/*"));
}
dirsToCheck = new List<string>();
topDepotDirs = lowerDirs;
}

where allDepotDirs will end up containing all of the directories (in depot syntax) that are in the current client (workspace) view. If you need those paths in local or workspace syntax, you'd need to run GetClientFileMappings on each of them (p4 where).

In Topic: P4 API for .NET strange issue on Disconnect

03 December 2019 - 05:19 PM

Hello,

We have had reports of this error in Disconnect and Connect. Unfortunately, similar to your experience they have been not consistently reproduced and we have not been able to recreate the error and catch it here. The most recent user that reported it was using P4API.NET 2016.1 and said that it no longer occurred with version 2018.1. Is there anything keeping you from upgrading to a more current version? 2019.2 is here: http://ftp.perforce....19.2/bin.ntx64/ and 2019.3 will be released in the coming weeks.