Subversion: How to get a list of all active, unmerged branches

Viewed 1736

My question is similar to Mercurial: List all unmerged branches but for SVN, not Mercurial.

I need to find a way to list all currently open branches that haven't been merged into mine (usually trunk).

As far as I'm aware, the equivalent feature in Git is git branch --no-merged and git branch --merged

For clarification, I'm not asking for a list of unmerged revisions, like many other StackOverflow questions have asked in the past.

I'll accept any solution that is able to to list all active branches that are not yet merged. If this isn't possible, then I will accept an answer that lists all active, merged branches, allowing me to work backwards.

For example, if I'm on repo/trunk, and the repo has these branches:

  • repo/branches/b1 has not been merged into trunk
  • repo/branches/b2 has been merged
  • repo/branches/b3 was deleted in a previous revision and wasn't merged
  • repo/branches/b4 was deleted after being merged

Your solution should return either b1 or b2, but must never return b3 or b4.

2 Answers

For those people using MacOS or Linux, here is a simple bash script based on Peska's answer. You can pass paths to the branch and trunk folders on the command line, or it will default to the default remote paths ^/branches and ^/trunk

#!/bin/bash

BRANCHDIR=${1:-^/branches}
TRUNKDIR=${2:-^/trunk}

for branch in $(svn list "$BRANCHDIR" -r HEAD)
do
    for revision in $(svn mergeinfo --show-revs eligible "$BRANCHDIR/$branch" "$TRUNKDIR")
    do
        echo "$BRANCHDIR/$branch"
        break
    done
done
Related