Why can't I delete this perforce changelist? - perforce

I'm new to perforce and somehow I've gotten myself into a weird state.
I have two files that I modified and somehow added to a change list (not the default changelist). I want to revert the changes and delete the changelist but I can't figure it out.
I have tried doing this:
p4 change -d 75697
Change 75697 has 2 open file(s) associated with it and can't be deleted.
So I tried to revert the files in the change list:
p4 revert package.json
package.json - file(s) not opened on this client.
Okay, so I guess I need to open the file?
p4 edit package.json
//a/b/c/package.json - can't edit (already opened on this client)
So I can't revert the file until I open it but I can't open it because it's already open? What's the deal?

You could be getting that error because your local package.json doesn't map to the actual depot path that's open (due to something tricky you've done with your client view since opening the file). It's hard to say without seeing more command output, but try just:
p4 revert -c 75697 //...
to revert all files in that changelist regardless of their paths.
If that doesn't work, check with your Perforce admin; either they've put you into some really weird permissions bind (i.e. they've revoked the access level to the files that you need in order to revert them) that they should undo, or they'll need to do a bit of light db maintenance (p4d -xf 925) to fix an inconsistency.

Related

P4V Get Latest does nothing

I do not want to go "Get Revision" > "Force". Because half of my stuff is already downloaded. I don't want to overwrite what I already have. P4V Can clearly see that what is in the depot and what is local is completely different. How can I get Perforce to retrieve the files I do not have, and ignore the ones I already do?
Select your workspace root, go to File > Open Command Window Here, and run:
p4 clean
This will scan your workspace and force-sync everything that's different or missing, as well as deleting unadded files. Note that if you have local work that isn't in a changelist, this will irrevocably erase it. If you only want to "clean" files that are edited/present but out of date (and disregard added/deleted files), do p4 clean -e instead. If you want to preview the operation before doing it for real, do p4 clean -n.
I think you can do the equivalent via the "Reconcile Offline Work" tool in P4V, but it may require additional manual steps.
To make working with Perforce easier, try to avoid modifying files in your workspace that are read-only -- if you want to remove a file from your workspace, use "remove from workspace" in P4V rather than manually deleting it, etc. Perforce is able to make file operations very fast by virtue of knowing what's in your workspace and not having to re-check it each time, but you eliminate that benefit when you mess with your workspace manually.
Instead of p4 clean, you could do:
reconcile offline work on root of workspace then a pop-up saying that you deleted some files and it is going to delete them from Depot of the server as well make sure you added to default or new changelist or whatever. Accept.
Go to changelist and right-click press revert files to bring back the deleted/missing files.

Make the contents of a perforce directory exactly match the latest depot version

I would like to make the contents of a directory in a Perforce workspace be exactly the same as the latest depot contents. I want this to work no matter what has gone on in the workspace. (For example, editing files without opening them in perforce, creating unsubmitted changesets, etc.)
So far I have come up with running this series of commands, in order:
p4 clean ...
p4 revert ...
p4 sync ...
Will this do what I want? Is this the correct order? Is there a simpler way?
Those are the correct commands, and you do need all three:
revert is needed to discard changes to files you've opened
clean is needed to discard changes to files you haven't opened (including added files)
sync is needed to make sure you're at the very latest depot revision
You should either put clean after the revert or add -w to revert; otherwise files that were opened for add will be skipped by the clean (because they're open) and then revert will "abandon" them in the workspace (the -w option causes revert to delete/"wipe" added files instead of abandoning them). Other than that, I think the order is unimportant.

Perforce Change List too Big

In Perforce, I have created a change list that has over 200,000 files (by doing a rename on a directory). This change list is now too big to submit or revert. When I try, I get an error saying that the operation took too long.
I am now stuck with this change list that has my original directory in marked for delete state and a new directory that hasn't been submitted. Is there a way undo this change list?
You can revert the files a few at a time. As a test, you could run p4 revert //path/to/some/file and verify that it's able to revert that file.
Once you know that's working, you just need a way to automate the process.
You could script something up that starts in the root directory and runs through all directories breadth-first, running p4 revert //path/to/folder/* at each folder (I think you could also use client paths).
You can revert via the command line using the p4 tool. I do not think you can revert the files from the UI. The associated documentation shows various examples of how revert all or specific files (see the Examples section):
http://www.perforce.com/perforce/r12.1/manuals/cmdref/revert.html

What can I do with a file open for 'add', if it's submitted via another client

With Perforce, I have the following situation:
Created a new file foo.txt in client client_a, opened it for add
Shelved foo.txt in client_a, unshelved it in client_b
Now foo.txt is open for add in client_b
Submit foo.txt in client_a
Now my question concerns how I can cleanup foo.txt in client_b. Maybe it has a one line change from the depot version that I'd like to keep. Ideally I'd like to do a resolve operation against the newly checked in file, but I'm not allowed to do this because it's open for add.
Now I have this file foo.txt#1 - add change default in my client.
I can't reopen the file ('nothing changed'), I can't diff it vs the depot ('file not open for edit'), I can't resolve it against the depot ('no files to resolve'), I can't open it for edit ('can't edit, already opened for add').
Is there any way to make perforce reopen this as edit instead of add? I know I can copy it to a temp file, revert, reopen for add, and then recopy the temp file back over, but this seems rather unelegant. Is there any command that can do what I want, or is there a good reason I'm not seeing why it's disallowed?
Only slightly more elegant than the comment in your last paragraph, but you should be able to:
Revert foo.txt in client_b. Since it was marked for add the file will remain on the disk with no changes
Sync foo.txt with -k. This makes the server think you have the latest revision without modifying your local file.
Check out foo.txt for edit. Diff'ing against the have revision should show the changes.
Submit your changes.

Perforce Revert Shows "file(s) not opened on this client"

I'm trying to open an existing Perforce application. I made some local changes, like deleting files, which I want to undo (that is, I want my local copy to exactly match the repository once more -- delete added files, restore deleted files, and undo changes).
When I try to revert using the p4v gui client, I see this error:
file(s) not opened on this client
What am I doing wrong?
I did manage to revert all the changed files, but not the added/removed files.
Edit: I did the following:
Connect to a Perforce server using p4v
Map a directory to my local file system (lets say C:\Perforce)
Get the latest version of the repository
Go to C:\Perforce in Windows Explorer
Delete some files and folders
Add some files and folders
I would like to get back to the "pristine" state, the copy of exactly what's on the server when I got the latest version of the repository for the first time.
By the looks of the edited description you added and deleted files directly on the filesystem and not through perforce. Therefore Perforce doesn't know anything about those changes so there is nothing to revert. Typically when you want to add a file you use 'p4 add" (or the equivalent p4v operation), and when you delete, you should use 'p4 delete' (or again, the equivalent p4v operation).
Really, the best option to get back to a pristine state is to nuke the local copy of the code in c:\perforce (in windows explorer), go to p4v, right click the area you want to sync, and choose "Get Revision..." and in the subsequent dialog, make sure that the "force operation" checkbox is checked. This will tell Perforce that you want a new copy of everything regardless of whether you had it synced or not.
You can also run "reconcile offline work" in p4v. Right click the depot area and choose that option. It will scan through the local folder structure and give you a report of what files have been added that don't exist in perforce, what files were deleted, and what files were modified. From that dialog, you can right click on local files that don't exist in perforce and delete them, or you can 'p4 add' them. You can also sync deleted files.
HTH.
Just an extra not to point out another cause for this.
If the file name contains an unusual character that cannot be translated correctly the name on the client will never match that on the server.
The solution in this case is to spot that character in the file name (it will be a question mark emblem on Linux) and use a wildcard to help identify the file to the server so it can delete it etc (p4 deleting the file is a way to go).
This answer may not be your case. This happened to me when I edited the files on my local disk without logging into p4.
A quick fix at commandline is:
p4 login # make sure you've logged in
p4 edit <filename> # let p4 know you've edited the file
p4 revert <filename> # revert to "pristine" state
You can use p4 reconcile -w to restore your client to the state of the server. There is an alias called clean, which is also available in P4V on the right-click context menu as Clean....
There are several additional flags to control whether added and deleted files are deleted or restored, respectively.
The -w flag forces the workspace files to be updated to match the
depot rather than opening them so that the depot can be updated to
match the workspace. The -a, -d, and -e flags when used with -w
update workspace files as follows:
-a Files with no corresponding depot file are deleted.
-d Depot files not in the workspace are added.
-e Modified files are restored to the last version synced.

Resources