How to map depot path to a different client path? - perforce

Quick question: My Perforce depot path looks like
//depot/systems/live/myApp/src
I want to map it to my client directory as
/myApp/src
But I always get the full path as it is in the depot. Is there a way to accomplish what I'm looking for?

Map the depot path to where you want it to be relative to your client root:
Client: myClientName
Root: /myApp
View:
//depot/systems/live/myApp/... //myClientName/...
The //myClientName part of the mapping corresponds directly to the Root of the client. If you specify the full depot path on the left side of the map, and the bare client root on the right side of the map, then everything from that specific depot folder goes directly into your root without copying the actual depot path.
(Doing this in P4V might require using some tricky "Advanced" tab in the workspace editor -- I have never had good luck with editing my client view via P4V, because it seems to want to add stuff to the client view that I don't want, so I always use the command line. YMMV.)

Related

What does not located within the filtered view of the tree mean?

I'm trying to Download a file with Get Revision... and Force Operation on Perforce. The log says that the operation was completed.
p4 sync -f /Folder/.yarnrc#head
1 file updated
But when I switch to the Workspace tree I get the error:
The folder /Folder/.yarnrc is not located within the filtered view of the tree.
The workspace mappings are the same I've used on three other machines and they were fine.
Other sibling files (files inside /Folder) were downloaded correctly
Looks like this is happening only with files that begin their name with a dot.
The "filtered view of the tree" is a P4V thing, not a general Perforce thing (i.e. it's not the same as the View in your client spec). If you look for a little funnel icon on the taskbar that's where the filters are set for the workspace pane -- maybe something is set there that excludes this file? Like a setting to exclude "hidden" files?

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 p4ignore with P4v

Does anyone know how to ignore files and/or directories with P4V? I added p4ignore by p4 command line, but P4V does not pickup that.
Thank you in advance for your help.
P4V does work with p4ignore...to a point.
In your workspace view, you will still see the local files that would be "ignored" by the ignore file. The reasoning behind this is multifold, but the main reason is that to show a local view, P4V stats the local directories, and there's no good way other than to constantly check with p4ignore files (and that involves walking the directory tree on up to the workspace root) every time it looks at the tree. Ends up being terribly inefficient.
However, P4V still respects the p4ignore file, and if you attempt to add any file that would be ignored, it properly gives you an error message (with the ability to silently ignore the files as well if you want).

List changes in a directory using perforce

New to perforce (and stackoverflow). I'm trying determine what has changed in my local view: I want to list all the recent changes under a directory in my workspace.
Perforce documentation seems to suggest everything is file based. Is there not a simple solution that does not require either probing each file individually and recursively down the directory tree, or filtering and processing changelists (multiple projects are sharing the same depot in my case)?
Ideally, I'm looking for the SVN equivalent of "svn log -v" (i.e., no path specification).
I'm also looking for a command-line solution.
Take a look at p4 changes and the documentation.
There are some examples, which might already help you. Moreover there are some global options, which you can use to specify the client, port, etc.
You are probably looking for something like
p4 changes -m 5 -s submitted //depot/project/..., which return the last 5 submitted changelists under the given depot path.
To see the last N changes under a particular workspace directory, do:
p4 changes -m N path/...
Note that path/... can be a relative local path, an absolute local path, or an absolute depot path. This is true for almost any Perforce command that accepts a file argument -- if you can specify one file you can usually specify an arbitrary pattern like "foldername/...", and you can usually specify it in either local or depot syntax.

Get the workspace location of files from Perforce

When I am running p4 files ... and p4 dirs ... all the returned values have paths relative to the depot root folder. Is there a command that has the same functionality as files and dirs that returns the actual workspace path?
Given a path you can get the workspace path in a couple of different ways (that have subtle differences):
Run p4 where //depot/path/... to see the view mapping for the depot path, i.e. where the client view says this depot path maps.
Run p4 have //depot/path/... to see where the depot files are synced, i.e. where they are physically located on the client. If the files are not synced this will show you nothing (even if the files are mapped), and if the files are synced but the view mapping has changed in the meantime it will show where they were synced according to the old mapping, not where they should be according to the new mapping (i.e. what p4 where will show you).
When you're looking at an entire directory, either of these may yield a one-to-many answer, since different subpaths within a depot directory may map to different client directories. Since there isn't a one-to-one relationship there isn't a p4 dirs-style equivalent that will give you a path like //client/dir; everything will be at the file level or at the mapping (i.e. //depot/dir/... -> //client/dir/...) level.
Note that most commands (including p4 have and p4 where) will accept local paths as well as depot paths, so you can run e.g. p4 have ... to see all files that you've synced under the current directory (and its output will include the depot path as well as the client path).

Resources