以下示例展示了模板文件中的关键字如何在输出文件中被替换。
// Test file for SubWCRev char *Revision = "$WCREV$"; char *Revision16 = "$WCREV&0xFF$"; char *Revisionp100 = "$WCREV+100$"; char *Revisionm100 = "$WCREV-100$"; char *Modified = "$WCMODS?Modified:Not modified$"; char *Unversioned = "$WCUNVER?Unversioned items found:no unversioned items$"; char *Date = "$WCDATE$"; char *CustDate = "$WCDATE=%a, %d %B %Y$"; char *DateUTC = "$WCDATEUTC$"; char *CustDateUTC = "$WCDATEUTC=%a, %d %B %Y$"; char *TimeNow = "$WCNOW$"; char *TimeNowUTC = "$WCNOWUTC$"; char *RevRange = "$WCRANGE$"; char *Mixed = "$WCMIXED?Mixed revision WC:Not mixed$"; char *ExtAllFixed = "$WCEXTALLFIXED?All externals fixed:Not all externals fixed$"; char *IsTagged = "$WCISTAGGED?Tagged:Not tagged$"; char *URL = "$WCURL$"; char *isInSVN = "$WCINSVN?versioned:not versioned$"; char *needslck = "$WCNEEDSLOCK?TRUE:FALSE$"; char *islocked = "$WCISLOCKED?locked:not locked$"; char *lockdateutc = "$WCLOCKDATEUTC$"; char *lockdate = "$WCLOCKDATE$"; char *lockcustutc = "$WCLOCKDATEUTC=%a, %d %B %Y$"; char *lockcust = "$WCLOCKDATE=%a, %d %B %Y$"; char *lockown = "$WCLOCKOWNER$"; char *lockcmt = "$WCLOCKCOMMENT$"; #if $WCMODS?1:0$ #error Source is modified #endif // End of file
运行 SubWCRev.exe path\to\workingcopy testfile.tmpl testfile.txt
后,输出文件 testfile.txt
将如下所示
// Test file for SubWCRev char *Revision = "22837"; char *Revision16 = "53"; char *Revisionp100 = "22937"; char *Revisionm100 = "22737"; char *Modified = "Modified"; char *Unversioned = "no unversioned items"; char *Date = "2012/04/26 18:47:57"; char *CustDate = "Thu, 26 April 2012"; char *DateUTC = "2012/04/26 16:47:57"; char *CustDateUTC = "Thu, 26 April 2012"; char *TimeNow = "2012/04/26 20:51:17"; char *TimeNowUTC = "2012/04/26 18:51:17"; char *RevRange = "22836:22837"; char *Mixed = "Mixed revision WC"; char *ExtAllFixed = "All externals fixed"; char *IsTagged = "Not tagged"; char *URL = "https://svn.code.sf.net/p/tortoisesvn/code/trunk"; char *isInSVN = "versioned"; char *needslck = "FALSE"; char *islocked = "not locked"; char *lockdateutc = "1970/01/01 00:00:00"; char *lockdate = "1970/01/01 01:00:00"; char *lockcustutc = "Thu, 01 January 1970"; char *lockcust = "Thu, 01 January 1970"; char *lockown = ""; char *lockcmt = ""; #if 1 #error Source is modified #endif // End of file
这样的文件将包含在构建中,因此您应该期望它被版本化。请确保对模板文件进行版本控制,而不是对生成的版本文件进行版本控制,否则每次重新生成版本文件时都需要提交更改,这反过来意味着版本文件需要更新。