(toiminnot)

hwechtla-tl: Making a combined diff of many subversion commits: viime muutokset

(nettipäiväkirja 08.02.2017) Branching in [subversion] is somewhat more cumbersome than, say, in [Git] or [darcs], so some programming shops run the practice of not using branches for features and just tagging all commits to some feature in the commit message. It's fine, and it significantly reduces the pain of merges (by keeping the merges small), but it does make code reviews sometimes hard. The worst case is when you have to review a long-running feature pseudo-branch with commits interspersed with other commits.

Stack Overflow tells us that Intellij IDEA has something to combine the diffs (http://stackoverflow.com/questions/466195/seeing-a-combined-diff-of-man y-commits-in-subversion), but if it really does, I've never been able to find this functionality. Instead, I did what the people in the thread suggested: write a script that takes the patches of multiple commits, splits them, and combines them so that changes to the same line(s) are merged.

It's not foolproof, since the changes in between (that do not belong to the pseudo-branch) might offset the changes in the patches. However, this actually works pretty well for most cases. The only other option I can think of, is to create a new branch for the code review and cherry-pick all commits to be reviewed into that branch. I don't know about subversion's cherry-picking abilities, but I wouldn't hold my breath for the success of this approach. Not to mention that it will then clutter your repository with another branch, something you were probably trying to avoid if you didn't create that branch in the first place.

Here's the diff-combining script (it uses splitdiff and combinediff from patchutils):

{{{ #!/bin/bash

TAG="$1"

mkdir -p tmp

test ! -s "tmp/$TAG.diff" \ && svn log --limit 500 --search "$TAG" --diff \ | sed '/^--------*$/,/^========*$/d;/^Index: /,/^========*$/d;/^$/d' \ > "tmp/$TAG.diff"

(cd tmp && splitdiff "$TAG.diff") > "tmp/$TAG.diff.combined"

ls tmp | tac | grep 'diff\.part[0-9]*\.patch$' \ | while read PATCH; do echo "Processing $PATCH..." 1>&2 combinediff -q "tmp/$TAG.diff.combined" "tmp/$PATCH" \ > "tmp/$PATCH.combined" \ && test -s "tmp/$PATCH.combined" \ && cp "tmp/$PATCH.combined" "tmp/$TAG.diff.combined" done

cat "tmp/$TAG.diff.combined" }}}

* [merkintä: 2017-02] * [atehwa] * [kategoria: päiväkirjamerkintä] * [kategoria: työkalut]


(viimeksi muutettu 08.02.2017 16:47)