Jump to content


map a depot to existing workspace from p4 command line client

perforce workspace p4client triggers

  • Please log in to reply
3 replies to this topic

#1 MaxBk

MaxBk

    Member

  • Members
  • PipPip
  • 12 posts

Posted 05 December 2016 - 05:39 PM

Hi,
I would like to map a depot to a workspace from the command line client.
I couldn't find a reference for that command and to use it from the trigger I would need to run it with Perl so it has to be called with the p4 command line client.

If you are curios the trigger that I am using is "newDepot form-commit depot".

Can anyone give me an example of the command that I need to run?
p4 workspace ....?

Thanks in advance,
Max.

#2 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 1190 posts

Posted 06 December 2016 - 01:04 AM

Could you explain a little bit more what you're trying to do?  I was with you up until you mentioned a trigger -- usually you create a workspace on a client, but a trigger runs on the server.  Are you making a trigger that needs to create its own workspace, or is the idea that the trigger is supposed to modify an existing workspace spec, or...?

#3 MaxBk

MaxBk

    Member

  • Members
  • PipPip
  • 12 posts

Posted 06 December 2016 - 01:32 PM

View PostSambwise, on 06 December 2016 - 01:04 AM, said:

Could you explain a little bit more what you're trying to do?  I was with you up until you mentioned a trigger -- usually you create a workspace on a client, but a trigger runs on the server.  Are you making a trigger that needs to create its own workspace, or is the idea that the trigger is supposed to modify an existing workspace spec, or...?

Hi thanks for the response but I figured it out.
What I intended to do is to map a stream to a view of a workspace after a new depot that is a stream was created.
The next code worked for me:

$pid = open(README, "p4 client -o $ClientName |") or die "Couldn't fork: $!\n";
  while (  ) {
      push @arrViewsList, "$_";
  }
close(README) or die "Couldn't close: $!\n";
push @arrViewsList, "\t//$DepotName/... //$ClientName/$DepotName/...";

$pid = open(WRITEME, "| p4 client -i") or die "Couldn't fork: $!\n";
  foreach (@arrViewsList){
    print WRITEME "$_";
  }

#4 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 1190 posts

Posted 06 December 2016 - 06:02 PM

Ah, I see.  A simpler equivalent to the code you've written would be:

p4 --field "View+=//$DepotName/... //$ClientName/$DepotName/..." client -o $ClientName | p4 client -i

Note that there are some problems -- for example you're talking about streams, which this won't work for since stream workspaces manage their own views (you set the view simply by changing the "Stream" field, and a given stream workspace only maps one stream at a time).  Also note that the approach of just generating a view and putting it on the end will mess up the user if they've mapped something else into that namespace -- their existing mapping will be overwritten and they won't know until the next time they do a sync (whereupon a bunch of their files will disappear for no obvious reason).





Also tagged with one or more of these keywords: perforce, workspace, p4client, triggers

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users