In the shell, when I am in a directory located as part of a p4 workspace, I can run p4 commands in the shell and it knows what workspace I am in.
However, when I launch p4v, I have to manually find the workspace that I want to load. Since, the context of p4 commands to run is already known in the shell, how I can I pass that to p4v, so it will launch in the same workspace. There's no reason why I should have to select a workspace when I launch the tool, since the p4 toolchain already can self-determine the context.
I should only have to select the workspace if I am wanting to select some other workspace that I am not currently operating under.
As you've found, P4V has its own settings file and ignores the shell's environment. Per this blog post:
https://www.perforce.com/blog/100114/p4v-secrets-calling-p4v-command-line
the way I'd handle this would be to write a script/alias that wraps P4V and passes the current environment to it. Something along these lines:
$_ = `p4 -Ztag -F "%serverAddress%#%clientName%#%userName%" info`;
#env = split /\#/;
exec "p4v -p $env[0] -c $env[1] -u $env[2]";
Related
I'm trying to understand how perorce work and I'm struggling with command line
I have a single depot with 3 project inside
so depot:
projectA
projectB
now I have 2 workspaces, one mapped only on projectA and one on projectB.
Here I have my trouble , using interface everything works
but with command line I have not enough knoledge on perforce.
I use
p4 -c workspacA //to switch workspace
then I run: p4 cstat
and it give me all the information about changelist contained in all depot
not only depot/projectA
But I woul like to enter in a workspace and run my command only on that workspace
Is this normal? I see that I need to specify my depot mapping but this seems strange to me.
Can someone clarify me this?
Thanks
Do:
p4 set P4CLIENT=workspaceA
If you use -c workspaceA it applies only to that one command, whereas p4 set is persistent.
I also recommend looking at documentation on P4CONFIG, which lets you associate Perforce config settings with local directories (so you switch workspaces automatically when you cd to a different workspace root).
https://www.perforce.com/manuals/v16.2/cmdref/P4CONFIG.html
I have a couple files checked out in Perforce on a different computer that I won't have access to until tomorrow. I received a request to revert them but I'm not sure how to do that from my home computer. I don't see an option and I can't find any results about this for the visual client. Is it even possible?
I ended up finding a suitable solution for myself.
I opened P4V and navigated to my workspaces. I edited the one with the checked out files and changed the workspace root and host to be from my current computer. After applying that, I was able to revert them as I normally would from the P4V client.
p4 revert takes as an option the client name, i.e workspace name.
From P4V>File> Open Command window here and try :
p4 revert -C *yourotherworkspace* -c changelist //...
If this is not enough you might have to add some global options settings like :
p4 -H remote_computer_name revert -C *yourotherworkspace* -c changelist //...
I have a list of files , with full windows path of each file with me , i want to insert each of these file in a perforce changelist using windows shell or cygnus-win . Is this possible , if yes then what commands should i use.
Yes it is possible. You can use p4 add <path to file>. This will add file to default change list. -c allows you to specify change list to add to. For full help use p4 help add.
Note that you should also set up some environment variables to use p4 from command line or provide these details in command line before p4 action (like p4 -u your_account add <path to file>).
Shortly you have to setup P4USER (your account), P4PORT (server with port), P4CLIENT (workspace name). See p4 help environment for details.
For list of p4 options see p4 help and p4 help usage
How to clone my co-worker's workspace in perforce? I have the name of the workspace to clone from, how can I do it? I have tried doing it via command line with
'p4 client -t coworker_workspace_name', but I get this error 'Client '?coworker_workspace_name' doesn't exit.
Thank you.
You can do this via the P4V GUI client. I would post a screenshot, but I need at least 10 reputation :'(
Go to the Workspaces tab.
If you don't see it, you can show it via "View -> Workspaces"
Untick the filtering options, such as "Show only workspaces available or use on this computer" (see figure). You should see your co-worker's workspace (assuming it's on the same Perforce server you're connected to).
Right-click it and select "Create/Update Workspace from '...'"
Select the "Create Workspace" radio button to create a new workspace.
Using linux/bash command line:
p4 client -o -t source_client target_client_name | sed 's,Root.*,Root:\tdesired path,' | p4 client -i
p4 client -o -t source_client target_client_name
Copies source_client and changes any reference to its name to "target_client_name".
E.g. All references of "clientA" become "clientB"
sed 's,Root.\*,Root\:\tDesired_Root_Path,'
Replace "Desired_Root_Path" with wherever you'd like your Root directory. I like to group my workspaces into "/workarea/allmyworkspaces/" so that's what I'd supply.
The commas are the separators for the sed command.
p4 client -i
Reads a client spec from standard input, so this pipes all the output from the previous commands into a spec creation.
To test that your values will be correct, leave this portion off the command and everything will print to stdout and you can inspect.
I want to change the workspace client using the p4 command line but i don't know if its possible.
You can create, delete or edit workspace using the p4 workspace command, but i want to change the current workspace with a .bat method.
Exemple :
p4 -c MyClient changeworkspace myNewWorkspace
If you know in first step if it's possible.
Thanks.
Either set the P4CLIENT environment variable to the name of the workspace you want to be your current workspace, or consistently pass that workspace name as the value of the -c flag on your p4 commands: http://www.perforce.com/perforce/doc.current/manuals/cmdref/env.P4CLIENT.html#1040647
See also these other ways to set the environment variable (many people find P4CONFIG files helpful): http://www.perforce.com/perforce/doc.current/manuals/p4guide/02_config.html#1069873