Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert Perforce depot locations to client view locations

I'd like to know how to convert Perforce depot locations to client view locations for the purpose of script writing.

I have a script that first checks out a file for edit in perforce and then interacts with the file. I need to have the depot location (i.e. \Projects\Project6) converted to the client view location. (i.e. d:\Projects\Project6).

Is this possible?

like image 341
Poltron Galantine Avatar asked Nov 19 '08 00:11

Poltron Galantine


People also ask

What is Perforce client view?

A Perforce client workspace is a set of files on a user's machine that mirror a subset of the files in the depot. More precisely, it is a named mapping of depot files to workspace files.

What does p4 flush do?

The p4 flush command performs half the work of a p4 sync .

What are depots Perforce?

The Helix Server stores files in shared repositories called depots. By default, there is one local depot named depot on every Helix Server installation. To create or edit a depot, use p4 depot depotname and edit the fields in the depot spec form.

What is workspace P4V?

A workspace is the location on your computer where you work on files that are managed by the Helix server. In this video, we'll explain workspace concepts and set one up using P4V, a client application that communicates with the server. The server manages depots, which are shared file repositories.


2 Answers

I have always used the p4 where command for this. Here is its description from the built-in help:

where -- Show how file names map through the client view

p4 where [ file ... ]

    Where shows how the named files map through the client view.
    For each argument, three names are produced: the name in the
    depot, the name on the client in Perforce syntax, and the name
    on the client in local syntax.

    If no file is given, the mapping for '...' (all files in the
    current directory and below) is shown.

    Note that 'p4 where' does not determine where any real files are.
    It only computes where they should be according to the client view.
like image 200
bk1e Avatar answered Sep 18 '22 19:09

bk1e


I would use the p4 fstat command. I find its format slightly easier to parse than p4 have. Additionally if you are scripting this in python you can use the -G option to have the the return values marshalled as python dictionaries.

It is also useful to note that you can type p4 help commands to see a list of the commands and a short description of what they do.

like image 40
grieve Avatar answered Sep 18 '22 19:09

grieve