Search code examples
perforceperforce-integrate

perforce doesn't overwrite file when forcing revision


My problem is not the "scary" issue of perforce overwriting my files, but the opposite, that it doesn't.

I want to be synchronized with code other people wrote, so I am doing in perforce: "get revision" and then "force operation" from the stream everyone are submitting their work to (after saving a backup of course for the file I am working on in my computer), but when I open the file in eclipse it remains with my changes.
Further - I am doing some small, deliberate changes in my file, and "get revision" and then "force operation" to it, and the same happens.

I have been working in the same workspace for the last days, and when I did it yesterday it overwrote my files, as expected.

Also, in the "submitted" tab in Perforce this file is not in the list, so I didn't accidentally submitted it somehow.

Also, by opening the file from the File System, my changes remain, so it doesn't seem like a problem with eclipse refreshing or something like that.

Ay idea, anyone?


Solution

  • If the file is recorded as "open" in Perforce (i.e. it is returned by the "p4 opened" command, or it appears in the "pending changes" tab in the GUI), even a force-sync won't overwrite it, because you're still working on it. If you want to discard your changes to get something someone else submitted, do one of these two things:

    • Sync as normal, then resolve with "accept theirs".
    • Sync as normal, then revert. (Or revert, then sync.)

    The first option leaves the file open; the second option does not.

    If you want to save a backup of your current work in Perforce (without submitting it), rather than making a local copy of it, you can "shelve" the pending changelist, and "unshelve" it at a later date to return your workspace to the shelved state.