COM 接口

如果你需要在其它程序中访问 Subversion 版本信息,可以使用 SubWCRev 的 COM 接口。创建的对象名称是 SubWCRev.object,支持下述方法:

表 6.3. 支持 COM/自动化 方法

方法描述
.GetWCInfoThis method traverses the working copy gathering the revision information. Naturally you must call this before you can access the information using the remaining methods. The first parameter is the path. The second parameter should be true if you want to include folder revisions. Equivalent to the -f command line switch. The third parameter should be true if you want to include svn:externals. Equivalent to the -e command line switch.
.Revision工作副本中的最高提交版本。等价于 $WCREV$
.Date最高提交版本的提交日期/时间。等价于 $WCDATE$
.Author最高提交版本的作者,也就是工作副本中最后提交修改的人。
.MinRev最小的更新版本,在 $WCRANGE$ 中描述
.MaxRev最大的更新版本,在 $WCRANGE$ 中描述
.HasModifications若本地存在修改,就为真
.UrlGetWCInfo 中使用,用工作副本的版本库之 URL 替换。等价于 $WCURL$


下述例子显示了如何使用接口。

// testCOM.js - javascript file
// test script for the SubWCRev COM/Automation-object

filesystem = new ActiveXObject("Scripting.FileSystemObject");

SubWCRev1 = new ActiveXObject("SubWCRev.object");
SubWCRev2 = new ActiveXObject("SubWCRev.object");
SubWCRev3 = new ActiveXObject("SubWCRev.object");

SubWCRev1.GetWCInfo(filesystem.GetAbsolutePathName("."), 0, 0);
SubWCRev2.GetWCInfo(filesystem.GetAbsolutePathName(".."), 1, 1);
SubWCRev3.GetWCInfo(filesystem.GetAbsolutePathName("SubWCRev.cpp"), 
                    0, 0);

sInfo1 = "Revision = " + SubWCRev1.Revision + 
         "\nMin Revision = " + SubWCRev1.MinRev +
         "\nMax Revision = " + SubWCRev1.MaxRev +
         "\nDate = " + SubWCRev1.Date +
         "\nURL = " + SubWCRev1.Url +
         "\nAuthor = " + SubWCRev1.Author +
         "\nHasMods = " + SubWCRev1.HasModifications;
sInfo2 = "Revision = " + SubWCRev2.Revision +
         "\nMin Revision = " + SubWCRev2.MinRev +
         "\nMax Revision = " + SubWCRev2.MaxRev +
         "\nDate = " + SubWCRev2.Date +
         "\nURL = " + SubWCRev2.Url +
         "\nAuthor = " + SubWCRev2.Author +
         "\nHasMods = " + SubWCRev2.HasModifications;
sInfo3 = "Revision = " + SubWCRev3.Revision +
         "\nMin Revision = " + SubWCRev3.MinRev +
         "\nMax Revision = " + SubWCRev3.MaxRev +
         "\nDate = " + SubWCRev3.Date +
         "\nURL = " + SubWCRev3.Url +
         "\nAuthor = " + SubWCRev3.Author +
         "\nHasMods = " + SubWCRev3.HasModifications;

WScript.Echo(sInfo1);
WScript.Echo(sInfo2);
WScript.Echo(sInfo3);