examining history of deleted file

前端 未结 17 1876
臣服心动
臣服心动 2020-11-30 17:36

If I delete a file in Subversion, how can I look at it\'s history and contents? If I try to do svn cat or svn log on a nonexistent file, it complai

17条回答
  •  孤街浪徒
    2020-11-30 18:27

    You can find the last revision which provides the file using binary search. I have created a simple /bin/bash script for this:

    function svnFindLast(){
     # The URL of the file to be found
     local URL="$1"
     # The SVN revision number which the file appears in (any rev where the file DOES exist)
     local r="$2"
     local R
     for i in $(seq 1 "${#URL}")
      do
       echo "checkingURL:'${URL:0:$i}'" >&2
       R="$(svn info --show-item revision "${URL:0:$i}" 2>/dev/null)"
       echo "R=$R" >&2
       [ -z "$R" ] || break
     done
     [ "$R" ] || {
      echo "It seems '$URL' is not in a valid SVN repository!" >&2
      return -1
     }
     while [ "$r" -ne "$R" -a "$(($r + 1))" -ne "$R" ]
     do
      T="$(($(($R + $r)) / 2))"
      if svn log "${URL}@${T}" >/dev/null 2>&1
       then
        r="$T"
        echo "r=$r" >&2
       else
        R="$T"
        echo "R=$R" >&2
      fi
     done
     echo "$r"
    }
    

提交回复
热议问题