Search code examples
editperforcedepot

Perforce "p4 edit" opens file in depot


Im using p4v. When i checkout some file in workspace p4v shows next command in log: p4 edit -c default d:\p4\depot...\file.txt

And I need to make same thing in cmd All enviroment variables are set as:

P4CHARSET=utf8 (set -s)
P4CLIENT=workspace_name (set)
P4PASSWD=passwd (set)
P4PORT=port (set)
P4USER=name (set)

Then i use same command "p4 edit -c default d:\p4\depot...\file.txt" and p4 outputs this: //depot/.../file.txt#5 - opened for edit And if I check in p4v i see that file checked out in depot, not in my workspace.

What is solution to this issue?


Solution

  • Files in Perforce are mapped between your workspace and the depot, and the depot and workspace paths can be used interchangeably. When a file is "checked out" using "p4 edit", the following things happen:

    1. Your local file (d:\p4\depot...\file.txt) is made writable.
    2. The depot file (//depot/.../file.txt#5) is marked as being open by you.
    3. The Perforce server "remembers" all of this.

    That is, the file is indeed "checked out" in both your workspace and the depot -- there's no difference between the two. It's the same file. If you look at your workspace file, you should see that it is now writable (this is the signal in your workspace that it's checked out). From the command line you can run "p4 opened" to see which files are open in the current workspace. If you're not sure how the depot paths map to local paths for individual files, you can run "p4 have" to see where you have a given depot file in your workspace and what version of it you have.

    When you submit, the server will know that the depot file needs to be updated, and it will know that the new content will come from your workspace file. If there is a new revision of the depot file (newer than #5), the server will schedule a resolve so that you can merge in the new content before submitting.

    In other words, there is no such thing as being "checked out in the depot" but not in a workspace. A depot file that is "checked out" is by definition checked out to a particular workspace.