Jump to content


P4API.NET DepotType enum does not have an entry for Graph depot


  • Please log in to reply
10 replies to this topic

#1 laurent_tr

laurent_tr

    Member

  • Members
  • PipPip
  • 10 posts

Posted 19 June 2019 - 07:50 AM

Hello,

I am using the p4api.net dll version 2019.1.177.4442 and I have noticed that the DepotType enum does not have an entry for Graph depot.
Currently I do not have any Graph depot in my Perforce server but I plan to have one.
Therefore I would like to know if the "GetDepots" method returns all depots in the server including Graph ones.

Thanks.

#2 p4bill

p4bill

    Advanced Member

  • Members
  • PipPipPip
  • 205 posts

Posted 19 June 2019 - 02:14 PM

Hello,

The DepotType enum appears not to have been updated since 2014, when the Unload type was added. Currently there are:

Local
Remote
Spec
Stream
Archive
Unload

Missing are:

Tangent
Extension
Graph

I'll log an issue here to have them added in a future release. Thanks again for your feedback on p4api.net.

#3 laurent_tr

laurent_tr

    Member

  • Members
  • PipPip
  • 10 posts

Posted 21 June 2019 - 12:55 PM

Hello,

Thank you for the update.

By chance, could you please verify that GetDepots() also returns Graph depots?
I have created via the command line p4 a Graph depot, which is visible via "p4 depots" with user having read permission on this depot.
However using GetDepots() with the same user never shows me the depot.

I have also tried to create my own method that sends "p4 depots -t graph":
public IList<Depot> GetDepots()
{
  var options = new Options();
  options["-t"] = "graph";
  P4CommandResult p4CommandResult = new P4Command(this, "depots", true, new string[0]).Run((StringList) options);
  if (p4CommandResult.Success)
  {
	if (p4CommandResult.TaggedOutput == null || p4CommandResult.TaggedOutput.Count <= 0)
	  return (IList<Depot>) null;
	bool dst_mismatch = false;
	string offset = string.Empty;
	if (this.Server != null && this.Server.Metadata != null)
	{
	  offset = this.Server.Metadata.DateTimeOffset;
	  dst_mismatch = FormBase.DSTMismatch(this.Server.Metadata);
	}
	List<Depot> depotList = new List<Depot>();
	foreach (TaggedObject objectInfo in (List<TaggedObject>) p4CommandResult.TaggedOutput)
	{
	  Depot depot = new Depot();
	  depot.FromDepotsCmdTaggedOutput(objectInfo, offset, dst_mismatch);
	  depotList.Add(depot);
	}
	return (IList<Depot>) depotList;
  }
  P4Exception.Throw(p4CommandResult.ErrorList);
  return (IList<Depot>) null;
}

But the result is empty.

Thanks

#4 p4bill

p4bill

    Advanced Member

  • Members
  • PipPipPip
  • 205 posts

Posted 21 June 2019 - 07:10 PM

Hello,

GetDepots() will not return Graph depots, even if they are added to the DepotType enum. I see that a Tangent server will be returned with GetDepots() but will be incorrectly shown as DepotType.Local. I am guessing that there is something different required when using the base P4API with Graph depots. Unfortunately, I am not at all familiar with them. I'd suggest contacting support for more help specific to Graph depot usage. I'll ask internally why p4 depots run in p4api.net does not return Graph depots.

#5 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 957 posts

Posted 21 June 2019 - 07:19 PM

Probably related (man, it's MUCH harder to find these things now that it's not all in one easily-searchable text file -- could y'all just copy p4-doc to the Workshop so it'd at least be "p4 grep"pable?)...

https://www.perforce.../p4devnotes.txt

Major new functionality in 2017.1

	#1478710 * **
		The client must set the 'enableGraph' protocol to indicate
		that it supports the additional output formats reported by
		the graph data model.

My memory is hazy, but I'd bet that tangent depots show up as read-only "local" depots if your API protocol setting is below a certain level since the files in them behave like normal files (you should be able to browse them in P4V, etc) even if your client app doesn't know what a "tangent" is.  Graph depots probably need a more specific protocol setting since they don't (didn't?) support the majority of p4 commands.

#6 p4bill

p4bill

    Advanced Member

  • Members
  • PipPipPip
  • 205 posts

Posted 21 June 2019 - 07:26 PM

Thanks Sam. Thought it might be a protocol, but did not see anything in the API doc. I'll pass along your doc posting request.

@laurent_tr, more info when I get it, but it looks like another issue to log for P4API.NET to set the enableGraph protocol.

#7 p4bill

p4bill

    Advanced Member

  • Members
  • PipPipPip
  • 205 posts

Posted 24 June 2019 - 02:59 PM

View Postlaurent_tr, on 21 June 2019 - 12:55 PM, said:

Hello,

Thank you for the update.

By chance, could you please verify that GetDepots() also returns Graph depots?
I have created via the command line p4 a Graph depot, which is visible via "p4 depots" with user having read permission on this depot.
However using GetDepots() with the same user never shows me the depot.

I have also tried to create my own method that sends "p4 depots -t graph":
public IList<Depot> GetDepots()
{
var options = new Options();
options["-t"] = "graph";
P4CommandResult p4CommandResult = new P4Command(this, "depots", true, new string[0]).Run((StringList) options);
if (p4CommandResult.Success)
{
if (p4CommandResult.TaggedOutput == null || p4CommandResult.TaggedOutput.Count <= 0)
	 return (IList<Depot>) null;
bool dst_mismatch = false;
string offset = string.Empty;
if (this.Server != null && this.Server.Metadata != null)
{
	 offset = this.Server.Metadata.DateTimeOffset;
	 dst_mismatch = FormBase.DSTMismatch(this.Server.Metadata);
}
List<Depot> depotList = new List<Depot>();
foreach (TaggedObject objectInfo in (List<TaggedObject>) p4CommandResult.TaggedOutput)
{
	 Depot depot = new Depot();
	 depot.FromDepotsCmdTaggedOutput(objectInfo, offset, dst_mismatch);
	 depotList.Add(depot);
}
return (IList<Depot>) depotList;
}
P4Exception.Throw(p4CommandResult.ErrorList);
return (IList<Depot>) null;
}

But the result is empty.

Thanks

Following up with Sam's suggestion, it does appear that the 'enableGraph' protocol needs to be set. This is a change required in P4API.NET. I'll log an issue and schedule it for the next release.

If you are building P4API.NET from the source distribution, you can make the required change in P4BridgeServer.cpp around lines 1035-1039 where other protocols are set:

pConnection->SetProtocol("specstring", "");
pConnection->SetProtocol("enableStreams", "");
pConnection->SetProtocol("enableGraph", "");
pConnection->SetProtocol("wingui", "999");
pConnection->SetProtocol("unicode", "");



#8 laurent_tr

laurent_tr

    Member

  • Members
  • PipPip
  • 10 posts

Posted 25 June 2019 - 02:10 PM

Hello @p4bill, @sambwise,

Thank you very much for your response.
I will wait for the next release of P4API.NET then.
Besides I did not manage to find the source distribution of P4API.NET, I imagine that it is not some kind of public repository, isn't it?
Is there a way to know when a new version P4API.NET will be released ?

Also what are the options to be activated in P4Admin and P4V so that I can view a Graph repo ?

Thanks

#9 p4bill

p4bill

    Advanced Member

  • Members
  • PipPipPip
  • 205 posts

Posted 25 June 2019 - 02:47 PM

Hello,

P4API.NET source can be found here:
http://ftp.perforce....19.1/bin.ntx86/

It is near the top of that list: p4api.net-src.zip

There is no public schedule for new releases, but I expect that 2019.2 will be out in early August.

Graph depots are currently not supported in P4V or P4Admin but I am told that they are on the product roadmap.

#10 laurent_tr

laurent_tr

    Member

  • Members
  • PipPip
  • 10 posts

Posted 13 August 2019 - 09:28 AM

Hello @p4bill,

I have downloaded the .NET dll version 2019.2 just now.
I have noticed that in this version there is P4Server.SetProtocol() where we can change the connection protocol of P4Bridge.
I assume that this corresponds to the code snippet pointed out by @sambwise
pConnection->SetProtocol("enableStreams", "");
pConnection->SetProtocol("enableGraph", "");

However when I try to play with this method, it does not change the result of GetDepots().
For example, I put "false" to "enableStreams" but I still receive Streams depots in the result of GetDepots().

Here is the snippet of code the manage my Perforce connection
public bool Connect()
{
	// define the server, repository and connection
	_server = new Server(new ServerAddress(_serverUri));
	_repository = new Repository(_server);
	_connection = _repository.Connection;
	// use the connection variables for this connection
	_connection.UserName = _user;
	_connection.Client = new Client();
	var options = new Options();
	options["ProgramName"] = ApplicationName;
	options["ProgramVersion"] = ApiVersion;
	// connect to the server
	try
	{
		if (!_connection.Connect(options))
		{
			Sys.LogError($"{nameof(PerforceClient)}.Connect could not connect to Perforce server at {_serverUri}, with the user {_user}.");
			return false;
		}
		// TODO: Uncomment this line to enable Graph depot discovery
		_connection.getP4Server().SetProtocol("enableGraph", "");
		_connection.getP4Server().SetProtocol("enableStreams", "false");
		if (_passwordAuthentication)
		{
			var credential = _connection.Login(_pwd.Password);
			// Save the ticket expiration time, remove 5 min to be more proactive on the expiration time
			_ticketExpirationTime = Dat.MinSub(credential.Expires, 5);
			PerforceHelixConnector.LogProgress($"{nameof(PerforceClient)}.Connect obtains new validation ticket, valid until {Dat.ToStrSystem(_ticketExpirationTime)}.");
		}
		return true;
	}
	catch (Exception e)
	{
		HandleException($"{nameof(PerforceClient)}.Connect could not connect to Perforce server at {_serverUri}, with the user {_user}.", e , out _);
		return false;
	}
}


#11 p4bill

p4bill

    Advanced Member

  • Members
  • PipPipPip
  • 205 posts

Posted 13 August 2019 - 01:52 PM

P4Server.SetProtocol() has been in P4API.NET for at least a couple of releases. Here is a note on it from the C++ tests:
// must run SetProtocol before the connection is established
// note that for the most part SetProtocol is already handled
// in our connection code, but this is for the case when
// a parallel sync/transmit response has protocol data for
// the new connections

Where it mentions that SetProtocol is already handled in the connection code, refers to P4BridgeServer.cpp where Streams and Graph are enabled:
pConnection->SetProtocol("enableStreams", "");
pConnection->SetProtocol("enableGraph", "");

enableGraph is new in 2019.2
I don't think that you can disable those protocols without changing the source code of P4API.NET. Do you need to?




2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users