SVN:如何知道文件在哪个版本中被删除?
鉴于我在 Windows 上使用 svn 命令行,如何查找删除文件的修订号?在 Windows 上,没有像 grep 这样奇特的东西,我尝试只使用命令行,而不使用 TortoiseSVN。提前致谢!
编辑:
- 我看到了一些帖子,例如 检查已删除文件的历史记录,但它没有回答我的问题。
- 除了 svn log -v url > 还有其他方法吗? log.out 并用记事本搜索?
Given that I'm using svn command line on Windows, how to find the revision number, in which a file was deleted? On Windows, there are no fancy stuff like grep and I attempting to use command line only, without TortoiseSVN. Thanks in advance!
EDIT:
- I saw a few posts, like examining history of deleted file but it did not answer my question.
- Is there any way other than svn log -v url > log.out and search with Notepad?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
安装 Cygwin。
我使用这个:
where
这将为您提供有关文件的所有操作(添加、删除、删除、修改)的修订,但通过使用
grep
进行简单调整,您可以获得仅用于删除的修订。(显然,--limit 是可选的,但是您通常可以了解需要搜索的深度,从而提高性能。)
Install Cygwin.
I use this:
where
This will give you the revisions for all the actions (add, delete, remove, modify) concerning the file, but with a simple tweak with
grep
you can get the revisions only for deletion.(Obviously, --limit is optional, however you usually have an overview about how deep you need to search which gains you some performance.)
日志是查看的地方。我知道您不想听到这个答案,但这就是您需要在 SVN 中查找已删除文件的地方。
原因很简单,删除的文件在删除后不可见。找出其存在的唯一位置是在日志中,或者在删除之前取出较早的修订版本。
据我所知,处理此问题的最简单方法是摆脱命令行,并使用 GUI 工具,例如 TortoiseSVN< /a>.
TortoiseSVN 将自身链接到标准的 Windows 文件资源管理器中,因此它非常易于使用。在回答这个问题时,您仍然会使用它来查看日志,但它变得更快:
浏览到您想要检查的 SVN 文件夹。然后右键单击文件夹图标并选择TortoiseSVN ->从上下文菜单中查看日志。
现在您将看到一个窗口,显示该文件夹中所做的所有修订。特别是,很容易看出哪些修订版有添加和删除,因为该列表包含每个修订版的一组操作图标。您可以双击某个修订版来获取已更改的文件列表(如果仅更改了一个文件,则直接进入差异视图),
这样您就可以轻松查看哪些修订版已被删除,并且可以快速单击它们来查找找出涉及哪些文件。真的就是这么简单。
我知道您问的是命令行,但对于像这样的管理任务,GUI 浏览器确实很有意义。与尝试阅读几页神秘文本(无论您多么精通阅读该文本)相比,它可以更快地了解正在发生的情况。
The log is the place to look. I know you don't want to hear that answer, but that is where you need to look for deleted files in SVN.
The reason for this is simply that a deleted file is not visible after it's been deleted. The only place to find out about its existence at all is either in the logs, or by fetching out an earlier revision prior to it being deleted.
The easiest way I know of to deal with this problem is to move away from the the command line, and use a GUI tool such as TortoiseSVN.
TortoiseSVN links itself into the standard Windows file Explorer, so it's very easy to use. In the context of answering this question, you would still use it to look at the logs, but it becomes a much quicker excersise:
Browser to the SVN folder you want to examine. Then right-click on the folder icon and select TortoiseSVN -> View Logs from the context menu.
You'll now get a window showing all the revisions made in that folder. In particular, it is easy to see which revisions have had additions and deletions, because the list includes a set of Action icons for each revision. You can double-click on a revision to get a list of files that were changed (or straight into a diff view if only one file was changed)
So you can easily see which revisions have had deletions, and you can quickly click them to find out which files were involved. It really is that easy.
I know you're asking about the command-line, but for administrative tasks like this, a GUI browser really does make sense. It makes it much quicker to see what's happening compared with trying to read through pages of cryptic text (no matter how well versed you are at reading that text).
这个问题是前一段时间发布并回答的。
在这个答案中,我将尝试展示一种灵活的方法来获取所询问的信息并扩展它。
在 cygwin 中,将
svn log
与awk
结合使用svn log ${REPO_URL} -v --search "${FILENAME}"
询问 svn log 包含 ${FILENAME} 的详细日志。这减少了数据传输。awk
。awk
获取通过 varvar
中的-v
传递的${FILENAME}
以及搜索模式var ="^ [D] ${FILENAME}$"
awk
程序中/^r[0-9]+/ {rev=$1}
赋值如果行匹配,则将修订号改为rev
<代码>/^r[0-9]+/。^ [D] ${FILENAME}$
的每一行,awk 打印存储的修订号rev
和行:$0 ~ var {print rev $0}< /code>
如果您不仅对删除文件感兴趣,还对创建、修改、替换、更改
var="^ [D] ${FILENAME}$" 中的
到D
感兴趣DAMR
。以下将为您提供所有更改:
如果您对用户名、日期和时间感兴趣:
This question was posted and answered some time ago.
In this answer I'll try to show a flexible way to get the informations asked and extend it.
In cygwin, use
svn log
in combination withawk
svn log ${REPO_URL} -v --search "${FILENAME}"
asks svn log for a verbose log containing ${FILENAME}. This reduces the data transfer.awk
.awk
gets${FILENAME}
passed via-v
in the varvar
together with search patternvar="^ [D] ${FILENAME}$"
awk
program/^r[0-9]+/ {rev=$1}
assigns the revision number torev
if line matches/^r[0-9]+/
.^ [D] ${FILENAME}$
awk prints the stored revision numberrev
and the line:$0 ~ var {print rev $0}
if you're interested not only in the deletion of the file but also creation, modification, replacing, change
D
invar="^ [D] ${FILENAME}$"
toDAMR
.The following will give you all the changes:
And if you're interested in username, date and time: