views:

4565

answers:

8

I sometimes use the feature 'Reconcile Offline Work...' found in Perforce's P4V IDE to sync up any files that I have been working on while disconnected from the P4 depot. It launches another window that performs a 'Folder Diff'.

I have files I never want to check in to source control (like ones found in bin folder such as DLLs, code generated output, etc.) Is there a way to filter those files/folders out from appearing as "new" that might be added. They tend to clutter up the list of files that I am actually interesting in. Does P4 have the equivalent of Subversion's 'ignore file' feature?

+1  A: 

From the manual:

To exclude files from source control: in the directory where the files reside, create a text file named .p4ignore and enter the directories and file names you want to exclude. When you specify a directory, all its subdirectories are ignored. You cannot use wildcards in .p4ignore files.

Will Sargent
This is what concerns me about this site. Have you tried this? I have. It doesn't work.
raven
I just tried it. It works for me. My .p4ignore is a single line with ".idea *.log *.pid" and sure enough, it refuses to add files in the .idea directory or with .log or .pid on the end.
edebill
It only works for the Eclipse Perforce plugin. P4, P4V, and P4Win do not support .p4ignore files.
Mike
+18  A: 

Assuming you have a client named "CLIENT", a directory named "foo" (located at your project root), and you wish to ignore all .dll files in that directory tree, you can add the following lines to your workspace view to accomplish this:

-//depot/foo/*.dll //CLIENT/foo/*.dll
-//depot/foo/.../*.dll //CLIENT/foo/.../*.dll

The first line removes them from the directory "foo" and the second line removes them from all sub directories. Now, when you 'Reconcile Offline Work...', all the .dll files will be moved into "Excluded Files" folders at the bottom of the folder diff display. They will be out of your way, but can still view and manipulate them if you really need to.

You can also do it another way, which will reduce your "Excluded Files" folder to just one, but you won't be able to manipulate any of the files it contains because the path will be corrupt (but if you just want them out of your way, it doesn't matter).

-//depot/foo.../*.dll //CLIENT/foo.../*.dll
raven
While this works, it's not very useful as you will have to put these lines in to every workspace you ever create.
dgrant
@dgrant: How can you say this is not useful when it does what was asked? So what if you have to put it in every workspace? How hard is it to copy and paste some text?
raven
Note: this does not work for the normal reconcile offline work from p4v. The "excluded files" only seem to be in the "advanced" reconcile window...
Catskul
The exclude filter does not work inside the `Reconcile Offline Work` dialog. It does work if you open it inside `Advanced Reconcile...` but this is useless because in 99.9% of the the time you do not need or want to use the advanced dialog.
Sorin Sbarnea
Imagine how easy is to do a reconcile on a Python project where the listing will contain hundreds of `.pyc` files. Also the idea of keeping the ignore rules on the workspace is a very poor one, who will imagine that all developers will be able to sync their ignore rules?
Sorin Sbarnea
I didn't think you could get any more *unnecessarily* complex than the effort of copying a group of source file to a new location while preserving their change history. Then I tried to ignore files...
280Z28
@280Z28: Yeah, I guess they don't make it easy, do they? Although, I can't say it bothers me much. In nearly 7 years of Perforce use, I have *never* had the need to do this. I'd like to hear a use case.
raven
@raven: 1) (Example:) Some projects use bin/obj folders under each project instead of having them in a central location. (Generalized conclusion:) Perforce's assumption that all intermediate files are placed in an easily excluded workspace location is an unnecessarily restrictive design for a VCS to be making. 2) Some projects involve local cache and/or other per-user generated files in the directory structure (as an example, the *.ncb IntelliSense cache). The inability to exclude them as a common policy severely impairs the Reconcile Offline Work and Diff Folders features.
280Z28
This particular problem is killing me.
Warren P
+2  A: 

Will's suggestion of using .p4ignore only seems to work with the Websphere Studio (P4WSAD) plugin. I just tried it on my local windows box and any files and directories that I listed were not ignored.

Raven's suggestion of modifying your client spec is the correct way under Perforce. Proper organization of your code/data/executables and generated output files will make the process of excluding files from being checked in much easier.

As a more draconian approach, you can always write a submit trigger which will reject submission of changelists if they contain a certain file or files with a certain extension, etc.

Mark
I completely disagree with the whole "Proper organization of your code..." statement. The fact of the matter is, following Perforce's convention of editing the workspace requires every user to make the change. Whereas, a true .p4ignore file would only be created/managed once.
Mike
Oh, and not to mention, you like to branch your code? Good luck maintaining your workspaces for each branch. That sounds like fun!
Mike
+2  A: 

but a solution that can be checked in (like .p4ignore or .svnignore files) would be better, since you have to do this once and all participating developers of that project would use the same filters, that can be changed and adjusted over time according to project evolution...

A: 

I tried to use this to ignore the "target" folders that maven generates when doing a "diff against" operation in P4V. It's almost working, but when I switch to "View as flat list" I still see all of the excluded files. The tree view seems to work, but without an "expand all" button it's a real pain in the butt to navigate.

-//depot/.../target/.../* //CLIENT/.../target/.../*

Anyone know if there's a way to tweak the list view or expand all the changes in tree view?

Thanks in advance!

matschaffer
for best results, you might want to add this as a new question, referencing this question in the description
akf
I have the same problem, with REconcile Offline work, it still shows everything I am trying to ignore.
Warren P
granted this is offtopic, but eventually on this project I switched to using git-p4 for this. I like git a lot better and the perforce integration isn't bad. Not sure how it handles branching though since the project never got that large.
matschaffer
A: 

If you are using the Eclipse Perforce plugin, then the plugin documentation lists several ways to ignore files.

antrix
duplicate, and doesn't answer the question
Warren P
+1  A: 

If you want a solution that will apply to all workspaces without needing to be copied around, you (or your sysadmin) can refuse submission of those filetypes through using lines like the below in the p4 protect table:

write user * * -//.../*.suo
write user * * -//.../*.obj
write user * * -//.../*.ccscc

I remember doing this before, but I don't have the necessary permissions to test this here. Check out Perforce's Sysadmin guide and try it out

Mike Burrows
Unfortunately this causes errors on submit rather than having the reconcile view ignore. So it can keep certain files out of a repository, but it can't help your users not to see noise.
Warren P
+1  A: 

You can not write and check in a file that the server will use to make ignore rules; general glob or regex file pattern ignore in perforce.

Other answers have global server configurations that are global (and not per folder). The other answers show things that might work for you, if you want one line in your view per folder times number of extensions you want to ignore in that single folder, or that provide this capability in Websphere Studio plugins only, or provide capability for server administrators, but not available to users.

In short, I find Perforce really weak in this area. While I appreciate that those who use the Eclipse Plugin can use .p4ignore, and I think that's great, it leaves those of us that don't, out in the dark.

Warren P