Reverting unshelved files in perforce
Asked Answered
K

3

7

I have unshelved a cl that contained an 'add' file called foo.txt. When i revert that changelist the foo.txt disappears from my workspace but stays on my hdd.

p4 unshelve -f -s $A -c default :: unshelving add foo.txt
p4 revert -c default //MY_WORKSPACE/... :: foo.txt is reverted
p4 opened -C MY_WORKSPACE :: shows none

When i open the workspace i still can see the foo.txt.

is there a way to delete the added file ? (Except the obvious of deleting it manually)

Kusin answered 23/4, 2013 at 16:37 Comment(4)
This doesn't actually have anything to do with unshelving. Your question is really about reverting added files.Takishatakken
possible duplicate of Perforce: 'remove from workspace' from command line?Ulrika
@Ulrika This has nothing to do with 'remove from workspace'. This is about what happens to the local file, after p4 add followed by p4 revert. (With shelve, unshelve thrown in to complicate matters).Biotite
I see now. I withdraw my close vote.Ulrika
O
3

Running the revert command with -w flag will delete any files marked for add during the revert (see p4_revert docs)

p4 revert -w [file specification]

e.g., p4 revert -w -c default //MY_WORKSPACE/... (foo.txt is deleted from disk, then reverted)

Overseer answered 20/8, 2015 at 5:20 Comment(1)
This a great solution! Note that 'revert -w' requires that your server be at version 2013.2 or higher.Massproduce
E
2

Such behaviour is by design.

http://www.perforce.com/perforce/doc.current/manuals/p4guide/04_files.html

Discarding changes (reverting)

To remove an open file from a changelist and discard any changes you made, issue the p4 revert command. When you revert a file, Perforce restores the last version you synced to your workspace. If you revert a file that is open for add, the file is removed from the changelist but is not deleted from your workspace.

Explicable answered 29/4, 2013 at 15:59 Comment(0)
B
0

Once you've reverted the file add in Perforce, I think you can just delete them from the disk - Perforce has forgotten about them entirely.

Biotite answered 23/4, 2013 at 16:43 Comment(6)
Shouldn't the revert function do that?Kusin
@Twisted: The thinking is probably that it'd be dangerous for the revert command to do that since if you do it by accident, you're likely to lose a significant amount of work. (Arguably they could add a command-line option to revert to do it, though.)Takishatakken
Well, it's time to revise my shell scripting knowledge.Kusin
No, Perforce has not forgotten about them entirely. It knows that you have them in your workspace. If you delete them outside of Perforce, they won't appear again during a sync operation because Perforce thinks you already have them. You would have to do a forced sync. Use Perforce to delete them so as not to confuse the server.Ulrika
@Ulrika That would apply to files already submitted to the repository. But I don't think that applies to files after p4 add p4 revert. What version would it sync, since there is no revision in the repository?Biotite
@DouglasLeeder: You're right. My bad. I completely misinterpreted the question.Ulrika

© 2022 - 2024 — McMap. All rights reserved.