p4 obliterate
Synopsis
Removes files and their history from the depot.
Syntax
p4 [g-opts
] obliterate [-y -A -b
-a -h]
file
[revRange
]
...
Warning
Use p4 obliterate with
caution. This is one of only two commands in Perforce that
actually removes file data. (The other command that removes file data is
the archive-purging option for p4 archive
.)
The p4 obliterate
command actually deletes the server’s copy of
a file’s data, precluding any possibility of recovery. (By contrast, the
p4 delete
command merely marks the latest revision
as deleted, but leaves earlier revisions intact in the depot.)
Description
p4 obliterate
can be used by Perforce administrators to
permanently remove files from the depot. The file is removed from the
Perforce service, along with all associated metadata, including
references to the file in labels, the have list, and so on. After p4
obliterate
completes, it appears to the service as if the affected
file(s) had never existed. Copies of files in user workspaces are left
untouched, but are no longer recognized as being under Perforce control.
p4 obliterate
requires at least one file pattern as an argument.
To actually perform the obliteration, the -y
option is required;
without it, p4 obliterate
merely reports what it would do
without actually performing the obliteration.
If you specify a single revision (for instance, p4 obliterate
file#3
), only that revision of the file is obliterated. If you
specify a revision range (for instance, p4 obliterate file#3,5
),
only the revisions in that range are obliterated.
Note
p4 obliterate myfile
does not obliterate a shelve of the file
(archive or metadata). When you attempt to unshelve a file that has been
obliterated, you will get an error. To recover the content of that file,
print the file. To get rid of the shelve, delete the shelf.
p4 obliterate
with a file spec does not obliterate a shelve of
the file.
Options
|
Perform the obliterate operation. Without this option, |
|
Obliterate a revision marked for archive. By default, archived revisions are skipped. |
|
Restrict files in the argument range to those that are branched, and
to files that are both the first revision and the head revision.
This option is useful for removing old branches (where only one
revision exists) while preserving files that have been modified
post-branch. You can greatly improve the performance of
|
|
Skip the (potentially resource-intensive) search of |
|
Skip the search of |
|
See “Global Options”. |
Usage Notes
Can File Arguments Use Revision Specifier? | Can File Arguments Use Revision Range? | Minimal Access Level Required |
---|---|---|
Yes |
Yes |
|
p4 obliterate
is one way to reclaim disk space from files that are no longer required, or to clean up mistakes made by users who create file hierarchies in the wrong place. Do not use operating system commands (erase
,rm
, and their equivalents) to remove files from the Perforce server root by hand.- A better way to save disk space is to relocate infrequently-accessed
files onto lower-performance (or detachable) storage. Instead of
obliterating files outright, consider using
p4 archive
andp4 restore
in conjunction with an archive depot. With archive depots, file history is preserved and available to all users, and file contents may be moved to offline or near-line storage. - Obliterating files can alter the behavior of user commands. Syncing to an obliterated file does not remove the file from your client workspace, because the file is no longer part of any client workspace. Syncing to an obliterated revision of a file will either report that the file does not exist (if all revisions were obliterated), or provide you with the most recent non-obliterated revision of the file.
-
Obliterating files in revision ranges can also change the behavior of scripts, as revision numbers of files may "skip" obliterated revisions. For instance, the output of
p4 filelog
after obliterating revisions#2
and#3
might look like this:... #4 change 1276 edit on 2011/04/18 by user@dev1 (binary) 'Fixed' ... #1 change 1231 add on 2011/04/12 by user@dev1 (binary) 'First try'
In this case, a developer using the
#4
in the first line of the output to assume the existence of four change descriptions in the output ofp4 filelog
would encounter difficulty.
Examples
p4 obliterate
|
Do not obliterate any files; list the files that would be obliterated
with the In this case, all files in directory |
|
Obliterate |
|
Obliterate only the third revision of If If |
|
Obliterate revisions 3, 4, and 5 of If If |