How to ignore "Unversioned Files" if using Perforce, not git (2021.2)?
I have a bunch of files under "Unversioned files" in my "Local Changes" tab:
When I bring up the browser for them and navigate down to a directory, I am presented with the following options:
I want to ignore this directory. We're using Perforce, not git, but what the heck, I'll select Add to .gitignore anyway. I click it, and it opens up a .gitignore file. Doesn't add it to the file, but OK, I'll add it manually. I save the file, my Local Changes window refreshes, and ...
No difference. Same number of Unversioned files. Click browse, and sure enough, that directory is still in the list.
I suspect this is because we're using Perforce, not git, and so Perforce isn't seeing the changes to the .gitignore file. So I go into our .p4ignore file, and add the directory there. Save, watch "Local Changes" refresh, and ...
Nothing. No difference.
In prior versions, this was easy. Right-clicking in the browse window gave me options like "Ignore file(s)" and "Ignore directory", and they just worked. I remember that there were usability issues with the UI for it, but fundamentally, it worked.
Is there a way for me to turn on the old UI? Or to make this new system work with Perforce?
Please sign in to leave a comment.
Hello Rob Freundlich
Could you please check whether you have git repository listed under Preferences | Version Control?
Also, please click on "Refresh" button (once you've changed perforce configuration/env. variables) in Local changes.
Nope. The entire project is mapped to Perforce:
I've tried that, with no effect.
Rob Freundlich
I am sorry, but I saw that there was a message that mentioned git tool that you were using. Could you please clarify whether you still can see "Add to .gitignore"? Would it disappear if you change mapping from <Project> to a path to a project?
Also, you've mentioned that you've configured p4ignore. If you go Preferences | Version Control | Perforce and click "Test connection" - would you see P4IGNORE variable there?
Once you set it, added some file to p4ignore.txt, then you need to go to Local changes and click "Force refresh" (I am sorry, last time I've said use "Refresh". Force refresh is a red button) and once you click on "Browse" you shouldn't be able to see files that are mentioned in p4ignore.txt
Hi, Ruslan Kuleshov,
Yeah, I misunderstood your earlier question at first, and wrote in that I do see git in the list of Version Control providers. I was saying that I've got git installed because one of our tool projects lives in a git repository. But our product project and all of its modules are all in Perforce. I deleted that comment because I then figured out what you meant, and I don't generally keep that tool project open.
Yes. its value is "target;web;*.class"
Yes, if I change the mapping to be the root path of my project, "Add to .gitignore" goes away.. The number of Unversioned files goes up dramatically. We don't have a p4ignore.txt, but we have .p4ignore files (at various levels). I don't know why we're set up this way, but it works for us for our Perforce setup outside of IntelliJ.
I tried creating a p4ignore.txt and adding a directory that we have in various places that I want ignored to it, and force-refreshing, and it didn't ignore files in those directories.
I tried adding that directory to the existing .p4ignore files and force-refreshing. same result - they're still not ignored.
Why do I need to manually edit a VCS-specific file to manage the unversioned files? In prior versions, the UI provided operations to ignore files, patterns, and directories, but this was problematic because they were stored internally to IntelliJ. Storing them in a VCS-specific way is a great move, because VCS commands will then understand them. But I think you've gone too far in the VCS-specific direction. The UI could provide the operations, and they could be stored in a VCS-specific way. Then, regardless of whether I'm working on a Perforce-managed project or a git-managed project, I get the same UI and none of this complexity and bugginess.
Hi, Rob Freundlich
Indeed, there used to be 2 separate ignore mechanism in the IDE - builtin Ignored Files list (it was working only in the IDE and no other tools knew about it) and native ignores of the respective VCS. P4IGNORE in case of Perforce.
Since 2019.1, the builtin Ignored list has been deprecated in favor of native ignores.
>Yes. its value is "target;web;*.class"
Do I understand correctly that these values are set inside P4IGNORE variable, not in .p4ignore file that is specified in P4INGORE variable?
That's the thing, though. IntelliJ doesn't seem to be paying attention to the p4 ignore system we are using.
That's correct
Rob Freundlich
As I can see in Perforce documentation it is required to specify a file in P4IGNORE variable that contains filenames/patters, please see:
https://www.perforce.com/perforce/doc.current/manuals/p4guide/Content/P4Guide/less_common.files.ignore.html
Please check, whether it would work if you would use file in P4IGNORE
Nope. I had a P4IGNORE that looked like this:
I changed it to point at a .p4ignore file, and it had no effect. Then I changed it to look like this:
to see if perhaps it was using it for the list of ignore rules, and perhaps it would now ignore my generated directories. Nope.
Rob Freundlich
>I changed it to point at a .p4ignore file, and it had no effect
once you've done it - have you checked in IDE settings whether P4IGNORE variable has changed?
You can also test you .p4ignore file with this article:
https://community.perforce.com/s/article/6510
And once you specify something in .p4ignore file you can try to run:
To see whether ignore applies to that file.
I think part of the problem, if not the entire problem, is that we have .p4ignore files all over the place. I don't know what the reason or history behind that is, but it means my .p4config file doesn't point to an ignore file, and I can't just point the IntelliJ IDE at a single ignore file.
Both the Perforce command line client and the Perforce Windows GUI client work just fine with this setup. My expectation was that the IntelliJ IDE's Perforce support would use the same logic as the Perforce clients. But what I'm coming to realize from this conversation is that it doesn't. The only question now is whether our setup is something that's not officially supported by Perforce, and we're just lucky that it works, or whether this is something that is officially supported by Perforce.
If the former, I need to push folks here to change and follow the official pattern. If the latter, I need to push you folks to support the way we're doing things.
@... FreundlichIf you have P4IGNORE set correctly, like `P4IGNORE=.p4ignore` it means that Perforce will take into account all p4ignore files in a project.
As a matter of test, could you please run commands in the terminal:
`p4 set`
`SET`
And see if they both contain "P4IGNORE" variable?
Have you tried to run `p4 set P4IGNORE=.p4ignore` and then click `Force Refresh`?
SOLVED!!!!!
My P4IGNORE was set to a bunch of .p4ignore file patterns separated by semicolon. I set it to ".p4ignore" and started mucking around with some of the .p4ignore files in my sandbox. Sure enough, the Unversioned files started decreasing. It turned out we didn't have one in the root directory, so I put one there for myself, and just started going to town on it, adding patterns and refreshing until I got my Unversioned files down to a (small) list of files that are in areas of the product I don't understand and can't really make patterns for.
I can live with that.
Thanks SO much for your help on this!