I am new to Perforce. Could you add a new folder under the branch in the depot? I also tried to add one in my workplace but how could I get it to the depot? Do I have to do a merge/integrate or something?
Thanks.
p4 add doesn't support recursive add .
Here's a unix shell work-around to run from within the root folder you want to add:
find . -type f -print | p4 -x - add
If your server version is 2012.1 or later, you can use the reconcile command to do this, with full wildcard support:
p4 reconcile //depot/path/to/folder/...
From your local workspace, create your folder and a file you want to go inside it. Then either mark it as add from the visual client, or go into the folder from the command line, and type...
p4 add ./new_folder/new_file_name.ext
When you submit, the new file and folder will be in your repository. This assumes that new_folder is a subfolder of your existing workspace. Please let me know if it isn't and I'll update my answer.
Above command will add files under default changelist. And later if you want to see the if files are really added in default changelist
p4 opened
And for the submission of opened files, under the default changelist, to depot
p4 submit
Use command
p4 add directory_to_be_added/...
This will recursively add all contents starting drom "directory_to_be_added"
To add files from a directory in perforce
p4 reconcile -f -c [changeList] -a <dir_path_to add>
I had a situation that I need to add entire folder with files having wildcard name, so had to do it through command line using -f (force), I used "dir /b /s /a-d | p4 -x - add -f"
If you are using p4v to add a folder recursively, you need to click on:
"Connection" -> "Edit Current Workspace"
then manually add the mapping of the new folder to your depot.
Then go to your "Workspace" view and right click on the root folder, click "Mark for Add" and comment. All the files under it should show up in the new pending change list.
Related
I'm trying to understand how perorce work and I'm struggling with command line
I have a single depot with 3 project inside
so depot:
projectA
projectB
now I have 2 workspaces, one mapped only on projectA and one on projectB.
Here I have my trouble , using interface everything works
but with command line I have not enough knoledge on perforce.
I use
p4 -c workspacA //to switch workspace
then I run: p4 cstat
and it give me all the information about changelist contained in all depot
not only depot/projectA
But I woul like to enter in a workspace and run my command only on that workspace
Is this normal? I see that I need to specify my depot mapping but this seems strange to me.
Can someone clarify me this?
Thanks
Do:
p4 set P4CLIENT=workspaceA
If you use -c workspaceA it applies only to that one command, whereas p4 set is persistent.
I also recommend looking at documentation on P4CONFIG, which lets you associate Perforce config settings with local directories (so you switch workspaces automatically when you cd to a different workspace root).
https://www.perforce.com/manuals/v16.2/cmdref/P4CONFIG.html
I am trying to setup perforce. I installed p4v and setup workspace.
Then I ran
C:\"Program Files"\Perforce\p4 -p perforce-test:1500 -u test-user -c test-user_test sync //test-folder/test/
But I get error //test-folder/test/ no such files(s)
I can see files and folder exist in p4v depo.
Use the path:
//test-folder/test/...
Directories aren't objects in Perforce, they're just part of the file name -- so you don't sync a directory called "//test-folder/test/", you sync all the files whose paths match the pattern "//test-folder/test/...".
Use the “...” in the end
e.g.
Wrong : p4 sync //test-folder/test/
Right : p4 sync //test-folder/test/...
find . -type f -print | p4 -x - add
This adds all files from $PWD and its sub directories, but it prints the message can't add existing file for files already in perforce.
How do I add only new files which are not in P4?
For Perforce versions 12.1 and above, you can use the command p4 reconcile, which will reconcile any added, deleted, or edited files outside of Perforce. To use it specifically to add files, type p4 reconcile -a.
Just a note though, it doesn't do any harm to do the command you are doing. It issues a warning for any files already existing, but that's it. It will still add the files that don't currently exist in Perforce. Your command is the way I have done it until the p4 reconcile command was created.
I'm new to Perforce and, to be honest, I'm hating it.
I had about 20 files in my c:\workspaces\perforce directory and I selected all of them and hit the delete key.
They were all checked in before I deleted them.
I've been pulling my hair out trying to figure out how to get them back (Perforce is sooooo unintuitive) but there's nothing that stands out to a n00b like me to.
How can I get the latest revisions back into the directory from Perforce?
You need to do a force sync.
On the command line:
$> p4 sync -f
In the P4V GUI:
Right-click on the directory to update
Select 'Get Revision'
In the dialog, check 'Force operation'
Click 'Get Revision'
The perforce server keeps track of which files you pulled in last time. This is done so that, the next sync only brings in the files which have changes since the last sync, instead of all the files once again.
To override this behavior, you need to use the -f option.
The -f flag forces resynchronization even if the client already has
the file, and overwriting any writable files. This flag doesn't
affect open files.
If you're using the command line client, you can run this command from the directory where you want to sync up:
p4 sync -f ...
You might also want to check the list of opened files, since sync -f will not be bringing in changes corresponding to those files (even if you have deleted them).
This command should list all the opened files:
p4 opened ...
If you have any files listed in the above list, which you had deleted as well, you should revert them before running sync -f.
p4 revert <FILE1> <FILE2>
p4 sync -f ...
If you're using p4v, you could follow the steps mentioned by dwinkle:
1. Right click the folder in your workspace
2. Choose `Get Revision` in the context menu.
3. Choose `Get Latest revision`
4. Check `Force Operation (replace file even if you already have the revision specified)
5. Click on `Get Revision` button to fetch the files.
To look at the list of opened files using p4v, you would have to look at your list of pending changelists. You should be looking in the default changelist, if you have not put the files in any speficic changelist. Right click on files that you see there that you had deleted earlier, and choose Revert.
if you have files checked out, and then deleted. You need to revert(p4 revert -a //...) the folder before you get latest forced (p4 sync -f).
An alternative:
p4 reconcile
p4 revert //...
If you don't care about the old client, one solution would be to pull down a new client:
p4 newclient
p4 sync
If you want the client to have the same name, you can do a forced sync as others have mentioned:
p4 sync -f
If you want the client to have the same name, but your directory is no longer recognized as a p4 workspace, you will need to delete the client and then recreate it.
p4 -c <client_name> client -d <client_name>
p4 newclient
Right click on parent directory.
Click "Reconcile" in context menu.
Let a new change list be created.
Right click changelist.
Revert change.
In my case I tried everything and I couldn't get all of my files to revert, so I tried deleting them and then I couldn't get all of them back. I restarted my pc, and tried numerous solutions found online. In the end my problem was solved by one or all of the following: upgrading to the latest P4V application, running the application with elevated permissions, and going to lunch after forcing get latest.
If you wasted half of a day. You may want to try the above.
I've deleted all the files in my directory. How can I get them back?
One wrinkle to this that I just stumbled over is that if you remove the directory you can't just use p4 sync -f to get it back. I wanted a complete clean version of the directory so I did a:
rm -rf directory1
However when I did a p4 sync -f directory1 on it, it spits out:
directory1 - no such file(s).
What I found that works is to recover a file inside of the directory first:
p4 sync -f directory1/some-file
You will have to know the name of one of the files inside of the missing directory which you can get using:
p4 files //depot/some/path/directory1/\*
Once you get one of the filenames, do:
p4 sync -f directory1/some-file
This should create the directory1 directory. Then you can do a full sync inside of the created directory:
cd directory1
p4 sync -f ...
Hope this helps someone else.
I am trying to get the last checkin on a particular folder structure on perforce, I know "p4 changes -m1 'filepath" does the job, but the problem is the filepath has to be the depot file-path. What I have on the other hand is the local filepath something like "C:\Android\Version10.2\MyApp\" and not "//depot/Andoid/Version10.2/MyApp".
I tried using commands like "p4 fstat", "p4 where" and "p4 files", but for all of them it works fine with the depot file path, if I give the local file path, it keeps complaining file(s) not on client/no such file(s).
The other issue is I dont have rights to change the p4client on the machine. How do I get this to work?
Basic question then to sum up is being able to get the last change on a folder/file for which I have the local filepath.
Regards
If you're going to run any commands on files those files have to be in the workspace. The problem is probably that p4 on Windows defaults to the machine name as the workspace name if you don't supply one.
So you either have to run set P4CLIENT=<clientname> then run p4 changes -m1 <filename>,
or p4 -c <clientname> changes -m1 <filepath> where <filepath> can be the file on your local file system, so C:\Android\Version10.2\MyApp\ would be acceptable.
Does p4 filelog -m 1 <filename> give you what you want? You can add the -l (lowercase L, not one) switch to get more information.
If you have a local file (as opposed to the depot-path), then you also should have a client-spec. You need to specify this with the -c option:
p4 -c <name-of-client-spec> changes -m1 <filepath>