perforce: 'p4 changes' with its change 'diff' between two changesets - perforce

is there a way to list out all the changes with each change's subject and its change difference between two changesets?
p4 diff2 -u //depot/build/stage/gobuild/...#676277 //depot/build/stage/gobuild/...#676640
this giving only consolidated diff

Here's how to script Bartek's answer, in one easy line:
p4 -Ztag -F "describe %change%" changes -s submitted #676277,676640 | p4 -x - run
If you want to massage the output further you'll need to buckle down and learn a scripting language -- the p4 command line can do a lot on its own but it's no substitute for Perl. :)

p4 changes won't show you diffs. You could use it for collecting changelist numbers and then you could call p4 describe for each which will produce a diff.
See p4 help describe for the formats of diffs.

Related

P4 -s describe changelist

Is there an straight forward command to get only the submitted description of a CL and not the affected files ? I want to get only the one-liner descriptions of a list of change lists and print them all in one file with the CL number.
Take a look at the "p4 changes" command -- that sounds like it might already have roughly the format you're looking for?
Otherwise, you can get the full description with a command like:
p4 -Ztag -F %Description% change -o CHANGENUM
A bit late, but this might be what you where looking for:
p4 changes -e [changelist#] -r -m 1
This will give description of all changelists submitted between two dates
p4 changes -u <username> -l //<depot>/...#2020/01/01,#2021/01/10

p4 describe for multiple changelists

I want to redirect the output pf "p4 describe" for a set of Changelists, into a xls file.
As I saw the syntax for p4 describe, we can only give a single changelist with "p4 describe" for ex: p4 describe -df .
Could you please help me get p4 describe for multiple CLs?
Here's the syntax for 'p4 describe', from 'p4 help describe':
describe -- Display a changelist description
p4 describe [-d<flags> -s -S -f -O] changelist# ...
Note that '...' at the end. That means that you can pass multiple arguments.
So, for example,
p4 describe -df 1704 1722 1903
works fine, and describes each changelist, in turn, one after the next, in a single command.
Now, as to the bit about trying to put this in a xls file, I'm confused, because I'm not sure what sort of xls file you're talking about. The output of describe doesn't seem very useful as a spreadsheet, to me.

Using P4CONFIG variables in p4 commands

Is it possible to use variables defined in P4CONFIG files in p4 commands? Let's say I want to define an alias for quickly seeing pending changelists in the current workspace. So something like:
p4 changes -s pending -c $P4CLIENT
I don't want to define P4CLIENT in my bashrc as I switch between different workspaces a lot. I much prefer it to come from the current P4CONFIG file. Is that possible?
This should do it:
p4 -Ztag -F %clientName% info | p4 -x - changes -s pending -c
Note that you need a relatively current p4 client to use the undoc -F flag, which is described more here: http://www.perforce.com/blog/130826/fun-formatting
You could also script something around "p4 set P4CLIENT", which is a purely client-side query and therefore a bit faster, but you'll need to manipulate the output a bit to make it suitable as an argument to "p4 changes".

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