How to ignore taking revision of few files in perforce? - 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

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.

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

p4 sync, how do you exclude files while using wildcards?

I'm trying to use p4 sync to sync a specific directory to a given changelist number using wildcards but I also want to exclude a list of files that are under that directory (in subdirectories), I tried using - (both before and after using a path with wildcards) but the file never gets excluded, this the command I'm trying:
p4 sync //Repo/Foo/... -//Repo/Foo/Bar/Foobar.txt
The file exclusion seems to only work when the files/directories you are syncing don't match the files you're trying to exclude.
In your client, you would have multiple lines:
//Repo/Foo/... //my_client/Repo/Foo/...
-//Repo/Foo/subdirectory/... //my_client/Repo/Foo/subdirectory/...
This would allow you to get everything in the Foo directory and all subdirectories except "subdirectory".
You can do this if you use a label. Create a label in your favorite editor (p4v or command line p4 label and add your two lines:
//Repo/Foo/...
-//Repo/Foo/Bar/Foobar.txt
In the revision field put "#head" (including quotes!) if you want the latest or a change list number. Give the label a name - for instance "sync_butnot_foobar"
On the command line you can now sync:
p4 sync #sync_butnot_foobar,#sync_butnot_foobar
This has a huge benefit over the modify your client spec and sync head model. If you exclude a file in your client spec, the next time you sync that file will be brought to revision 0 which probably isn't what you wanted.
In short, you can't exclude files on a sync. That can only be done within the client spec. (Well, it could be done through the protections table, but that is really a different matter I think).
But if you want to sync a specific folder and only the files in that folder, use *
p4 sync //Repo/Foo/*
will get you only the files in the Foo folder.

Is it possible to use RCS Revision keyword for a depot path?

I've managed to use the $Revision$ RCS keyword in Perforce: when I update my file
//depot/dev_projects/main/src/include/version.h it will update my define in the file, nicely:
#define VCS_VERSION "$Revision: #4 $"
That includes the revision for the version.h file.
What I really need is to embed the revision for the folder of my project //depot/dev_projects/main/src/ to the version.h file. So if someone submits a file for example to //depot/dev_projects/main/doc/readme.txt, I would like to see #define VCS_REVISION "$Revision: #5 $" in version.h after I gets the latest revision from depot.
Is there a way to do that?
You have two cases to worry about: exiting files and new files. For existing files (and I'm going to assume you are talking about c/cpp files), you can simply 'p4 reopen' the files with the filetype 'text+k' and then submit those files:
p4 reopen -t text+k //groovy_project/src/....cpp
This would reopen all of the .cpp files in the //groovy_project/src location and make them 'text+k' (the +k means RCS keyword expansion, but I guess you know that since you have keyword expansion working).
For new files, you should use the 'p4 typemap' command. 'p4 typemap' will bring up the typemap in your editor. This form contains a mapping of files to filetypes for new files added to the depot. These are the default filetypes that new files will receive (unless a new file added explicitly uses a different filetype when the file is added). For instance, if you have
TypeMap:
text+k //groovy_project/src/....cpp
in your typemap, all new .cpp files in the //groovy_project/src folder will get the text+k filetype, allowing for keyword expansion.
Note, if you explicitly give a new file a different type than what is found in the typemap, the explicitly specified type is used. Say you had the typemap above. The command:
p4 add -t text ~/projects/groovy_project/src/newfile.cpp
this file would get added to the depot as text, and not text+k.
I hope that this information helps.
EDIT:
After reading the edits to your original question, the short answer is no, you cannot add a revision for a folder. The slightly longer answer is that Perforce doesn't really know about folders/directories. It just knows about files (and therefore the path to the file). Directories are not really individual objects in the database in a way that would make what you want work.
I think you want the $File$ keyword:
http://kb.perforce.com/article/54/using-rcs-keywords

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

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

Resources