开发者

Easiest way to collect revision history since last merge in Subversion

开发者 https://www.devze.com 2022-12-11 10:32 出处:网络
I usually commit multiple changes to my branch and merge to trunk occasionally. I\'d like to keep all my commit messages in the latest revision note of the final trunk merge. I don\'t want to memorize

I usually commit multiple changes to my branch and merge to trunk occasionally. I'd like to keep all my commit messages in the latest revision note of the final trunk merge. I don't want to memorize revision numbers or anything I simply want "all commit messages to the branch since the last merge to trunk" collected together in an editable fashion before I commit.

Since this information is available only in mergeinfo I think this has to be provided by client. I didn't find this feature in TortoiseSVN, SVN Monitor or command lin开发者_如何学Pythone client. Any chances I'm missing something obvious?


I hope I understood your requirement correctly. You can try the following steps: (via svn commandline client):

  1. svn log -v --stop-on-copy http://myrepo/mybranch gives out a report you can use to find out the revision number representing your last merge from the branch to trunk. (XXXX)

  2. svn log -rXXXX:HEAD http://myrepo/mybranch > commitmessg.txt (Presuming you now want to merge form the HEAD version of your branch into the trunk) - this will collect all your commit messages into the text file. You may want to edit this file to include a meaningful first line like "Merging elements as below" - or "Merging all elements pertaining to the defect fix &&&&" etc., and save.

  3. Perform the merge as usual

  4. While committing the merged files, run svn commit -F commitmessg.txt so the message contains the contents for the text file. (I am not sure of the character limitations for commit messages though)

Hope this helps.

EDIT: (via TortoiseSVN)

Just figured to do this via tortoiseSVN as well. You can get to the tortoiseSVN-Show Log, select the range of versions you want the log for (using show range button at the bottom). Highlight the report in the message window - right click - copy to clipboard, and paste into a text file. (I liked the format of the commandline output better though.) You can edit this file and use it for the post-merge commit.


This isn't exactly what you're looking for, but you could always build the list of commit messages by piping mergeinfo into the svn log command using xargs. It looks more or less like this:

svn mergeinfo $SOURCE $DESTINATION --show-revs eligible | xargs -i  svn log $SOURCE -r '{}'


Another solution, inspired by @tschaible's answer:

$ svn mergeinfo --show-revs=eligible ^/branches/version | tr "\\n" "," | xargs -i svn log -c {} ^/branches/version

Basically, it's the same idea used by @tschaible, but a little bit faster, because the svn log command runs just once, accepting a list of revisions in question. To make the command little bit easier and shorter, you may consider to add an alias in your ~/.bash_aliases file as follow:

alias svnlog='tr "\\n" "," | xargs -i svn log -c {}'

Now, you can shorten the command like that:

svn mergeinfo --show-revs=eligible ^/branches/version | svnlog ^/branches/version


I had somewhat similar problem of merging and commit changes from trunk to branch and SVN 1.7 does not provide by default svnmerge so I developed small script to complete this task for me.

So here is my bash script to merge and commit files:

#!/bin/bash

usage() {
cat << EOF

    usage: $0 options

    Script to simplify merging and commiting to prelive 

    OPTIONS:
       -h      Show usage
       -r      Specify file to use
       -s      Merge source location 
       -d      Place where You want ot merge 

EOF
}

SOURCE= 
DESTANATION= 
REV= 
# Provide revision number or list of revisions
while getopts "hr:s:d:" OPTION; do 
    case $OPTION in 
        h) 
            usage
            exit 1
            ;;  
        r) 
            REV=$OPTARG
            ;;
        s)
            SOURCE=$OPTARG
            ;;
        d)
            DESTANATION=$OPTARG
            ;;
    esac
done

# Create commit message file 
echo "Preperign commit info file..."
FILE=commit-info.txt
touch $FILE
echo "Merged revision(s) $REV via costom merge script from" > $FILE
svn info $SOURCE | grep 'URL' | awk '{print $NF}' >> $FILE

LIST=`echo "$REV" | tr ',' ' '`

# Get commit messages from source location 
echo "" >> $FILE
for commit in $LIST
do
    svn log $SOURCE -r $commit >> $FILE
    echo "" >> $FILE
done
echo "Done...."

# Merge changes from source location 
echo "Starting merge....."
svn merge -c$REV $SOURCE
echo "Done merging...."

# Commit changes to destanation 
echo "Start commiting files to SVN...."
svn commit -F $FILE
rm $FILE
echo "Complete"
0

精彩评论

暂无评论...
验证码 换一张
取 消