Issue
I can compare a current folder state to its latest revision using the following command:
meld .
meld
shows a list of changed files. One can click on each file and see a diff.
Is it possible to compare a current folder state to its specific revision (not the latest one)?
TortoiseSVN allows to compare arbitrary revisions, however it works on Windows only. SmartSVN is proprietary. SVN CLI is unusable for big changesets (CLI diff is fine for small commits, but it's very hard to use it for branch comparision with a lot of changes).
Maybe I could checkout the revision to compare into a separate folder and compare two folders using meld
. But I guess there should be a simpler approach.
Solution
Folder comparision is usually required for code review or branch merging. It seems that the simplest approach is as follows:
- Find last trunk revision merged to a current brach
- If the current branch was not merged from trunk, then find the branch creration revision
- Checkout trunk with a specified revision to some folder
- Compare the trunk folder and the brach folder
I didn't found any existing tools supporting it. Here is a simple bash script:
TRUNK_FOLDER=~/tmp/trunk-merge
LAST_TRUNK_MERGED_REV=$(svn mergeinfo --show-revs merged -R "^/trunk" | tail -n 1)
if [[ -z "$LAST_TRUNK_MERGED_REV" ]]; then
LAST_TRUNK_MERGED_REV=$(svn log -r 1:HEAD --limit 1 --stop-on-copy -q | grep -oP "^r\K[0-9]+")
echo "Comparison with trunk@$LAST_TRUNK_MERGED_REV from which the current branch was copied"
else
echo "Comparison with trunk@$LAST_TRUNK_MERGED_REV with which the current branch was last merged"
fi
svn update -r $LAST_TRUNK_MERGED_REV "$TRUNK_FOLDER"
meld "$TRUNK_FOLDER" .
Answered By - Denis Answer Checked By - Cary Denson (WPSolving Admin)