examining history of deleted file

前端 未结 17 1861
臣服心动
臣服心动 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:07

    I wanted an answer, myself. Try the following to output only deletes from svn log.

    svn log --stop-on-copy --verbose [--limit ]  | \
    awk '{ if ($0 ~ /^r[0-9]+/) rev = $0 }
      { if ($0 ~ /^ D /) { if (rev != "") { print rev; rev = "" }; print $0 } }'
    

    This filters the log output through awk. awk buffers each revision line it finds, outputting it only when a delete record is found. Each revision is only output once, so multiple deletes in a revision are grouped together (as in standard svn log output).

    You can specify a --limit to reduce the amount of records returned. You may also remove the --stop-on-copy, as needed.

    I know there are complaints about the efficiency of parsing the whole log. I think this is a better solution than grep and its "cast a wide net" -B option. I don't know if it is more efficient, but I can't think of an alternative to svn log. It's similar to @Alexander Amelkin's answer, but doesn't need a specific name. It's also my first awk script, so it might be unconventional.

提交回复
热议问题