Item10307: First save of files without rcs ,v file fails to create a new revision

Priority: Urgent
Current State: Closed
Released In: 1.1.3
Target Release: patch
Applies To: Engine
Component: Store
Reported By: GeorgeClark
Waiting For:
Last Change By: KennethLavrsen
For any topic shipped with Foswiki, we don't ship the RCS ,v file. If a user saves changes to the file, Store creates the rcs file as "rev 1" and the changes are combined with the original shipped file. This makes it impossible to revert changes back to the original shipped version. This was first detected because it was not possible to roll back changes to AdminGroup, and it was first interpreted as an issue with the Group UI.

Adding or removing group members using the UI fails to rev. the topic in RCS.

One line change to TopicUserMapping::_writeGroupTopic - add forcenewrevision.
   $groupTopicObject->saveAs( $groupWeb, $groupName, -author => $user, forcenewrevision => 1 );

-- GeorgeClark - 01 Feb 2011

The initial install creates the AdminGroup topic without doing a checkin. So there is no revision history to start. The first addition of a user to AdminGroup creates the rcs .txt,v file, but all changes become learned as revision 1 and cannot be reverted. Once the { ReplaceIfEditedAgainWithin} timeout has expired, the next addition creates revision 2.

By adding the forcenewrevision option, only the first change cannot be reverted. Each subsequent change creates a new revision. So this issue is a more generic problem in that a missing .txt,v file results in the first save becoming the base revision with no way to revert to the original version.

-- GeorgeClark - 02 Feb 2011

Evil. I would class this as a clear bug - and the fact that it impacts the admin user as making it Urgent, so I have confirmed it. Whatever the fix is, it should be entirely in the Foswiki::Store::VC implementation.

-- CrawfordCurrie - 05 Feb 2011

I think I have a fix for this. There are a couple of side effects, but the critical issue of unable to revert a change has been fixed.

  • Store Meta and Func unit tests pass without errors, and without changes
  • Topic history now shows "r0" if no rcs file exists, however topic revision shows whatever is in the TOPICINFO metadata.
  • Saving a topic with a missing rcs file Creates rev 2 of the file, checking in both r1 and r2, so the initial change is recorded, and can be backed out.
  • But the TOPICINFO rev is set back in time to r2. So if a topic is at r5 and the rcs file is removed, history shows r0, next save, topic becomes r2 and history r2 > r1.
    • It might be better to not loose the fact that there was history, even though the history is removed. In which case, the TOPICINFO rev should become the initial revision,
  • The History dialog works backwards from the TOPICINFO and not the rcs available rev. So when the rcs file is removed, HISTORY will show up to 10 identical revisions counting backwards from the TOPICINFO revision number.
    • The revisions shown, for example 4, 3, 2 and 1, all actually display rev4.

diff --git a/core/lib/Foswiki/Store/VC/ b/core/lib/Foswiki/Store/VC/
index b4010d8..cdc7862 100644
--- a/core/lib/Foswiki/Store/VC/
+++ b/core/lib/Foswiki/Store/VC/
@@ -265,7 +265,7 @@ sub getRevisionHistory {
     ASSERT( $this->{file} ) if DEBUG;
     unless ( -e $this->{rcsFile} ) {
         if ( -e $this->{file} ) {
-            return new Foswiki::ListIterator( [1] );
+            return new Foswiki::ListIterator( [0] );
         else {
             return new Foswiki::ListIterator( [] );
@@ -302,7 +302,8 @@ ID into TOPICINFO before the revision is actually created.
 sub getNextRevisionID {
     my $this = shift;
-    return ( $this->numRevisions() || 0 ) + 1;
+    return ( $this->numRevisions() || ( ( -e $this->{file} ) ? 1 : 0 ) ) + 1 ;

-- GeorgeClark - 26 Feb 2011

I am not sure this change is for the better.

The only files that are distributed without the ,v files are the distributed files and they should be shown as rev 1 as they have always been.

I can understand the argument that you will want the first edit to be 2 and not 1 so you can revert a mistake in the browser.

But if you have a rev 10 and remove the ,v file, the next saved topic revision should revert back to starting all over again. It is awful to have 10 pseudo revisions.

It is often that I copy a number of old topics in the file system from one web to a new web has a pure hack to start a new web with a reused wiki application. And then I ommit the .txt files to get a fresh start.

So I prefer that the first topic edit is rev 2 when I save a topic the first time AND there is no ,v file.

-- KennethLavrsen - 28 Feb 2011

ItemTemplate edit

Summary First save of files without rcs ,v file fails to create a new revision
ReportedBy GeorgeClark
Codebase 1.1.2, 1.1.1, 1.1.0, trunk
SVN Range
AppliesTo Engine
Component Store
Priority Urgent
CurrentState Closed
Checkins distro:926681df0652 distro:a637256911cc distro:8b759187892e distro:eea1e69d0c66
TargetRelease patch
ReleasedIn 1.1.3
Topic revision: r13 - 16 Apr 2011, KennethLavrsen - This page was cached on 15 Feb 2018 - 19:44.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License