Search code examples
perforcep4v

set depot path from a terminal using p4 command


I have recently start using perforce.

in my organization we have tool that translates installation path to depot path where repos are , I want to know if we can set that translated path in the already open perforce from the commandline ?

which in turn also brings perforce (p4v) in focus.


Solution

  • Perforce's solution for this is P4CONFIG. Do:

    p4 set P4CONFIG=p4config.txt
    

    Then, in the path you want to associate with a particular server ("repo" in gitspeak), create a file called p4config.txt that contains:

    P4PORT=your_server:1666
    

    The P4CONFIG file can also contain values for P4USER, P4CLIENT, etc.

    It sounds like your tool should simply be modified to write its information to P4CONFIG files so that Perforce client tools can pick the information up automatically. Failing that, you might be able to script something around this tool that queries it and then converts its output to P4CONFIG settings.