Sam Liddicott
Sam Liddicott

Reputation: 1406

Listing perforce changes in one branch, but not another; when there are deletions

When I want to compute a list of changes in one branch but not an older branch, I do something like this:

diff -u \
  <( p4 changes -s submitted -i @OLD_BRANCH_LABEL )  \
  <( p4 changes -s submitted -i @NEW_BRANCH_LABEL ) | grep ^+'

NOTE: These are automatic labels containing a view and a revision, but I can also put in the view paths @REVISION

which gives a good answer when both labels are actually in the same view, and good answers generally.

But I find that I get some poor results in this case:

If a commit #A adds a file to MAIN_BRANCH, and commit #D removes the file (and makes some other change), followed by commit #F which forks a NEW_BRANCH, I find that the MAIN_BRANCH contains both commits #A and #D, but NEW_BRANCH contains commits #D and #F

The NEW_BRANCH does not contain commit #A

So my p4 changes recipe above insists that the mainline contains #A which is not in the branch, or in other words was made since the branch, even though it is not in the mainline any more than it is in the branch.

An obvious but unwieldy fix would be to take another fork of MAIN_BRANCH at the point I want to compare, knowing that #A would be excluded again in the same way.

If this were git, I would use git-merge-base or something to find a common point and remove that from the changes of both branches, but perforce branching is too flexible, being just another integration.

Are there any ways that I can convince perforce that NEW_BRANCH does contain #A? (for the branch fork #F occurred after #A was committed).

Or to get perforce to ignore changes whose files are entirely deleted, that WOULD be ignored if a branch were made?

Upvotes: 2

Views: 329

Answers (1)

gmaghera
gmaghera

Reputation: 545

The command p4 interchanges does exactly what you are after, if I read your question correctly.

'p4 interchanges' lists changes that have not been integrated from
a set of source files to a set of target files.

Have a look at p4 help interchanges for the full description. The command does take indirect integrations into account, too.

Upvotes: 1

Related Questions