SVN:通过比较文件或文件内容来确定修订的方法 [英] SVN: Way to determine revision by comparing file or file content

查看:97
本文介绍了SVN:通过比较文件或文件内容来确定修订的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我有一个文件的情况下,我需要知道该文件在源代码中的修订版本.

I have a scenario where I have a file and I need to know what revision in source this file is.

我可能在一个特定的文件上有数百个修订,并且有一个文件与这些修订中的一个或多个相匹配. 在Tortoise,Cornerstone中或通过命令行有什么方法可以做到这一点?

I may have hundreds of revisions on a particular file and have a file that matches one or more of those revisions. Is there any way in Tortoise, Cornerstone or through the command line to do this?

如果问题不是最明确的话,我们深表歉意.老实说,我不确定如何表达我要寻找的内容.

Apologies if the question isn't the clearest. To be honest I'm not sure how to phrase what I'm looking for.

我在这里找到了关于git的类似问题;

I found a similar question about git here;

GIT:根据文件确定修订版本

推荐答案

略述此答案,这里是一个快速且肮脏的批处理文件,它可以完成此工作,前提是输入文件已经在版本控制之下.

Cribbing a bit off of this answer, here's a quick and dirty batch file that will do the job, assuming the input file is already under version control.

@echo off

set file=%1
set temp_file="temp.file"

if [%file%] == [] (
  echo Usage: "%0 <file>"
  exit /b
)

for /F "tokens=1 delims=-r " %%R in ('"svn log -q %file%"') do (
  svn cat -r %%R %file% > %temp_file%
  fc %temp_file% %file% > nul
  if errorlevel 0 if not errorlevel 1 echo Matches revision r%%R
  del /Q %temp_file%
)

这将获取给定文件名的日志,并且对于每个修订版本执行以下操作:

This gets the log for the filename given, and for each revision does the following:

  • 将该版本的文件版本转储到磁盘上的临时文件中
  • 将转储的修订版与输入文件进行比较
  • 如果它们相等,则fcerrorlevel设置为0,因此检查并输出Matches revision r###
  • 删除临时文件
  • dumps the version of the file at that revision to a temporary file on disk
  • compares the dumped revision with the input file
  • if they're equivalent, fc sets errorlevel to 0, so check for that and output Matches revision r###
  • removes the temporary file

这篇关于SVN:通过比较文件或文件内容来确定修订的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆