3

I have some software that is version controlled with Perforce. There are a lot of checkins, and hence a lot of changelists.

There is one feature, implemented with many checkins across a long period of time, that I would like to port elsewhere. I can search the history by hand, but it would be really nice if there were a simple way to diff the current state of the baseline against the combined effect of selected changelists.

In other words, diff the latest-greatest in that branch against the result of: changelist A+ changelist B + changelist C...

How do I do this in Perforce?

kmort
  • 2,848
  • 2
  • 32
  • 54
  • Do you want to compare different versions of a single file or different versions of several files? You can always do "p4 diff ...@YYYY/MM/DD" to compare the current version of a subtree with the same subtree in an older version. But the result is hard to read of course (if it's complex). – pitseeker Jan 23 '14 at 11:42
  • If you are using p4v, have you looked at Time-Lapse view? Within the same branch it works to allow you to look at the code over time. It'll allow you to compare cumulative changes against current or past change lists. – gaige Jan 23 '14 at 11:49
  • @pitseeker There were several developers that checked in to the same branch over a long period of time. I only want some of the changelists from one of the developers. I can easily find all the relevant changelists, it's just a pain to manually diff each one. And it's different versions of a whole bunch of files. I want to take all the changelists I care about, sum them up, and diff them against the current latest-greatest. – kmort Jan 23 '14 at 13:18
  • @gaige I've only been able to use Time-Lapse view on one file at at time. Is there some way to use it on a collection of changelists with multiple files changed? – kmort Jan 23 '14 at 13:19
  • @kmort not that I'm aware of. I didn't infer from your note you were looking to see multiple files at the same time, although I can see where that might have been the intent. – gaige Jan 23 '14 at 13:25
  • Actually I can't really imagine how a multifile diff could look like (independently from the SCM). The timelapse view is already pretty convinient, but how should it work for several files at once? – pitseeker Jan 23 '14 at 13:38
  • @pitseeker Each file will have its own diff. Just that there were multiple changes made to each file, and I only want to extract one of the features added. I know the changelists these mods were made in. I thought it would be nice to automatically aggregate the changes and compare. Very similar to dragging one changelist on top of the other in P4V where you get a list of differences and can double click the files for individual diffs, except I would be choosing the changelists (multiple) that are aggregated. Does that make sense? – kmort Jan 23 '14 at 14:54
  • @kmort I'm afraid that sounds like a very specialised tool. IMHO the tool most useful for you is probably the timelapseview. Also if I got you right you want to see several changes done to a certain file in one go (in one diff). How can that work? You can only diff 2 versions. You can also diff 3 versions in a 3-way diff/merge. But "n" versions ? Apart from no tool for it I don't even think this works in theory. But perhaps I still didn't understand the issue yet. – pitseeker Jan 24 '14 at 08:07
  • @pitseeker The way I understand it, Perforce stores changelists as diffs from the original. I was hoping to sum all the diffs from only certain changelists and compare against the current. Basically, I want to see what has changed in a baseline over time, using only selected changelists. It doesn't sound like this is going to be possible with Perforce. Oh well. :-) – kmort Jan 24 '14 at 13:22

1 Answers1

1

The way I would do this is to build up the set of changes I wanted in my workspace using a combination of p4 edit, sync, and resolve. The basic process would be:

  1. Sync to change A (assuming it starts the sequence)
  2. Open everything for edit
  3. Sync to change B-1 (this will schedule a resolve )
  4. Run p4 resolve and ignore the changes (-ay)
  5. Sync change B ( this will schedule a resolve )
  6. Resolve change B handling any conflicts
  7. Sync to change C-1
  8. Resolve and ignore the changes
  9. Sync change C
  10. Resolve and merge in the changes
  11. Diff against head
Matt
  • 4,860
  • 1
  • 17
  • 15
  • Thanks Matt. This will do what I asked. I was hoping for something a bit more automated, but I think you've shown the best that Perforce can do with this currently. – kmort Jan 30 '14 at 02:24
  • I have the same issue. I'm doing code reviews across multiple change lists and it's a time consuming nightmare. The answer from @matt looks great if only I could understand it. lol The bit that loses me is the jump from having change lists A, B & C but syncing to B-1 & C-1. I don't understand what B-1 & C-1 are. – Keith Oct 30 '15 at 16:34
  • Literally one less than whatever changelist number A, B, and C are. So if you want to see the combined effects of changes 123(A), 456(B), and 789(C), then you would sync to 123, open everything for edit, then sync to 455, resolve -ay to ignore all those changes, then sync to 456 to take just the content from that change. – Matt Nov 02 '15 at 18:41
  • Thank you Matt, I was reading it as 'hyphen one' instead of 'minus one'. lol. Much appreciated. – Keith Nov 03 '15 at 16:35