Having trouble deleting client - perforce

I'm getting this error while trying to delete a client named 'test':
Client 'test' has files opened. To delete the client, revert any opened files and delete any pending changes first. An administrator may specify -f to force the delete of another user's client.
I try p4 opened and it shows:
//TestRepo/test/TestA.java#1 - edit default change (ktext)
//TestRepo/test/TestB.java#1 - edit default change (ktext)
How do I delete these files so that I'm able to delete the client?

Run p4 revert //TestRepo/test/TestA.java //TestRepo/test/TestB.java from within the client first.

Related

How can I get revision from other workspace in perforce by command line?

I have a workspace "template" that get some file in local.
I can use gui to create a new workspace, right-click, get revision..., select "template".
Then, the new workspace's local file = template's local file. The file's version is also equal.
How can i use command line do the same thing?
The equivalent of the "get revision" operation you're talking about is to use the client spec template as the revision specifier on a p4 sync:
p4 sync FILE#template
This is commonly used to recreate the state of another client for purposes of recreating a build. The client essentially acts like a label for whatever revisions it has synced. To sync the entire workspace instead of that one specific FILE, simply use p4 sync #template.
Note that this is completely separate from the concept of using the client spec as a "template" for the View of a new client:
p4 client -t template
This will create a new client spec that copies its View from the template client, but the specific set of revisions it's synced to (commonly called the "have list", i.e. the set of revisions referenced by #have within that client and by #client from any other context) is not in any way bound to the template client (unless a ChangeView is used, but that's a whole other thing).
Since these are separate operations it is not necessary to do one in order to do the other.

How to "unsync" files from perforce client?

I have files in my perforce client which I no longer need.
Is there a way to remove the files from my client to free up the space?
I don't want to delete the client and create a new one.
Thanks in advance.
You can sync to any revision, including #none. To temporarily remove a directory (e.g. the current directory, ...) from your client just do:
p4 sync ...#none
If you want to more permanently remove the directory from your client (so it won't come back even if you re-sync your entire workspace), remove it from your client's View:
View:
//depot/... //my-client/...
-//depot/some_directory/... //my-client/some_directory/...

WinSCP - ignore single directory during sync

I have a directory on a server that needs to synchronize its contents to a client. It is set to delete files on the client that have also been deleted from the directory that is to be synced from the server.
I want to ignore a specific directory, so it does not delete its contents on the client.
The following script (located on the client) currently deletes the contents located in /files/synced/oss/test/ but I want that directory to keep its contents on the client.
option exclude "Thumbs.db; /files/synced/oss/test/"
synchronize local -delete "D:\files" "/files/synced"
If I understand your question correctly, you do not want to exclude a remote folder /files/synced/oss/test/.
You want to exclude a local folder D:\files\oss\test\.
Also note that the option exclude has been deprecated, use -filemask switch instead.
synchronize local -delete -filemask="| Thumbs.db; D:\files\oss\test\" "D:\files" "/files/synced"

perforce depot converted to streams; can't delete old files from non-stream client

I have a depot that was initially set up as a non-stream depot. We added some files while sorting out folder structure. The depot was subsequently converted to a streams depot, and I want to remove the old files.
Unfortunately those original files do not appear under any stream, so I can't delete them from a stream-based client.
I do have a non-stream client left from initial testing, and I can open the offending files for delete, but I can't submit them:
//depot/myworkspace/main/foo.txt - warning: cannot submit from non-stream client
Is there any client-side way to delete the files? (Note that I am not an administrator on the server -- contacting the admin will be my next step.)

How to set defaults for perforce client specs

I'm trying to discover how to change the default set of Client Spec options and submit-options.
set P4CLIENT=my_new_client_1
p4 client
Gives me the following spec default-spec:
Client: my_new_client_1
...
Options: noallwrite noclobber nocompress unlocked nomodtime normdir
SubmitOptions: submitunchanged
...
Now on my machine i want to always use revertunchanged, rmdir for example, but it seems like I need remember to manually set this everytime I create a new client.
Is there any way to achieve this? p4 set seems to only affect the things that can be set by environment variables.
You can't change the default client spec template (unless you're the Perforce system administrator) but you can set up and use your own template. You would first create a dummy client with a client spec that has the values that you want:
Client: my_template_client
...
Options: noallwrite noclobber nocompress unlocked nomodtime rmdir
SubmitOptions: revertunchanged
...
Then you just specify that the dummy client should be used as a template when creating new clients:
p4 client -t my_template_client my_new_client_1
The first response here was incorrect:
You CAN create a default clientspec in Perforce using triggers.
Essentially, you create a script that runs on the server and runs whenever someone does a form-out on the form client. This script would have to check to see if the clientspec already exists, and then substitute a sensible "default" if it doesn't (if it's a new clientspec).
Note that this works fine and well, and it's even in the P4 SysAdmin Guide (the exact example you're looking for is there!) but it can be a bit difficult to debug, as triggers run on the SERVER, not on the client!
Manual:
http://www.perforce.com/perforce/r10.1/manuals/p4sag/06_scripting.html
Specific Case Example:
http://www.perforce.com/perforce/r10.1/manuals/p4sag/06_scripting.html#1057213
The Perforce Server Deployment Package (SDP), a reference implementation with best practices for operating a Perforce Helix Core server, includes sample triggers for exactly this purpose. See:
SetWsOptions.py - https://swarm.workshop.perforce.com/projects/perforce-software-sdp/files/main/Server/Unix/p4/common/bin/triggers/SetWsOptions.py
SetWsOptionsAndView.py - https://swarm.workshop.perforce.com/projects/perforce-software-sdp/files/main/Server/Unix/p4/common/bin/triggers/SetWsOptionsAndView.py
Using the p4 client -t <template_client> is useful and is something a regular user can do, and has a P4V (graphical user interface) equivalent as well. Only Perforce super users can mess with triggers.
There is one other trick for a super user to be aware of: They can designate a client spec to be used as a default if the user doesn't specify one with -t <template_client>. That can be done by setting the configurable template.client. See: https://www.perforce.com/manuals/cmdref/Content/CmdRef/configurables.configurables.html#template.client
One other suggestion: I suggest changing the default from submitunchanged to leaveunchanged rather than revertunchanged (as in the sample triggers above). Using leaveunchanged is better because, if you still want the file checked out, using leaveunchanged rather than revertunchanged saves you from having to navigate to the file to check it out again. It's a small thing, but optimal to go with leaveunchanged. If you do want to revert the unmodified file, it's slightly easier to revert than to checkout again, which might require more navigating or typing.

Resources