List all the changes with contents from a specific user - perforce

I am trying to get the changes with diff from the changes from a specific user. once I know the change I can get the details using "p4 describe".
Do we have a way to get list of all the changes with contents from a specific user?

Use the p4 changes -u USER command to get the list of changes, then run "p4 describe" on each.
p4 -Ztag -F "describe %change%" changes -u USER | p4 -x - run

Related

How to change description of a pending (shelved) changelist using command?

I've created CL#100 with some description and shelved some files.
Now I need to edit the description of that CL using a command.
I have tried these 2 ways and both failed (same error msg)
p4 change -u 100 "Description: test description edit"
p4 change -o 100 > myDes.txt >> Edit Description field in myDes.txt >> p4 change -u 100 < myDes.txt
Error:
Execution Failed: "'C:
Program" "C:\Users\iman\AppData\Local\Temp\t26660t63.tmp": The system cannot find the file specified.
Client side operation(s) failed. Command aborted.
Edited File C:\Users\iman\AppData\Local\Temp\t26660t63.tmp kept due to errors.
It sounds like your P4EDITOR is set to "C:\Program", which is making p4 unable to launch an editor. This will cause problems for any command which edits a spec, not just p4 change commands! Do:
p4 set P4EDITOR=notepad
to set your editor to notepad (the default on Windows).
Then you should be able to run:
p4 change 100
The -u flag isn't needed for the update since this is a pending changelist (you can freely edit your pending changelists by default). The description is not specified on the command line; it's part of the spec that you'll edit in the editor.
If for some reason you need to do this without an editor (e.g. you're writing a script), you need to use -o to output to stdout and -i to input from stdin. I recommend using --field to modify the field instead of writing your own script to parse the changelist spec:
p4 --field "Description=test description edit" change -o 100 | p4 change -i

Sync only the latest change list number files using P4V

Is there any way to sync only the latest change list number changes.
For example if the latest change number is 1234 and has 2 files in submitted changelist. I want to sync only those 2 files not the complete folder.
The below command is syncing only the 2 files
p4 sync -f //demo/osb/Test/...#=1234;
I want to pass this value dynamically as this value will change.
I have tried the below commands but none are working.
p4 sync -f //demo/osb/Test/...#head;
p4 sync -f //demo/osb/Test/...#=head;
p4 sync -f //demo/osb/Test/...#head; --> this is updating the complete folder
p4 sync -f //demo/osb/Test/...#=head; --> this is updating the complete folder
Thanks for the help!!
One way to do this would be to use two commands:
p4 -F %change% -ztag changes -m1 -s submitted //demo/osb/Test/...
p4 sync //demo/osb/Test/...#=NNN
The first command tells you the change number of the latest submitted change. The second command syncs the files changed in that changelist.
Depending on your shell, you could perhaps combine them:
p4 sync //demo/osb/Test/...#=`p4 -F %change% -ztag changes -m1 -s submitted //demo/osb/Test/...`
(Whew! That's a mouthful!)
You have to have a fairly recent client version for the '-F %change%' syntax to work; if you're having trouble with this part of the solution, check your client version.

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.

How to view Shelved P4 Changes?

One of our team member (located in different region) has shelved changes in P4 with changelist 1234.
Now, if I want to see what files are modified snf what are the changes, how can I do this?
What is the P4 command that I should use to see the changes made by our team member?
p4 describe -S 1234 should to the trick, see the documentation on describe.
To see the file content you would unshelve the files into your workspace (assuming you have a workspace for the same project your colleague is working on).
Create a new (empty) changelist with p4 change (results in e.g. 2345), then use p4 unshelve (docu) to get the modified files to your workspace:
p4 unshelve -s 1234 -c 2345
If you don't want the modified files in your workspace any longer, you can p4 revert -c 2345 them.
Using the GUI, go to Pending and remove all filters except by user, where you will put the other developer's ID. From there you should be able to see her Changelists, including the ones having shelved files. Right click on the Shelved Files icon and select Unshelve. You will have to have a workspace active that includes the files that you are trying to unshelve.
Using UI client, press Ctrl+G. Dialog window is appears. Select Changelist in combobox and input number of changelist.
Let's assume that changelist 123456 is the shelved changelist in question. As a previous answer mentioned, the way to list the files are associated with that changelist is via the p4 describe -s <changelist> command. Like so:
$ p4 describe -s 123456
Change 123456 by john.doe#JohnsBranch on 2013/10/24 15:38:10 *pending*
[Shelving my changes for Jane.]
Fix memory corruption caused by uninitialized pointer.
Affected files ...
... //depot/branches/JohnsBranch/kernel/vm/pageutils.c#1 edit
Once you know the file(s) in question, there are a couple of ways to diff the files without a corresponding workspace. Method #1 is to use p4 print:
$ p4 print -q //depot/branches/JohnsBranch/kernel/vm/pageutils.c#1 > /tmp/old
$ p4 print -q //depot/branches/JohnsBranch/kernel/vm/pageutils.c#=123456 > /tmp/new
$ diff /tmp/old /tmp/new # Or use kdiff3, tkdiff, etc.
...
<diff output here>
The other method is to use p4 diff2:
$ p4 diff2 //depot/branches/JohnsBranch/kernel/vm/pageutils.c#1 //depot/branches/JohnsBranch/kernel/vm/pageutils.c#=123456
...
<diff output here based on Perforce server's diff algorithm>
Both methods can be easily incorporated into the scripting language of choice.
jhwist's solution is good if you want to see the files' diffs.
If you want to see just the shelved files, use p4 describe -sS 1234.
The lower case s restricts the output from including file diffs.
If you wanted to see the actual content of the files, you could use:
p4 print <file>#=<shelved_change>
The #= means to look at the shelved change, where as # means to look at the change.
If you want to see only the list of files inside a ChangeList (whether it's a shelve, pending or submitted CL), without extra data, grep the result:
p4 describe -S 12345 | grep -oP '(?=//).*(?=#)'
In P4V UI, select
Search - > Go To
then choose type of changelist (in your case 'Pending changelist'), enter changelist number and click "OK".
You may try
p4 -ztag describe <changeno>
The description contains a string called '... shelved' if it is shelved.

Is there a single Perforce command to display a list of all the check-ins to a file/dir along with the list of files that changed and the description?

p4 changes -l ... shows us the list of check-ins and the description, but it doesn't show the list of files that were modified in the check-in. Is there a way to do that in one command, without the need to create a wrapper script that combines the output of another command like p4 describe or p4 file?
In Subversion, I can do this by running svn log -v.
The 'files' command can do what you're looking for. An easy way is:
p4 files //...#=<changelist>
That example will list the files modified by that changelist, under the view specified.
You can use the "describe" command to get the description of a changelist, along with the files affected.
For example, p4 describe -s <changelist> will describe the changelist, and the "-s" will prevent it from displaying file diffs.
One liner, list all changes made to a branch, with description and list of affected files, without showing the diff. Thanks to a combination of answers. Works on windows with Unix utils
p4 changes -s submitted //depot/xxx/yyy/zzz/... | grep -o "^Change [0-9]*" | cut -f2 -d" " | p4 -x- describe -s
Output:
Change 1753385 by user#clientspec on 2019/03/08 06:29:44
Changing the world
Affected files ...
... //depot/xx/yy/zz.h#6 edit
Change 1751752 by name#clientspec on 2019/03/05 15:24:00
I made a change to a file
Affected files ...
... //depot/xx/yy/zz.h#3 integrate

Resources