Contoh dibawah memperlihatkan bagaimana kata kunci dalam file template diganti dalam file output.
// 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
After running SubWCRev.exe path\to\workingcopy testfile.tmpl testfile.txt
, the output file testfile.txt
would looks like this:
// 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
A file like this will be included in the build so you would expect it to be versioned. Be sure to version the template file, not the generated file, otherwise each time you regenerate the version file you need to commit the change, which in turn means the version file needs to be updated.