Is there a way to submit all open files to Perforce without an editor opening?
If I do
p4 submit
an editor will open with all the open files already added. That works but I don't want an editor popping up.
If I do
p4 submit -i
I need to provide the entire changeset, including the names of all the open files. That works but I don't want to provide the names of all the files.
I just want to submit all the open files without having to supply the list of them and without an interactive editor popping up.
You can do this with:
p4 submit -d <description>
Related
If I want to create a checkpoint in my work, I often find myself submitting a chunk of files, only to re-open the same files again and continue working on them. Repeat this for several sets of files, many times over. Has anyone had to automate this? I am looking for a custom tool in p4win, or an autohotkey script tied to a hotkey.
p4win is rather out-dated. p4v has an option to reopen files after you submit them: "Check out submitted files after submit"
With Perforce, I have the following situation:
Created a new file foo.txt in client client_a, opened it for add
Shelved foo.txt in client_a, unshelved it in client_b
Now foo.txt is open for add in client_b
Submit foo.txt in client_a
Now my question concerns how I can cleanup foo.txt in client_b. Maybe it has a one line change from the depot version that I'd like to keep. Ideally I'd like to do a resolve operation against the newly checked in file, but I'm not allowed to do this because it's open for add.
Now I have this file foo.txt#1 - add change default in my client.
I can't reopen the file ('nothing changed'), I can't diff it vs the depot ('file not open for edit'), I can't resolve it against the depot ('no files to resolve'), I can't open it for edit ('can't edit, already opened for add').
Is there any way to make perforce reopen this as edit instead of add? I know I can copy it to a temp file, revert, reopen for add, and then recopy the temp file back over, but this seems rather unelegant. Is there any command that can do what I want, or is there a good reason I'm not seeing why it's disallowed?
Only slightly more elegant than the comment in your last paragraph, but you should be able to:
Revert foo.txt in client_b. Since it was marked for add the file will remain on the disk with no changes
Sync foo.txt with -k. This makes the server think you have the latest revision without modifying your local file.
Check out foo.txt for edit. Diff'ing against the have revision should show the changes.
Submit your changes.
Here's a frequent situation: You have about thirty files checked out into a specific pending change-list. After working on those files, and before submitting them, you needed to move them to a folder (external to deposits, so a simple "Integrate" wouldn't be suitable).
Using the "Show In - Explorer" option, you'll get a lot of window popped-up. And that's just painful (and sometimes, the system just cannot open all of them).
So, question is, is there a simple way to copy-paste multiple files from a change-list without doing it individually?
You can do this with a custom tool.
In P4V, open the custom tools manager via the Tools->Manage Custom Tools... menu item
Click New->Tool... to open the Add Custom Tool dialog and enter these parameters (xcopy isn't the ideal app for this, but I'll talk about that later1)
alt text http://img202.imageshack.us/img202/6678/p4editcustomtool.png
Now you will be able to select all the files in your change list, right click on them, and a new item will be available in the context menu Copy selected files to another location..."
alt text http://img97.imageshack.us/img97/4003/p4vcustomtoolincontextm.png
An input box will appear, asking you where you wish to copy the files.
alt text http://img132.imageshack.us/img132/7612/p4locationprompt.png
Click OK and the files will be copied to the location you entered in the input dialog. Maybe...
1There are some problems with xcopy:
the target directory must already exist
it doesn't seem to work if the path contains spaces
if the process fails, you're process list will fill up with a bunch of instances of xcopy.exe that are stuck trying to do who knows what
the custom tool will no longer work if the previous condition occurs
I tried robocopy also, which would be perfect if there was a way to pass it the source directory, but P4V custom tool editor doesn't provide the parent directory as a parameter. Ideally, you should write your own file copy utility, if this is really important to you. It wouldn't require that much effort.
Lastly, the P4V custom tool editor offers a file browser, but not a folder browser, and the latter is what you really need for a tool such as this.
So, play around with the custom tool thing. You might be able to come up with an answer to your problem.
I know you want to do these things outside of Perforce, but the best I can think of is if you create another workspace specifically for exporting files. You can sync your Perforce workspace to contain only the files in a particular changelist.
In this workspace, try giving the files in your changelist, after it is submitted, a particular label. If you sync your workspace to this label, it will delete every file that does not have this label based on this Perforce page. (do Find for label in that page)
p4 sync #label_name
This involves Perforce, but it does provide a way to get only the files you want.
I believe you can also accomplish this only using changelist numbers, but it may be more complicated. I'm not 100% sure this works
p4 sync #none
p4 sync #changelist,#changelist
I think this will sync files only in this changelist.
Quite often when I'm working in a branch in Perforce, I realise I need a file I didn't branch when I initially branched.
So, I add the file to my client, run p4 integrate -b branchname, then p4 submit.
Thing that bugs me is that I then need to go through the list of files for submit, and remove all entries that are open for edit.
I can't see any option in p4 help submit, but it seems like this might be a reasonably common use case.
First do
p4 submit
Assuming your p4 editor is vi,
type this command in command mode
g/#.*edit\|#.*add\|#.*delete/d
You can choice to submit a single file on the command-line.
p4 submit <filename>
Then it won't bug you about the other files.
If you have more than one file, then maybe you should move all of the files you are currently editing onto an numbered changelist, or branch onto a numbered changelist, which will provide the separation you want.
If you're going to do this, it's much easier to manage numbered changelists from one of the GUIs.
How do I get a list of the files checked out by users (including the usernames) using P4V or P4?
I want to provide a depot location and see a list of any files under that location (including sub folders) that are checked out.
From the command line:
p4 opened -a //depot/Your/Location/...
The ... indicates that sub folders should be included.
Seeing as you also asked about P4V and only had command line answers so far, here's what you do for P4V. The "Pending" pane gets you part way to what you want. Ensure the "User" and "Workspace" filters are cleared, and you'll get a list of all files grouped by changelist and client spec. Not as clean as the straight list of files you get when using the P4 command line as suggested by Iain and Mark, but may help in some situations.
An alternative is to create a custom menu in P4V that uses one of the command line solutions suggested. For example:
Tools->Manage Custom Tools
New
Call it something e.g. Open files by user
Check the "Add to applicable context menus"
In Application field, browse to p4.exe
In Arguments, type opened -a %D (the latter takes the currently selected depot path)
Check the box to run in a console.
I'm sure you could fancy this up a bit if needed to filter the output.
You can also restrict the output of p4 opened like so:
p4 opened -C <client-spec> //depot/...
to get a list of files opened on that client-spec
p4 opened //depot/...
will give you a list of files opened by the current P4USER
In case you want to search for a particular user:
p4 opened -u the_user_name
In case you want to search for particular Changelist:
p4 opened -u the_user_name -c cl_number
I just want to point out something about about the command line arguments.
It is important to add the "/..." after the folder you want to look over because it will tell perforce to do it recursively.
So, I was trying this at the beginning :
p4 opened -a //myP4Path/dev_project
Which wasn't working until I did this:
p4 opened -a //myP4Path/dev_project/...
In p4v : try to do a rename of the top directory. You will get a warning and list of the currently checked out files with user names.