每当我们发布项目时,我们都会创建一个标记来捕获快照。能够查看某些版本中使用的主干历史记录中的哪些修订版将非常有用。我知道TortoiseSVN修订图显示了这些信息,但我想知道是否有办法在命令行svn日志中看到它?
我来自Clearcase背景,我们将能够在历史中看到发布标签。
答案 0 :(得分:4)
tags
目录的日志应包含您在制作代码时提交的修订版本,trunk
的修订版编号将小于该版本。
或者我误解了什么?
查看我的类库:WebSVN view for my class library tags' directory
您可以看到每个构建最终的修订版本,因为它是相同的存储库,标记的修订版号比标记的更改中的最大可能版本高1。
以下是使用简单的svn log
命令查看的内容:
[C:\Temp] :svn log http://svn.vkarlsen.no/svn/LVK/LVK_3_5/tags
-----------------------------------------------------------------------
r751 | lassevk | 2009-10-04 13:45:07 +0200 (sø, 04 okt 2009) | 1 line
Build 750
-----------------------------------------------------------------------
r636 | lassevk | 2009-07-31 07:00:11 +0200 (fr, 31 jul 2009) | 1 line
Build 635
-----------------------------------------------------------------------
r632 | lassevk | 2009-07-25 06:19:27 +0200 (lø, 25 jul 2009) | 1 line
Build 631
-----------------------------------------------------------------------
r614 | lassevk | 2009-07-23 06:18:58 +0200 (to, 23 jul 2009) | 1 line
Build 612
|----|
^
+-- this column here shows the tag commit revision, trunk is less than that
或者使用xml:
[C:\Temp] :svn log http://svn.vkarlsen.no:81/svn/LVK/LVK_3_5/tags --xml
<?xml version="1.0"?>
<log>
<logentry
revision="751"> <-- this
<author>lassevk</author>
<date>2009-10-04T11:45:07.445750Z</date>
<msg>Build 750</msg>
</logentry>
<logentry
revision="636"> <-- and this
<author>lassevk</author>
<date>2009-07-31T05:00:11.796875Z</date>
<msg>Build 635</msg>
</logentry>
这是一个输出内容的python脚本,它没有格式化,因为它没有正确处理修订注释中的换行符,但它应该让你去。
from xml.dom.minidom import parse;
# files created by:
# svn log http://svn.vkarlsen.no:81/svn/LVK/LVK_3_5/tags --xml >tags.xml
# svn log http://svn.vkarlsen.no:81/svn/LVK/LVK_3_5/trunk --xml >trunk.xml
def get_revs(filename):
log = parse(filename);
try:
for rev in log.getElementsByTagName("logentry"):
revision = int(rev.getAttribute("revision"));
rev.getElementsByTagName("msg")[0].normalize();
comment = rev.getElementsByTagName("msg")[0].firstChild.nodeValue.rstrip();
yield (revision, comment);
finally:
log.unlink();
tag_revs = [tr for tr in get_revs("tags.xml")];
trunk_revs = [tr for tr in get_revs("trunk.xml")];
tag_revs.insert(0, (max((tr[0] for tr in trunk_revs)), "HEAD"));
tag_rev_lookup = {};
for tag_rev in tag_revs:
tag_rev_lookup[tag_rev[0]] = tag_rev[1];
prev_tag = -1;
for trunk_rev in trunk_revs:
tag_rev_for_trunk_rev = min((tr[0] for tr in tag_revs if tr[0] >= trunk_rev[0]));
if tag_rev_for_trunk_rev != prev_tag:
print("tag #%d: %s" % (tag_rev_for_trunk_rev, tag_rev_lookup[tag_rev_for_trunk_rev]));
prev_tag = tag_rev_for_trunk_rev;
print(" rev #%d: %s" % trunk_rev);
这输出(截断):
tag #879: HEAD
rev #879: Fixed build properties and added FinalBuilder project. Need PostSharp 2 to work properly for x64.
rev #878: Adjusted property targets.
Fixed references to SQLite for 32 and 64-bit.
rev #877: Removed 32-bit only SQLite library.
rev #876: Removed 32-bit only SQLite library.
rev #875: Removed 32-bit only SQLite library.
rev #874: Cleaned up dependencies on SQLite.
rev #873: Removed SQLite connection editor from UI.Windows project.
rev #872: Added separate projects for SQLite functionality.
rev #870: Changes to allow code to compile without resource files.
rev #859: Added Any CPU target.
我添加了一个名为HEAD
的人工标签,以确保所有日志条目都存在,但您可以轻松删除它并忽略它。
代码在这里:WebSVN repository for above example code。
我将其更改为输出xml,其格式与原始svn log --xml
的格式相同,存储库中的代码具有这些更改,输出现在如下所示:
<?xml version="1.0" ?>
<tags>
...
<tag revision="8"> --+
<logentry revision="8"> --+ |
<author> | |
lassevk | |
</author> | |
<date> | |
2007-12-08T20:36:18.730377Z +-- from tags.xml |
</date> | |
<msg> | |
Created folder remotely | |
</msg> | |
</logentry> --+ |
<revisions> +-- repeated
<logentry revision="7"> --+ | for each
<author> | | tag
lassevk | |
</author> | |
<date> | |
2007-12-08T20:36:14.324041Z +-- from trunk.xml |
</date> | repeated for each |
<msg> | revision |
Created folder remotely | |
</msg> | |
</logentry> --+ |
</revisions> |
</tag> --+
</tags>
每个<tag...>
节点都有一个<logentry...>
子节点,它是标记xml日志中的标记日志条目,然后是节点<revisions>
,其中所有子节点都是相关的日志条目来自trunk xml log。