开发者

Perforce overwrote code that I forgot to checkout. How do I recover it?

开发者 https://www.devze.com 2023-03-21 23:50 出处:网络
I forgot to check out a source code file before modifying i开发者_如何学运维t. When I get last revision, Perforce overwrote that file, so my work is totally lost.

I forgot to check out a source code file before modifying i开发者_如何学运维t. When I get last revision, Perforce overwrote that file, so my work is totally lost. Is it possible to recover the file?


For future use, update your client workspace so that you specify "noallwrite, noclobber". If noclobber is set, Perforce will not overwrite your writable un-opened files: http://www.perforce.com/perforce/doc.current/manuals/cmdref/client.html


Only if your editor or your operating system saved a copy or it's been modified long enough that it made its way to your backups. Perforce will not make copies of such files, it blindly assumes that you didn't lie and will always honestly tell it when you want to edit a file.


if you are using eclipse then its possible to retrieve the local version using Compare With -> Local history . It helped me.


This has happened to me recently. For some reason, after I "p4 sync"-ed my workspace, and do p4 resolve, I noticed that my changes to a file were missing. I'm not sure if my changes were not saved or I haven't checked out the file. But I really remembered that my changes were saved. :(

I have been using Visual Studio for development and it doesn't have local history unlike in Eclipse. Luckily, that file is a javascript file and I have been testing my application in Internet Explorer. Since IE does some caching on some internet data like js files, what I did is to check the directory where it saves temporarily files (Internet Options -> Browser history settings ) there you'll see different versions of the files saved. I did recover my files! It was really just luck!

After that incident, I installed a plugin for visual studio for storing local history of files everytime it's being saved. http://visualstudiogallery.msdn.microsoft.com/226c2108-9da9-407d-b90d-9783040d27b8

Best thing to avoid these cases is to:

  1. branch out your files first into a separate devline during development and submit every milestones you accomplished incrementally. In this way you'll always have versions of important changes you do during development. After this you could
  2. integrate it back to the parent branch/mainline.

http://answers.perforce.com/articles/KB_Article/Branching-Codelines-and-Merging-Changes

Hope this helps!


If you fired the following command (which is a FORCE sync option), only then will Perforce update ALL your files.. including ones which are WRITABLE. The only exception is that any file that you have OPENED in perforce will not be overwritten. So if your file was made WRITABLE using OS command, and not using p4 open.. they will get overwritten by p4 sync -f.

p4 sync -f  

The other possibility is that you did p4 sync, and still perforce overwrote your writable files (which were not opened using p4) because your workspace settings don't have noallwrite, noclobber specified. Usually by default, these settings are already specified, so that Perforce doesn't clobber writable files.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号