p4 edit

Opens files in a client workspace for edit, or open the current stream spec.

Syntax

p4 [g-opts] edit [-c changelist] [-k -n] [-t type] [--remote=remote] file...
p4 [g-opts] edit -So [-c changelist]

Syntax conventions

Description

files

p4 edit opens files for editing within the client workspace. The specified files are linked to a changelist, but the files are not actually changed in the depot until the changelist is committed with p4 submit.

Helix Server controls the local OS file permissions. When p4 edit is run, the OS write permission is turned on for the specified files.

When a file that has been opened for edit with p4 edit is submitted to the depot, the file revision that exists in the depot is not replaced. Instead, the new file revision is assigned the next revision number in sequence, and previous revisions are still accessible. By default, the newest revision (the head revision) is used by all commands that refer to the file.

By default, the specified files are added to the default changelist. Use -c to specify a different changelist. (Or use the p4 change command to move files from the default changelist to a numbered changelist.)

To move files already opened for edit from one changelist to another, use p4 reopen.

streams

See -So in the Options section.

Options

-c changelist

Opens the files for edit within the specified changelist. If this option is not provided, the files are linked to the default changelist.

-k

Keep existing workspace files; mark the file as open for edit even if the file is not in the client view. Use p4 edit -k only in the context of reconciling work performed while disconnected from the shared versioning service.

-n

Preview which files would be opened for edit, without actually changing any files or metadata.

--remote=remote

Opens the file for edit in your personal server, and additionally — if the file is of type +l — takes a global exclusive lock on the file in the shared server from which you cloned the file.

For more information, see the section Support for exclusive locking in the Fetching and Pushing chapter of Using Helix Core Server for Distributed Versioning.

-t type

Stores the new file revision as the specified type, overriding the file type of the previous revision of the same file. To forcibly re-detect a file’s filetype (that is, to assign a file type as if the file were being newly added) upon editing a file, use p4 edit -t auto.

See File types for a list of file types.

-So

Can be used with -c changelist to open the client's stream spec for edit. No list of files is allowed. p4 edit -So is an alias for p4 stream edit (see also p4 help streamcmds).

g-opts

See Global options.

Usage Notes

Can File Arguments Use Revision Specifier? Can File Arguments Use Revision Range? Minimal Access Level Required

No

No

open

Because p4 edit turns local OS write permissions on for the specified files, this command should be given before the file is actually edited. The process is:

  1. Use p4 edit to open the file in the client workspace,
  2. Edit the file with any editor,
  3. Submit the file to the depot with p4 submit.

To edit an older revision of a file, use p4 sync to retrieve the previously stored file revision into the client workspace, and then p4 edit the file. Because this file revision is not the head revision, you must use p4 resolve before the file can be stored in the depot with p4 submit.

By default, Helix Server does not prevent users from opening files that are already open; its default scheme is to allow multiple users to edit the file simultaneously, and then resolve file conflicts with p4 resolve. To determine whether or not another user already has a particular file opened, use p4 opened-a file.

If you need to prevent other users from working on files you’ve already opened, you can either use the p4 lock command (to allow other users to edit files you have open, but prevent them from submitting the files until you first submit your changes), or you can use the +l (exclusive-open) filetype to prevent other users from opening the files for edit at all.

In older versions of Helix Server, p4 edit was called p4 open.

Examples for files

p4 edit -t text+k doc/*.txt

Opens all files ending in .txt within the current directory’s doc subdirectory for edit. These files are:

  • linked to the default changelist

  • stored as type text with keyword expansion

p4 edit -t +l //depotname/...

Implements pessimistic locking (exclusive-open) for all files in a depot. After this changelist is submitted, only one user at a time will be able to edit files in the depot named depotname.

p4 edit -c 14 ...

Opens all files anywhere within the current working directory’s file tree for edit. These files are examined to determine whether they are text or binary, and changes to these files are linked to changelist 14.

p4 edit status%40jan1.txt

Open a file named [email protected] for edit.

For details about how to specify other characters reserved for use as Helix Server wildcards, see Limitations on characters in filenames and entities.

Examples for a stream

p4 edit -So

Opens the current stream spec to the default changelist.

p4 edit -So -c 14

Opens the current stream spec to the specified numbered change list

Related Commands

To open a file for add

p4 add

To open a file for deletion

p4 delete

To copy all open files to the depot

p4 submit

To copy files from the depot into the client workspace

p4 sync

To create or edit a new changelist

p4 change

To list all opened files

p4 opened

To revert a file to its unopened state

p4 revert

To move an open file to a different changelist or change its filetype

p4 reopen