小编典典

如何查看 SVN 中文件的所有历史更改

all

我知道我可以svn diff -r a:b repo查看两个指定修订版之间的更改。我想要的是更改文件的每个修订版的差异。这样的命令可用吗?


阅读 122

收藏
2022-08-02

共1个答案

小编典典

它没有内置命令,所以我通常只做这样的事情:

#!/bin/bash

# history_of_file
#
# Outputs the full history of a given file as a sequence of
# logentry/diff pairs.  The first revision of the file is emitted as
# full text since there's not previous version to compare it to.

function history_of_file() {
    url=$1 # current url of file
    svn log -q $url | grep -E -e "^r[[:digit:]]+" -o | cut -c2- | sort -n | {

#       first revision as full text
        echo
        read r
        svn log -r$r $url@HEAD
        svn cat -r$r $url@HEAD
        echo

#       remaining revisions as differences to previous revision
        while read r
        do
            echo
            svn log -r$r $url@HEAD
            svn diff -c$r $url@HEAD
            echo
        done
    }
}

然后,您可以使用以下命令调用它:

history_of_file $1
2022-08-02