How to reopen all files under default change to another specific change? - perforce

I have lots of files opened in perforce.
Some of them are under a specific change.
All other files are under default change.
How do I reopen all files under default change to that specific change?

If you just want all the files to be open under specific change 1234:
p4 reopen -c 1234 //...
In the situation you describe, this will work fine since all of your files that aren't open in the default change are already open under 1234.
If you have multiple numbered changelists and you want only the files in the default change to be reopened under change 1234:
p4 -F %depotFile% opened -c default | p4 -x - reopen -c 1234

Related

Perforce :Not able to create new changeList with Description

Not able to create new changeList for a file/files with Description
p4 --field Files=E:\MyFolder\run.py --field Description=Test change -o | p4 change -i
Shows error
Error in change specification.
Can't include file(s) not already opened.
Open new files with p4 add, p4 edit, etc.
Cant do it in single command, wanted automate.
Like the error says, you can't include files that aren't already open. To create an empty changelist, do:
p4 --field Description=Test change -o | p4 change -i
If you want to open the file for edit and submit it, you don't need to create a changelist explicitly. Just do:
p4 edit E:\MyFolder\run.py
(make changes?)
p4 submit -d Test
If you want to create a changelist that contains that file, you can take advantage of the fact that a newly created changelist will by default take ownership of files in the default changelist:
p4 edit E:\MyFolder\run.py
p4 --field Description=Test change -o | p4 change -i
If you have an empty changelist and files open in another changelist, you can move them over with the "reopen" command:
p4 reopen -c CHANGE E:\MyFolder\run.py
Note that this requires you to know the actual change number (CHANGE).
Finally, IFF the file is already open in the default changelist and you want to make a new changelist that contains that file and only that file, you can do this by specifying the file's depot path in the Files field of the changelist:
p4 --field Description=Test --field Files=//depot/run.py change -o | p4 change -i
A changelist description's Files field must contain the fully qualified depot path of each file, and it's only valid to include files there that are already open.
If you don't know the depot path of the open file, you can get it by running a command like p4 opened, which will list all open files by their depot paths.

In perforce, how can I reopen all elements of a CL into the default CL ?

Server version: P4D/LINUX26X86_64/2013.2/938876 (2014/09/23)
Hi:
Let's say I have a pending changelist 123 which has these 2 files...
... //foo/somewhere/abc.txt#100 edit
... //foo/somewherelse/def/txt#67 edit
I want to put both of these in the default CL. I know I can
"p4 reopen -c default //foo/somewhere/abc.txt"
and then
"p4" reopen -c default //foo/somewherelse/def.txt"
But is there a way to specify all the files in CL 123 regardless of the paths (do both reopens with one command)?
My actual situation involves a shelvelist. I want to put the changes in a shelvelist back in the default CL then delete the shelvelist AND the changelist that results after one deletes a shelve. Basically I want to undo the shelve operation. My method of doing this is...
1) delete the shelve
2) p4 describe the changelist
3) p4 reopen -c default each file, one at a time
4) delete the empty changelist
If there's a shortcut to do that, I'm all ears (eyes, whatever) !
But I would still like to learn how to do what I originally asked.
BTW, I do NOT have admin privs :-}
Thanks !
For the specific case of undoing a shelve operation and putting the shelf's contents back into the default changelist you could use p4 revert followed by p4 unshelve.
For the general case, if you just want to reopen everything in the default changelist you could do:
p4 reopen -c default //...
If you have a bunch of changelists and you want to just move the files from change 123 into the default changelist that'd be more like:
p4 -F %depotFile% opened -c 123 | p4 -x - reopen -c default

Perforce: How to move unresolved files to a separate CL

I'm currently (and regularly) performing very large integrations (usually 50k+ files). In P4V, it is technically possible to display and manually work with those files, but it's slow and unwieldy.
Is there some way to move unresolved files to a separate CL without needing to write an application? I was taking a look at "p4 resolve -n" but I can't figure out how to use that output with p4 reopen (assuming this is even the best way of doing what I want.)
Any help would be appreciated.
You can use this:
p4 -F %localPath% resolve -n | p4 -x - reopen -c default
Explanation:
-F %localPath%: tells p4 to output paths in local format
resolve -n: means "list unresolved files without actually resolving them". (P4 Resolve)
-x -: Tells p4 we'll be working on a list of files, and '-' means that the list of files is coming from stdin (piped) (p4 Global options)
reopen -c default: reopen incoming specified files in given changelist ("default" can be replaced by an existing changelist number). (p4 reopen)
Update:
For very big changelists, sometimes the command gets stuck. You can do it in 2 steps to workaround the problem:
p4 -F %localPath% resolve –n > c:\p4_output.txt 2>c:\p4_errors.txt
p4 -x - reopen -c default < c:\p4_output.txt
Note: When reopening files that were moved, p4 reopen will only move "half" of the change (the add) and leave the delete in the previous changelist. I haven't found a solution other than moving those manually.
Something like:
p4 -F %localFile% resolve -n | p4 -x - reopen -c CHANGE
ought to do it. (Run "p4 -e resolve -n" to see the list of available variables in the output, I think localFile is the one you want.)
I had a similar problem sometime ago.
To move a Perforce changelist to another computer/workspace,
follow the steps given in the below link:
movng unresolved files/changelists

Is it possible to get a list of files opened for add by any user, given a directory?

I need to see what users are adding new files in a certain directory depot. Is it possible to do see the users and what they've named their files using p4 opened?
I've tried
p4 opened -a //depot/MMA/interfaces/STAMP/branches/v16.1/src/testCfg/bundles/...
but it appears the command doesn't interpret the ... as other commands do; probably expecting files only.
p4 opened -a //<DepotName>/... works for me. I can also specify multiple directories:
bash-3.2$ p4 opened -a //guest/jen_bottom/...
//guest/jen_bottom/P4RubyGem/install.rb#10 - edit change 10688 (text) by jen_bottom#jen_bottom_ws
//guest/jen_bottom/P4RubyGem/install.rb#10 - edit change 10216 (text) by jen_bottom#jen_bottom_ws_home
I have found the following bug in the release notes, which may perhaps explain why 'p4 opened is not behaving as expected:
(#72994) **
Certain 'p4 opened' commands could potentially return incorrect
results on a server with db.peeking set to 2 or higher.
Hope this helps,
Jen.

Perforce: How can I delete a changelist that p4v refuses to delete?

After a while of working with perforce I was left with a lot of still open change lists.
To clean up I want to get rid of a subset of them.
So here is what makes this complicate:
For a subset of the changes the host of the client has changed.
Some changes contain shelved files.
Files from the change list may be deleted or moved.
When one or more of above points are true for a change list, p4v (the visual client) will not allow you to delete the change list.
So what is an effective way of deleting these change lists?
First of all, perforce refuses to work on any change lists if the host differs in their workspace. So step one is to change the host of the workspace to the current one. This can easily be done with the visual client p4v. Open the properties of a workspace, choose edit and change the host.
Then you can use the command line to get rid of the pesky change list(s):
# to delete a changelist
CLIENT="name_of_your_client"
CHANGE="number_of_the_changelist_to_delete"
p4 -c $CLIENT shelve -c $CHANGE -d //... # Delete all shelved files from it.
p4 -c $CLIENT revert -k -c $CHANGE //... # Revert all files from changelist (only metadata).
p4 -c $CLIENT change -d $CHANGE # Finally delete the changelist.
After the last command the change list will be gone forever.
Fixing the hostname can be done from the command line like this:
client_hostname="$(p4 client -o ${CLIENT} | grep "^Host" | awk '{print $2}')"
p4 client -o ${CLIENT} | sed "/^Host:/ s=${client_hostname}=${HOSTNAME}=" | p4 client -i
Had the same problem some time ago and wrote a script (p4-delete-changelist) that overcomes all of these problems (and another one - deleting p4 fixes).
Note that the script depends on another file in the repository.

Resources