开发者

What's the Right Way to Make Minor Local Edits on Files in Perforce through Eclipse?

开发者 https://www.devze.com 2023-03-19 03:38 出处:网络
I\'m working at a company that uses Perforce, and find it really annoying that when I edit something locally for a purely local purpose (maybe I want to change a path to point to something local for t

I'm working at a company that uses Perforce, and find it really annoying that when I edit something locally for a purely local purpose (maybe I want to change a path to point to something local for testing, etc...), that change is automatically added to my pending changelist and winds up cluttering it up. Intuitively, this seems strange, and in practice it's pretty annoying. It also makes it look to others like I'm editing the file and plan to upload it back to the depot, when this isn't at all my intent. All of that said, is there a simple way to differentiate between edits I plan on submitting, and edits I only want to exist loca开发者_如何学Golly? I'm using the eclipse plugin for Perforce, so bonus points if someone can give me a way to easily do it there. I know this is probably a stupid question, but I'm gonna need to find the answer at some point, so it might as well be now.


Why don't you create a separate changelist into which you put files that you don't intend to check in? It is still going to show up as being under edit to others, but why does that matter? Having these files tracked as changes in a CL gives you an easy way to revert back to Perforce copy when you need to as well as merge with any incoming changes.

Andy already mentioned "make writable" trick. To revert back from that position, you can run the check consistency action. It will find files that were modified, but not checked out. This is also a good way to work offline. Make it writable and then run check consistency when back online.

Another alternative is to copy file contents to clipboard, tell perforce to remove the local copy of that one file and then create a new file in its place with contents from the clipboard. From Perforce perspective the file at that point hasn't been synched to your workspace. When you go to sync, you will get a notice of collisions with existing local files that you would have to resolve by forcing the sync or deleting the local files.

Another alternative if you edit a certain specific file frequently is to use your client spec to map it out completely. Perforce will not try to sync it from depot and you can maintain a local equivalent however you want.

On a somewhat related note... If you find yourself doing this a lot, consider that perhaps what's in Perforce isn't as general as it should be. Maybe a property or an environment variable could be added so that you can override some setting without editing the file.


Well, I can tell you are worried about several things - I am not sure you can realistically fix any of them without causing yourself some pain in other ways...

One suggestion would be to create a branch for your work, that you later integrate back into the main line. That way your small edits don't show up to others - unless they are using your branch for some reason.

I would venture a guess that the small edits for your local dev/testing are probably more an indicator of something that could be improved in your code base. If you are tweaking files to adjust file paths, well, make the files themselves smarter: Read the values from a database, have switches based on host names, use environment variables... something. I think you can find ways to both improve the code and not have the little annoyances.

I find Perforce is incredibly flexible and really is intended to help you be more productive and generally get things done. If you find that you are fighting with your version control system, chances are you could be doing something a better way.


One way is to right-click on the file to "Properties", and clear the "Read only" flag.

It's now writable, but not checked out.

0

精彩评论

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