p4 submit without submitting out-of-date files - perforce

I want to use p4 submit command to submit a specific changelist, but unlike the GUI submit form, with command line you can submit even out-of-date files.
For example, the latest file revision is #10.
I sync revision #5, modify the file and then I'm able to submit with p4 submit command.
Is there a way to avoid it? In other words, is there a way to achieve the same behavior as with GUI?

Related

How to recover a previous file version in perforce branch?

I have deleted a file from a perforce branch and I am trying to recover it. I thought of syncing to its previous version and resubmitting it. Is it the better way to do and how?
P.S: Using command line
You've got it.
p4 sync file#version
p4 add file
p4 submit
Another option (only available with server versions after ~2013):
p4 copy file#version file
p4 submit
Another other option (only available with server versions after ~2016):
p4 undo file#head
p4 submit
Any of these ways you do it, the history will record that the new version came from the older one (you'll see "file#4 add from file#2" or something along those lines), and that will do things like connect up the history in Revision Graph and allow merge operations to find a common base.

How do I make the same change to multiple branches in perforce

If I do
p4 integrate foo/file bar/file
p4 submit
and then want to make substantially the same change to both copies in a single submit, is there a better way than just p4 editing both of them and doing the submit?
Making edits directly to both files is the wrong way to do it.
Running the p4 integrate command is letting perforce know that there should be a relationship between the files.
You should edit just one of the files, submit it, then you should do another integrate/merge/resolve.

Is there a way to bring up the regular P4V submit window from a custom tool script?

I need to run a very brief batch script before submitting the selected changelist - instead of then submitting the changelist through p4 submit, I'd like to just bring up the regular submit window that is used when submitting via P4V. Is there any way to do this from the custom tool batch script?
In later versions of the p4v client Perforce shipped a command line utility to do exactly what you're looking for, p4vc
I think it was added in 2012.1 or thereabouts (not at work so can't check)
Off the top of my head the command line would be p4vc submit -c changelist to bring up the p4v submit dialog.

re-submit changelist with new changelist number

I have submitted one file in perforce, and changes submitted by other user got reverted in merge.
Changes were not conflicting.
Is their a way, I can get that user's changes back. Means revert the revert.
Also how to submit a changelist again with new changelist number?
In order to revert a file (fall back to its previous version) you simply sync the previous version and submit that again.
For a single file the procedure goes like this:
# sync file at old revision (#3 in this example)
p4 sync //depot/file#3
# mark the file for edit
p4 edit //depot/file
# make perforce aware that something has to be merged
p4 sync //depot/file
# resolve (i.e. throw away the head revision changes and save those from #3)
p4 resolve -ay
p4 submit
If you have a changelist with several files (and not only edits, but also deletes & adds) the rollback is a bit more difficult.
See also this question.
Here's a smart script for that purpose and more info.
The 2nd part of your question I did not understand.
Submitting a change again with a new changelist number doesn't make sense, since a changelist contains diffs. If it was submitted once, then the diffs are already in the depot, so you can't submit the same diffs again.

Perforce - submit only files open for branch, not files open for edit

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.

Resources