SVN: Create a diff for lots of revisions

27,098

Solution 1

One possible procedure would be to do this:

  1. create diffs for 224453 and 224462 (e.g. by svn diff -r 224452:224453 > diff1.patch).
  2. check out 224446 (svn up -r224446)
  3. apply the diffs (e.g. patch -p0 -i diff1.patch)
  4. create a diff of that against 224445 (svn diff -r 224445 > diff2.patch)

Solution 2

One option would be to create a branch at 224446, then merge in 224453 and 224462. Then take a diff between that and 224445 on the trunk. That should be all the changes in one, and you can create it as a patch file should you need to:

# Branch from your initial checkin
svn cp svn://xyz/trunk@224446 svn://xyz/branches/foo

# Check it out
svn checkout svn://xyz/branches/foo tmp

# Merge in the two changes
svn merge -c 224453,224462 svn://xyz/trunk tmp

# Commit the changes
svn commit tmp -m "Extra commits 224453 and 224462"

# Diff the branch from mainline before original
svn diff svn://xyz/trunk@224445 svn://xyz/branches/foo

This is largely the same as Martin's answer, just with different ways of applying the changes and getting the diffs. Note that although in this case I've committed the changes, you don't really have to - you could just do svn diff svn://xyz/trunk@224445 tmp instead of the last two commands. The nice thing about having it in the repository is then anyone can apply the diff in reverse to roll it back, should that be required.

Share:
27,098
Paul Tarjan
Author by

Paul Tarjan

I'm a Distinguished Engineer at Robinhood. I used to be the Tech Lead of Developer Productivity at Stripe where I built Sorbet. Before that I was the CTO and cofounder at Trimian. Before that I was a Software Engineer at Facebook on HHVM and the Open Graph. Before that I was the Tech Lead for Yahoo! SearchMonkey. See my homepage for more.

Updated on October 28, 2020

Comments

  • Paul Tarjan
    Paul Tarjan over 3 years

    I had a private branch that I did a ton of commits to, then I merged it into trunk, and did a few little tweaks there.

    Now the trunk maintainer wants a diff off all of my changes incase we need a rollback.

    How can I create this? If you need numbers for your examples, assume that

    224446

    was my main revision where I merged into trunk,

    224453 and 224462

    were my minor fixes, and I have countless changes when in my private branch.

  • Paul Tarjan
    Paul Tarjan over 14 years
    sounds great. I'm not very familiar with SVN, can you post some commands?
  • Arturs Mednis
    Arturs Mednis over 14 years
    +1 for Jon's solution. What about when you add another revision? Then whole patch need to be regenerated. Patches are good when you don't have commit acces.
  • Thomas S. Trias
    Thomas S. Trias over 12 years
    I almost missed the postscript to Jon's solution; you can also skip the svn cp step and just svn co svn://xyz/trunk@224446 tmp. This works even if you do not have permission to alter the repository directly.