2

源代码控制很棒。一个很好的功能是我知道我可以回到以前的版本,以防出现问题。

但是,我仍然发现自己讨厌删除大量不再需要但我将来可能想使用其中一部分的代码。它在当前的代码库中确实没有任何业务。但是,我不喜欢删除它,因为我没有简单的方法来浏览我的修订历史并找到它。我会经常剪切+粘贴它并将其放入具有“未使用”和“tmp”等描述性名称的文件中,它们会在那里放置一段时间。

如果我有一个很好的方法来浏览存储库历史/搜索过去的代码,这个问题就会得到解决。是否有任何 GUI 可以让我这样做,或者我可以使用任何易于使用的过程?有没有办法用 TortoiseSVN 做到这一点?现在我知道要采取的唯一方法是检查不同的修订号,看看我想要的文件是否在那里,这太耗时了。

4

3 回答 3

4

What I like to do is add a tag: say "Codebase_before_removing_such_and_such_function". Then you can go into the Repository Browser in TortoiseSVN, browser to that tag, and dig into it to find the old file. Click on that file and select "open" to just see the code in that file.

You can also do the same by changing the Repository Browser to point to a particular revision rather than pointing to HEAD (and, again, then browsing to the particular file you want and opening it) but it's easier to tag because you can give tags meaningful names.

于 2010-06-24T15:41:40.590 回答
0

You can do that by viewing changes in Tortoise SVN...however...

I personally prefer Mercurial.

When you are working in a group, you are able to commit locally as often as you please, then when you want to try to commit to the group solution you can merge everything. This way, no matter what happens during a merge, no data is lost because everyone has back up repositories on their hard drives, and the pre-merge version is available on the group repository. It also means that you can commit every time you make a change, regardless of whether or not it works, because no one else sees it until you push it to the group repo. I like to add rather lengthy comments to my commits, because it means I absolutely don't have to search for the right version.

It's a bit different than Tortoise (which I use at work), but definitely better as far as I am concerned.

于 2010-06-24T15:42:03.607 回答
0

您可以使用带有 -v (详细,显示更改的路径)和 --xml 选项的 svn 命令行,并将结果通过管道传输到XMLStarlet。这将允许您按已删除的操作进行过滤,并向您显示文件被删除的修订版(然后您可以通过 grep 管道获取您要查找的文件)。

例子:

svn log -v --xml /path/to/repo | xml sel -T -t -m "//logentry/paths/path[@action='D']" -v "concat(../../@revision,': ',.)" -n

样本输出:

103: /foo/deprecated.h
99: /foo/bar/badfile.hpp

显然,使用svn log您可以将其限制为修订范围 (-r M:N),或日期范围 (-r {date1}:{date2}),或最后 N 次修订 (-l C)。

唯一的缺点是误报,因为 SVN 移动实际上是复制+删除。

一旦你知道它被删除的版本,你就可以使用svn catsvn export来查看文件:

svn cat /path/to/repo/foo/deprecated.h@102

由于 deprecated.h 在 r103 中被删除,我告诉 svn 获取 deprecated.h 的路径,因为它存在于 r102 中(删除之前)。

于 2010-06-24T16:28:56.313 回答