Tags:
create new tag
view all tags

Question

  • TWiki version: 20030201
  • Perl version: 5.8
  • Web server & version: 1.3
  • Server OS: Solaris 2.6
  • Web browser & version: Opera 7.01
  • Client OS: Windows 2000

Note: There is a topic (bug report) with exactly the same name in the codev web, which is marked as fixed, but please help me with this...

What I want to do is: Write a Style Guide for our java development team in Twiki. Therefore, I defined some default file headers that contain CVS tags. I write $Id:$ but after saving the topic twiki makes this:

$Id: ExpandsRcsKeywordsInText.txt,v 1.9 2004/05/05 06:01:43 PeterThoeny Exp nobody $

$Author: PeterThoeny $

I certainly do not want that Twiki (or some tool it uses) expands them, because the developers shall copy and paste them to their IDE.

How to do it? What I tried is

  • Upgrade to the current stable version of Twiki (no difference, CVS keywords are still expanded)
  • Try $<nop>Id: $ (does not work because my code fragments are in <verbatim> blocks)
  • Edit TWiki.cfg: set rcsArg to "-kv", as it was recommended in the mentioned bug report (this broke the Save Topic functionality)
  • Edit TWiki.cfg: added "-ko" to coCmd (no difference)

I do not want to use -kv whith rcs checkout, because it would make my CVS tags vanish...

And I have no idea how to suppress the lines that are added below every Log keyword.

Please point out what I can do to achieve the needed functionality (a "RTFM" would be fine)

Thanks for your help, Christian.

-- ChristianFroehler - 31 Mar 2003

Answer

I just re-tested this on TWiki.org (Feb 2003 release) over on Codev.ExpandsRcsKeywordsInText and it works fine. Try doing a diff between the default TWiki.cfg in Feb 2003 release and your TWiki.cfg to ensure that you have -ko everywhere it's needed - see $keywordMode in TWiki.cfg and make sure it is in all commands used in the default config file (e.g. ci command as well as co, since TWiki does a ci -l.)

-- RichardDonkin - 01 Apr 2003

Thank you for taking a look at my problem... Only the problem really exists. As you suggested, I made a diff between my cusomized TWiki.cfg and the one from the distribution (only the server names are replaced by <myserver>).

62c62
< $defaultUrlHost   = "http://your.domain.com";
---
> $defaultUrlHost   = "http://<myserver>.de";
68c68
< $pubDir           = "/home/httpd/twiki/pub";
---
> $pubDir           = "/home2/twiki/pub";
70c70
< $templateDir      = "/home/httpd/twiki/templates";
---
> $templateDir      = "/home2/twiki/templates";
72c72
< $dataDir          = "/home/httpd/twiki/data";
---
> $dataDir          = "/home2/twiki/data";
161c161
< $mailProgram      = "/usr/sbin/sendmail -t -oi -oeq";
---
> $mailProgram      = "/usr/lib/sendmail -t -oi -oeq";
170c170
< $rcsDir           = '/usr/bin';         # Unix, Linux and Cygwin
---
> $rcsDir           = '/usr/local/bin';         # Unix, Linux and Cygwin
305c305
< $wikiHomeUrl      = "http://your.domain.com/twiki";
---
> $wikiHomeUrl      = "http://<myserver>/twiki/";

The problem exists also on twiki.org, as you can see on this page (I suppose twiki.org uses the february2003 release): You can see the name RichardDonkin in the lines under the Log RCS keyword.

And if you would take a look at the revision history of Codev.ExpandsRcsKeywordsInText : you can see that the various CVS/RCS Tags like $Id:$ etc. are actually expanded (for example, you can see the current version number 1.16 in various places in the document) Note that in "preview" everything seems to work fine, the keywords are only expanded after saving the topic.

I'm sorry to say so, but the proof of the bugfix you made on Codev.ExpandsRcsKeywordsInText is incomplete, because the RCS-Keyword you use is $Id $ but the real RCS-Keyword is $Id:$ which will be expanded:

I also suspected that I use an old RCS version, but it is 5.7, as is stated in "Server Requirements" in the Twiki Documentation.

Workaround

I found out that i can use <pre> HTML-Tags instead of <verbatim> Twiki Tags; then using $<nop>Id$ looks o.k. on the displayed page; this works, but i have seen things that are more beautiful smile

-- ChristianFroehler - 01 Apr 2003

Thanks for spotting this - as you point out, the fix as committed to TWikiAlphaRelease a while back never worked!

Try editing TWiki.cfg to have the following line:

    ciCmd         => "$rcsDir/ci $rcsArg -q -l $keywordMode -m$cmdQuote%COMMENT%$cmdQuote -t-none -w$cmdQuote%USERNAME%$cmdQuote %FILENAME%",

This includes the crucial $keywordMode variable, which does seem to fix this bug as intended - tested at http://donkin.org/bin/view/Test/TestTopic8. Let me know if this works for you and I'll fix in TWikiAlphaRelease for CairoRelease.

-- RichardDonkin - 02 Apr 2003

I modified TWiki.cfg as you suggested. It seemed to work on the first try; the preview again works fine, and after saving the topic the keywords are not expanded.

But I tried to edit the topic again, and the changes were lost in a very strange manner: I could see the changes, but in the Diff-History, they do not appear. I also tried this on your site http://donkin.org/bin/view/Test/TestTopic8

The ciCmd you suggested has no $endRcsCmd at the end, as all the other Rcs-Commands have. I added this and now I use the following line:

    ciCmd         => "$rcsDir/ci $rcsArg -q -l $keywordMode -m$cmdQuote%COMMENT%$cmdQuote -t-none -w$cmdQuote%USERNAME%$cmdQuote %FILENAME% $endRcsCmd",

Now, after saving a topic, i see the error message:

Topic save error 
During save of file Test.TestTopic3 an error was found by the version control system. Please notify your TWiki administrator. /usr/local/bin/ci -q -l -ko -m'none' -t-none -w'ChristianFroehler' /home2/twiki/data/Test/TestTopic3.txt 2>&1
ci: /home2/twiki/data/Test/TestTopic3.txt,v: Symbolic name `o' is undefined.

Go back in your browser and save your changes locally. 

Interesting thing... after reading some rcs man pages and mailing list archive, and playing around, i found out:

  • ci is evil. After committing a change, it does a checkout. For this implicit checkout, it is impossible to give the -k option, because -k has a different meaning with ci.
  • The implicit checkout of ci after commiting a file takes the default keyword substitution rules. Those default rules can be manipulated
    • at creation time: rcs -i -ko filename.txt
    • with existing files: rcs -ko filename.txt

I would suggest to change the way of creating topics. Instead of creating a plain text file, and after that doing a ci:

  • Create a rcs file: rcs -i -ko filename.txt
  • Do a co for this file: co -l filename.txt (Note that the -ko Parameter is not necessary)
  • After that, continue the same way as before (edit file contents, do ci etc.)

Doing this, the RCS keywords will never be expanded.

Example session:

#rcs -i -ko test.txt
RCS file: test.txt,v
enter description, terminated with single '.' or end of file:
NOTE: This is NOT the log message!
>> .
done
#co -l test.txt
test.txt,v  -->  test.txt
no revisions present; generating empty revision 0.0
co: warning: no revisions, so nothing can be locked
done
#vi test.txt
#cat test.txt
Some RCS keyword: $Header: /home/twiki/data/Support/ExpandsRcsKeywordsInText.txt,v 1.9 2004/05/05 06:01:43 PeterThoeny Exp nobody $
#ci -l test.txt  
test.txt,v  <--  test.txt
initial revision: 1.1
done
#cat test.txt
Some RCS keyword: $Header: /home/twiki/data/Support/ExpandsRcsKeywordsInText.txt,v 1.9 2004/05/05 06:01:43 PeterThoeny Exp nobody $
#           

oh no... it worked fine, but twiki's rcs expands the keyword in my example... frown I will attach a file.

oh no(2)... the keywords are also expanded in file attachments. Now I don't know...

Note: I removed the annoying $Log:$ keywords in the upper part of this topic.

-- ChristianFroehler - 02 Apr 2003

Thanks for doing this research, the ci command -ko option obviously doesn't work as I thought it would. There will be a slight performance impact from solving this bug, but as long as it's on initial topic creation it should be quite minimal - just running an extra rcs command to create the topic rather than relying on ci -l. A similar rcs command is already done for binary attachments - may be necessary to do this for textual attachments that include ID keywords.

Fortunately there is no impact on RcsLite since this always works in -ko mode. In fact, a simple way to solve this bug is to just turn on RcsLite, although it still needs more testing to be really production ready. However, this should really be fixed in the core code for the majority of TWiki sites, which use RCS.

To fix this, a new $initTopicCmd variable should be defined for the rcs -ko command, and CVS:lib/TWiki/Store/RcsWrap.pm modified so that the _ci routine runs that command first if it detects that the topic's RCS file does not exist (note that this can be complicated if the file is in a subdirectory, which is possible in some setups). There'll also need to be a new $coLockedCmd to be used in this case. The $initBinaryCmd code may be re-usable for the first part although it uses -kb so best used for binaries.

-- RichardDonkin - 03 Apr 2003

Thank you for the support, which is far better than the support for any commercial product i use.

I'm not sure if $coLockedCmd is necessary -- maybe it is enough to do a rcs -i -ko filename.txt before the first ci. For my purpose, I found a real workaround which works until the patch is released (I will post it also to Codev.ExpandsRcsKeywordsInText).

Workaround

This workaround prevents RCS keywords like $Id:$ or $Log:$ being expanded by the Version Control System that Twiki uses.

What it does not do:

  • It does not treat the expanding of RCS keywords in newly created topics; the steps described below have to be re-executed for every new topic that contains RCS keywords which shall not be expanded.
  • RCS keywords in appended text files are also expanded, which is not addressed by this workaround.

Follow these steps:

  • Make a backup of the TWiki installation
  • On the server open a terminal window and go to the directory that contains the topics (usually data/Name_Of_Your_Twiki_Web).
  • Execute rcs -ko *.txt
  • Now RCS keywords will not expanded when saving an existing topic.

-- ChristianFroehler - 03 Apr 2003

Topic attachments
I Attachment History Action Size Date Who Comment
Texttxt examplesession.txt r1 manage 0.5 K 2003-04-02 - 12:29 UnknownUser Example: use of rcs -i -kv
Edit | Attach | Watch | Print version | History: r9 < r8 < r7 < r6 < r5 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r9 - 2004-05-05 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.