In Perforce P4V, how to I search for changelists with files in particular folders? - perforce

In Perforce P4V, I'd like to do a search for all changelists that have files from a particular set of folders, that all have "index" in the folder name, and also have another folder at the beginning. For instance, I want to see all changelists against any files in folders like these:
\depot\abc\def\table\index*.*
\depot\abc\ghi\table\index*.*
so basically any folders that match the pattern
\depot\abc\...\table\index*.*
But this doesn't appear to work. Any ideas? Also is there any detailed information on using perforce wildcards online? I was not able to find a whole lot. This must be something that lots of people need to do...

I use both P4V on Windows and I use the 'p4' command line client on Linux. What you're asking for actually uses two Perforce client commands:
p4 changes
p4 describe
On P4V specifically, this is done under the menu option View->Submitted Changelists (Ctrl+2). This should open a tab for searching. In the Folder/file input field, type a path expression, like this:
//depot/main/app/python/SiteControl/.../*.html
When I run this against my depot, I get a list of changelists. When I click on a changelist, it expands to a list of files. The files matching the pattern *.html are in normal font weight/color, and the non-matching files are "greyed out". Does that make sense?
Similarly, and more specific to your question/usage, you can use a wildcard to say "all files with index at the beginning of their name", as so:
//depot/main/app/python/SiteControl/.../index.*
Now just to compare, run it again but remove the "/index.*" from the path expression. Now what you'll see are all of the submitted changelists under the depot path - not just the ones that contain html files. Additionally, all files will appear in normal font weight/color.
HTH,
-aj

Related

How can I move a folder to another changelist using P4V?

I have accidentally added a few folders to my default changelist that I don't want to submit to the server. How can I move these changes to another changelist, or remove them from the changelist without affecting the files on disk?
I have created a new changelist and moved some individual files / changes to this list but the folder contains many autogenerated files and this will take too long to do file by file.
I also looked at using the "revert" option but I think some of these files may have been previously added to the server in error. Reverting seems like it will change these files on disk to the previous server version.
You can specify the folder path in "Find File".
And use "*" to match all files in the contains filed.
Now you can select all the files in your folder by using "Ctrl+A"
From P4V you can multi-select the files in the pending changes window and then drag them into a new changelist. If they're all in the same directory they'll all be grouped together since it's sorted by depot path.
If you just want to have them not be open but also not modify them on disk, go to the command line and do:
p4 revert -k //depot/path/...
The -k option lets you keep your local files. This isn't available from P4V as far as I know (since it leaves your workspace out of sync with the depot state, it's usually a bad idea).
If you have generated files in your workspace that aren't supposed to go into the depot, you should exclude them from your client's View, e.g.:
View:
//depot/... //myclient/...
-//depot/path_to_generated_files/... //myclient/path_to_generated_files/...
This will essentially "hide" these files from all Perforce operations; you will never be able to add files from this workspace path, and if somebody else adds files to that depot path, you won't sync them down to your workspace. Two notes on this:
If you already have some of these files in the depot and they're currently synced, excluding them from your view and then syncing your client will remove them from your client. You can use sync -k, much like revert -k, to keep your local copies while telling the server that your client is properly up to date.
If you're using streams, you can do this for ALL clients of the stream by adding an Ignored path.

How to ignore taking revision of few files in perforce?

We have few files checked-in in perforce like **#sample.json. Such file names are not supported on Windows, so I get below exception in p4v perforce application when I take revision.
**sample.json: The filename, directory name, or volume label syntax is incorrect.
I do not want these files on my local box. How can I ignore such files in p4v ?
See the section on ASCII expansion in the doc on file specs:
https://www.perforce.com/perforce/r12.1/manuals/cmdref/o.fspecs.html
You can use this syntax to exclude files with asterisks in their names from your client view:
//depot/... //client/...
-//depot/...%2A... //client/...%2A...
If you want to actually sync these files and substitute the invalid characters you can do that too. For example:
//depot/... //client/...
//depot/...%2A%2A... //client/...WTF-WHO-PUTS-A-DOUBLE-ASTERISK-IN-A-SAMPLE-FILENAME...
will cause a file called **sample.json to be synced to your workspace as WTF-WHO-PUTS-A-DOUBLE-ASTERISK-IN-A-SAMPLE-FILENAMEsample.json.
To ignore/disregard certain files and exclude them from your client workspace, put them into your client view with a '-' in front of them.
Something like:
View:
//depot/project/... //my/client/project/...
-//depot/**/*sample.json //my/client/**/*sample.json

Perforce: How do I sync the files in a specific subdirectory to a label

If I issue
p4 sync ...
it only syncs the files in my CWD and below to HEAD.
However, I am trying to sync a single directory to a label name
p4 sync #LABEL_NAME ...
and the result seems to be that the entire workspace (all files tagged with that label) is then sync'ed to that label, as though I had not added the "...".
Is this expected? And if so, how do I achieve what I want?
The #LABEL_NAME is a "revision specification", while the ... is a file pattern; what you want to do is to combine them, and specify both (the files in this directory and any sub-directories, at the revision in which they were tagged in the label).
To do that, you stick the revision specification after the file pattern, with no spaces between them:
p4 sync ...#LABEL_NAME
For more information about the things you can stick after the file pattern to refine your set of files, run:
p4 help revisions

Move all existing changes under a folder to desired changelist in Perforce

If changes for a folder already exist in the default changelist (or other changelists), I want to collect them all in one changelist. How can I accomplish this in perforce, preferably P4V?
From the command line:
p4 reopen -c CHANGE //depot/folder/...
In P4V, select the files and do Actions > Move Files to Another Changelist.
Perforce doesn't understand relative directories, so you have to type the full path name, which I hated doing each time. So I added the command from #sam-stafford's answer as a custom tool to P4V.
To add the command to the Perforce GUI:
To use, you can right click the depot folder and choose "Move all changes under folder to changelist.."
Note: The changelist should be an existing one. I don't know how you would create a new one from the custom tools.

"Actually, Perforce I don't want you tracking that file after all ..." how do I get Perforce to listen?

Sometimes I "Mark for Add" and add files to Perforce which I actually didn't want Perforce to worry about.
Is there a way to revert it so it just goes back to showing in P4V as an "untracked" item?
See my example:
I've added mil.ico and mil3.ico by mistake. I just want them to go back to looking like test.ico, ie. ignored by Perforce:
Even if I save a copy of the files, then delete, then put them back (all of which is a serious bore), P4V still knows they have a history and marks them as shown:
I just want Perforce to leave a file alone when I tell it to.
If you want to remove the last traces of the files from perforce, your only chance is through p4 obliterate. This will irreversibly remove file revisions or even file's complete history from perforce and will only work with administrator privileges. I don't know if obliterate is available through p4v, on the command line you would issue:
cd directory_of_accident
p4 obliterate accidentally_submitted_file
and if it looks like you and perforce agree on the file to forget
p4 obliterate -y accidentally_submitted_file
to seal the issue.
You can delete the items from the Perforce depot. Keep in mind Perforce will want to delete your local copy of that file so you should save it off in a different location, delete the file in Perforce and move the local version back.
Are you looking at your file structure through the Depot tab or the Workspace tab? It looks like it may be your Depot tab.
Try going to your Workspace tab then click on the Filter icon (looks more like a funnel) and ensure that "Show Files Not in Depot" is selected.
Hopefully looking through the Workspace tab, as opposed to Depot, will hide the deleted files, and selecting the appropriate filters will show your non-Perforce files.

Resources