Changeset 12494


Ignore:
Timestamp:
09/10/11 08:24:51 (21 months ago)
Author:
CrawfordCurrie
Message:

Item11091: deep RCS store changes to support the .txt as a latest revision in the history. With these changes, the core does not need to know anything about topic caches or rev numbers other than positive integers and 0 (for a non-existent topic).

Location:
trunk/core
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/core/data/TestCases/TestCaseAutoFormattedSearch.txt

    r8124 r12494  
    8383 
    8484---++ Expected 
     85_Note that the .txt says it is rev 4, but because there is no ,v to back this up 
     86it is treated as rev 1_ 
    8587 
    8688<!-- expected with $parent --> 
    87 Revision 4 has parent <nop>TestCaseAutoFormattedSearch and it contains the form <nop>FormattedSearchForm 
     89Revision 1 has parent <nop>TestCaseAutoFormattedSearch and it contains the form <nop>FormattedSearchForm 
    8890<!-- /expected --> 
    8991 
  • trunk/core/lib/Foswiki/Store.pm

    r12475 r12494  
    444444   * =$attachment= - name of an attachment (optional) 
    445445Get an iterator over the list of revisions of the object. The iterator returns 
    446 the revision identifiers (which will usually be numbers) starting with the most recent revision. 
     446the revision identifiers (which will usually be numbers) starting with the most 
     447recent revision. 
    447448 
    448449MUST WORK FOR ATTACHMENTS AS WELL AS TOPICS 
     450 
     451If the object does not exist, returns an empty iterator ($iterator->hasNext() will be 
     452false). 
    449453 
    450454=cut 
  • trunk/core/lib/Foswiki/Store/VC/Handler.pm

    r12248 r12494  
    205205 
    206206Designed to be overridden by subclasses, which can call up to this method 
    207 if file-based rev info is required. 
     207if simple file-based rev info is required. 
    208208 
    209209=cut 
    210210 
    211211sub getInfo { 
    212     my $this = shift; 
     212    my $this = shift; # $version is not useful here, as we have no way to record history 
    213213 
    214214    # SMELL: this is only required for the constant 
    215215    require Foswiki::Users::BaseUserMapping; 
    216216 
    217     # If a topic file exists, grab the TOPICINFO from it. This is 
    218     # the default behaviour if no implementing class can come up 
    219     # with a better answer. Note that we only peek at the first line 
    220     # of the file, which is where a "proper" save will have left the tag. 
     217    # We only arrive here if the implementation getInfo can't serve the info; this 
     218    # will usually be because the ,v is missing or the topic cache is newer. 
     219 
     220    # If there is a .txt file, grab the TOPICINFO from it. 
     221    # Note that we only peek at the first line of the file, 
     222    # which is where a "proper" save will have left the tag. 
    221223    my $info = {}; 
    222224    my $f; 
    223     if ( open( $f, '<', $this->{file} ) ) { 
    224         local $/ = "\n"; 
    225         my $ti = <$f>; 
    226         close($f); 
    227         if ( defined $ti && $ti =~ /^%META:TOPICINFO{(.*)}%/ ) { 
    228             require Foswiki::Attrs; 
    229             my $a = Foswiki::Attrs->new($1); 
    230  
    231             # Default bad revs to 1, not 0, because this is coming from 
    232             # a topic on disk, so we know it's a "real" rev. 
    233             $info->{version} = Foswiki::Store::cleanUpRevID( $a->{version} ) 
    234               || 1; 
    235             $info->{date}    = $a->{date}    if defined $a->{date}; 
    236             $info->{author}  = $a->{author}  if defined $a->{author}; 
    237             $info->{comment} = $a->{comment} if defined $a->{comment}; 
    238         } 
    239     } 
    240  
    241     # version, date, author and comment fields *must* be defined 
     225    if ( $this->noCheckinPending() ) { 
     226        # TOPICINFO may be OK 
     227        if ( open( $f, '<', $this->{file} ) ) { 
     228            local $/ = "\n"; 
     229            my $ti = <$f>; 
     230            close($f); 
     231            if ( defined $ti && $ti =~ /^%META:TOPICINFO{(.*)}%/ ) { 
     232                require Foswiki::Attrs; 
     233                my $a = Foswiki::Attrs->new($1); 
     234                 
     235                # Default bad revs to 1, not 0, because this is coming from 
     236                # a topic on disk, so we know it's a "real" rev. 
     237                $info->{version} = Foswiki::Store::cleanUpRevID( $a->{version} ) 
     238                    || 1; 
     239                $info->{date}    = $a->{date}; 
     240                $info->{author}  = $a->{author}; 
     241                $info->{comment} = $a->{comment}; 
     242            } 
     243        } 
     244    } else { 
     245        # There is a checkin pending. We need the latest rev in the history + 1 
     246        $info->{version} = -e $this->{rcsFile} ? $this->_numRevisions() + 1 : 1; 
     247        $info->{comment} = "pending"; 
     248    } 
     249    $info->{date} = $this->getTimestamp() unless defined $info->{date}; 
    242250    $info->{version} = 1 unless defined $info->{version}; 
    243     $info->{date} = $this->getTimestamp() unless defined $info->{date}; 
    244     $info->{author} = $Foswiki::Users::BaseUserMapping::DEFAULT_USER_CUID 
    245       unless defined $info->{author}; 
    246     $info->{comment} = '' 
    247       unless defined $info->{comment}; 
     251    $info->{comment} = '' unless defined $info->{comment}; 
     252    $info->{author} ||= $Foswiki::Users::BaseUserMapping::UNKNOWN_USER_CUID; 
    248253    return $info; 
     254} 
     255 
     256# Check to see if there is a newer non-,v file waiting to be checked in. If there is, then 
     257# all rev numbers have to be incremented, as they will auto-increment when it is finally 
     258# checked in (usually as the result of a save). This is also used to test the validity of 
     259# TOPICINFO, as a pending checkin does not contain valid TOPICINFO. 
     260sub noCheckinPending { 
     261    my $this = shift; 
     262    my $isValid = 0; 
     263 
     264    if (! -e $this->{file}) { 
     265        $isValid = 1; # Hmmmm...... 
     266    } else { 
     267        if (-e $this->{rcsFile}) { 
     268            # Check the time on the rcs file; is the .txt newer? 
     269            # Danger, Will Robinson! stat isn't reliable on all file systems, though [9] is claimed to be OK 
     270            # See perldoc perlport for more on this. 
     271            local ${^WIN32_SLOPPY_STAT} = 1; # don't need to open the file on Win32 
     272            my $rcsTime = (stat($this->{rcsFile}))[9]; 
     273            my $fileTime = (stat($this->{file}))[9]; 
     274            $isValid = ($rcsTime < $fileTime) ? 0 : 1; 
     275        } 
     276    } 
     277    return $isValid; 
     278} 
     279 
     280# Must be implemented by subclasses 
     281sub ci { 
     282    die "Pure virtual method"; 
     283} 
     284 
     285# Protected for use only in subclasses. Check that the object has a history 
     286# and the .txt is consistent with that history. 
     287sub _saveDamage { 
     288    my $this = shift; 
     289    return if $this->noCheckinPending(); 
     290 
     291    # the version in the TOPICINFO may not be correct. We need 
     292    # to check the change in and update the TOPICINFO accordingly 
     293    my $t = $this->readFile($this->{file}); 
     294 
     295    # If this is a topic, adjust the TOPICINFO 
     296    if (defined $this->{topic} && !defined $this->{attachment}) { 
     297        my $rev = -e $this->{rcsFile} ? $this->getLatestRevisionID() : 1; 
     298        $t =~ s/^%META:TOPICINFO{(.*)}%$//m; 
     299        $t = '%META:TOPICINFO{author="' 
     300            . $Foswiki::Users::BaseUserMapping::UNKNOWN_USER_CUID. 
     301            '" comment="autosave" date="' .time().'" format="1.1" version="' 
     302            .$rev.'"}%'."\n$t"; 
     303    } 
     304    $this->ci( 0, 
     305        $t, 'autosave', 
     306        $Foswiki::Users::BaseUserMapping::UNKNOWN_USER_CUID, time()); 
     307} 
     308 
     309=begin TML 
     310 
     311---++ ObjectMethod addRevisionFromText($text, $comment, $cUID, $date) 
     312 
     313Add new revision. Replace file with text. 
     314   * =$text= of new revision 
     315   * =$comment= checkin comment 
     316   * =$cUID= is a cUID. 
     317   * =$date= in epoch seconds; may be ignored 
     318 
     319=cut 
     320 
     321sub addRevisionFromText { 
     322    my ( $this, $text, $comment, $user, $date ) = @_; 
     323    $this->init(); 
     324    # Commit any out-of-band damage to .txt 
     325    $this->_saveDamage(); 
     326    $this->ci( 0, $text, $comment, $user, $date ); 
     327} 
     328 
     329=begin TML 
     330 
     331---++ ObjectMethod addRevisionFromStream($fh, $comment, $cUID, $date) 
     332 
     333Add new revision. Replace file with contents of stream. 
     334   * =$fh= filehandle for contents of new revision 
     335   * =$cUID= is a cUID. 
     336   * =$date= in epoch seconds; may be ignored 
     337 
     338=cut 
     339 
     340sub addRevisionFromStream { 
     341    my ( $this, $stream, $comment, $user, $date ) = @_; 
     342    $this->init(); 
     343 
     344    # Commit any out-of-band damage to .txt 
     345    $this->_saveDamage(); 
     346 
     347    $this->ci( 1, $stream, $comment, $user, $date ); 
     348} 
     349 
     350=begin TML 
     351 
     352---++ ObjectMethod replaceRevision($text, $comment, $cUID, $date) 
     353 
     354Replace the top revision. 
     355   * =$text= is the new revision 
     356   * =$date= is in epoch seconds. 
     357   * =$cUID= is a cUID. 
     358   * =$comment= is a string 
     359 
     360=cut 
     361 
     362sub replaceRevision { 
     363    my $this = shift; 
     364    $this->_saveDamage(); 
     365    $this->repRev(@_); 
     366} 
     367 
     368# Signature as for replaceRevision 
     369sub repRev { 
     370    die "Pure virtual method"; 
    249371} 
    250372 
     
    257379 
    258380The default is to return an iterator from the current version number 
    259 down to 1.   Return rev 0 if the file exists without history. 
     381down to 1.   Return rev 1 if the file exists without history. Return 
     382an empty iterator if the file does not exist. 
    260383 
    261384=cut 
     
    267390        require Foswiki::ListIterator; 
    268391        if ( -e $this->{file} ) { 
    269             return Foswiki::ListIterator->new( [0] ); 
     392            return Foswiki::ListIterator->new( [1] ); 
    270393        } 
    271394        else { 
     
    289412 
    290413sub getLatestRevisionID { 
    291     return shift->numRevisions() || 1; 
     414    my $this = shift; 
     415    return 0 unless -e $this->{file}; 
     416    my $rev = $this->_numRevisions() || 1; 
     417    # If there is a pending pseudo-revision, need n+1, but only if there is 
     418    # an existing history 
     419    $rev++ unless $this->noCheckinPending() || !-e $this->{rcsFile}; 
     420    return $rev; 
    292421} 
    293422 
     
    308437sub getNextRevisionID { 
    309438    my $this = shift; 
    310     return ( $this->numRevisions() || ( ( -e $this->{file} ) ? 1 : 0 ) ) + 1; 
     439    return $this->getLatestRevisionID() + 1; 
    311440} 
    312441 
     
    363492 
    364493    # Rev numbers run from 1 to numRevisions 
    365     return $rev && $rev <= $this->numRevisions(); 
     494    return $rev && $rev <= $this->_numRevisions(); 
    366495} 
    367496 
     
    454583    return 0 unless $this->{file}; 
    455584    return -e $this->{file}; 
    456 } 
    457  
    458 =begin TML 
    459  
    460 ---++ ObjectMethod getTimestamp() -> $integer 
    461  
    462 Get the timestamp of the file 
    463 Returns 0 if no file, otherwise epoch seconds 
    464  
    465 =cut 
    466  
    467 sub getTimestamp { 
    468     my ($this) = @_; 
    469     ASSERT( $this->{file} ) if DEBUG; 
    470  
    471     my $date = 0; 
    472     if ( -e $this->{file} ) { 
    473  
    474         # If the stat fails, stamp it with some arbitrary static 
    475         # time in the past (00:40:05 on 5th Jan 1989) 
    476         $date = ( stat $this->{file} )[9] || 600000000; 
    477     } 
    478     return $date; 
    479585} 
    480586 
     
    12991405} 
    13001406 
     1407# ObjectMethod getTimestamp() -> $integer 
     1408# Get the timestamp of the file 
     1409# Returns 0 if no file, otherwise epoch seconds 
     1410# Used in subclasses 
     1411 
     1412sub getTimestamp { 
     1413    my ($this) = @_; 
     1414    ASSERT( $this->{file} ) if DEBUG; 
     1415 
     1416    my $date = 0; 
     1417    if ( -e $this->{file} ) { 
     1418 
     1419        # If the stat fails, stamp it with some arbitrary static 
     1420        # time in the past (00:40:05 on 5th Jan 1989) 
     1421        $date = ( stat $this->{file} )[9] || 600000000; 
     1422    } 
     1423    return $date; 
     1424} 
     1425 
    130114261; 
    13021427 
     
    13591484=begin TML 
    13601485 
    1361 ---++ ObjectMethod addRevisionFromText($text, $comment, $cUID, $date) 
    1362  
    1363 Add new revision. Replace file with text. 
    1364    * =$text= of new revision 
    1365    * =$comment= checkin comment 
    1366    * =$cUID= is a cUID. 
    1367    * =$date= in epoch seconds; may be ignored 
    1368  
    1369 *Virtual method* - must be implemented by subclasses 
    1370  
    1371 =begin TML 
    1372  
    1373 ---++ ObjectMethod addRevisionFromStream($fh, $comment, $cUID, $date) 
    1374  
    1375 Add new revision. Replace file with contents of stream. 
    1376    * =$fh= filehandle for contents of new revision 
    1377    * =$cUID= is a cUID. 
    1378    * =$date= in epoch seconds; may be ignored 
    1379  
    1380 *Virtual method* - must be implemented by subclasses 
    1381  
    1382 =cut 
    1383  
    1384 =begin TML 
    1385  
    1386 ---++ ObjectMethod replaceRevision($text, $comment, $cUID, $date) 
    1387  
    1388 Replace the top revision. 
    1389    * =$text= is the new revision 
    1390    * =$date= is in epoch seconds. 
    1391    * =$cUID= is a cUID. 
    1392    * =$comment= is a string 
    1393  
    1394 *Virtual method* - must be implemented by subclasses 
    1395  
    1396 =cut 
    1397  
    1398 =begin TML 
    1399  
    14001486---++ ObjectMethod deleteRevision() 
    14011487 
     
    14371523 
    14381524=cut 
    1439 __END__ 
     1525 
    14401526Foswiki - The Free and Open Source Wiki, http://foswiki.org/ 
    14411527 
  • trunk/core/lib/Foswiki/Store/VC/RcsLiteHandler.pm

    r12243 r12494  
    433433 
    434434# implements VC::Handler 
    435 sub numRevisions { 
     435sub _numRevisions { 
    436436    my ($this) = @_; 
    437437    _ensureProcessed($this); 
     
    445445} 
    446446 
    447 # implements VC::Handler 
    448 sub addRevisionFromText { 
    449     _addRevision( shift, 0, @_ ); 
    450 } 
    451  
    452 # implements VC::Handler 
    453 sub addRevisionFromStream { 
    454     _addRevision( shift, 1, @_ ); 
    455 } 
    456  
    457 sub _addRevision { 
     447sub ci { 
    458448    my ( $this, $isStream, $data, $log, $author, $date ) = @_; 
    459449 
    460450    _ensureProcessed($this); 
    461     if ( $this->{state} eq 'nocommav' && -e $this->{file} ) { 
    462  
    463         # Must do this *before* saving the attachment, so we 
    464         # save the file on disc 
    465         $this->{head} = 1; 
    466         $this->{revs}[1]->{text} = 
    467           Foswiki::Store::VC::Handler::readFile( $this, $this->{file} ); 
    468         $this->{revs}[1]->{log}    = $log; 
    469         $this->{revs}[1]->{author} = $author; 
    470         $this->{revs}[1]->{date}   = ( defined $date ? $date : time() ); 
    471         _writeMe($this); 
    472     } 
    473451 
    474452    if ($isStream) { 
     
    481459        $this->saveFile( $this->{file}, $data ); 
    482460    } 
    483  
    484     my $head = $this->{head}; 
     461    my $head = $this->{head} || 0; 
    485462    if ($head) { 
    486463        my $lNew  = _split($data); 
     
    517494 
    518495# implements VC::Handler 
    519 sub replaceRevision { 
     496sub repRev { 
    520497    my ( $this, $text, $comment, $user, $date ) = @_; 
    521498    _ensureProcessed($this); 
    522499    _delLastRevision($this); 
    523     return _addRevision( $this, 0, $text, $comment, $user, $date ); 
     500    return $this->ci( 0, $text, $comment, $user, $date ); 
    524501} 
    525502 
     
    573550 
    574551    _ensureProcessed($this); 
    575  
    576552    my $info; 
    577     if ( $this->{state} ne 'nocommav' ) { 
     553    if ( $this->{state} ne 'nocommav') { 
    578554        if ( !$version || $version > $this->{head} ) { 
    579555            $version = $this->{head} || 1; 
     
    585561            comment => $this->{revs}[$version]->{log} 
    586562        }; 
     563        # We have to check that there is not a pending version in the .txt 
     564        unless ($this->noCheckinPending()) { 
     565            # There's a pending version in the .txt 
     566            $info->{version}++; 
     567            $info->{author} = $Foswiki::Users::BaseUserMapping::UNKNOWN_USER_CUID; 
     568            $info->{comment} = "pending"; 
     569            $info->{date} = time(); 
     570        } 
    587571    } 
    588572    else { 
     
    773757    my ( $this, $date ) = @_; 
    774758 
    775     my $version = 1; 
    776  
    777759    _ensureProcessed($this); 
    778     $version = $this->{head}; 
     760    if ($this->{state} eq 'nocommav') { 
     761        return ($date >= (stat($this->{file}))[9]) ? 1 : undef; 
     762   } 
     763 
     764    my $version = $this->{head}; 
    779765    while ( $this->{revs}[$version]->{date} > $date ) { 
    780766        $version--; 
    781         return 0 if $version == 0; 
    782     } 
    783  
     767        return undef if $version == 0; 
     768    } 
     769 
     770    if ($version == $this->{head} && !$this->noCheckinPending()) { 
     771        # Check the file date 
     772        $version++ if ($date >= (stat($this->{file}))[9]); 
     773    } 
    784774    return $version; 
    785775} 
  • trunk/core/lib/Foswiki/Store/VC/RcsWrapHandler.pm

    r8604 r12494  
    102102 
    103103# implements VC::Handler 
    104 sub addRevisionFromText { 
     104 
     105# Designed for calling *only* from the Handler superclass and this class 
     106sub ci { 
     107    my ($this, $isStream, $data, $comment, $user, $date) = @_; 
     108#    unless ( -e $this->{rcsFile} ) {    # 
     109#                                        # SMELL: what is this for? 
     110#        _lock($this); 
     111#        _ci( $this, $comment, $user, $date ); 
     112#    } 
     113    _lock($this); 
     114    if ($isStream) { 
     115        $this->saveStream( $data ); 
     116    } else { 
     117        $this->saveFile( $this->{file}, $data ); 
     118    } 
     119    _ci( $this, $comment, $user, $date ); 
     120} 
     121 
     122# implements VC::Handler 
     123sub repRev { 
    105124    my ( $this, $text, $comment, $user, $date ) = @_; 
    106     $this->init(); 
    107  
    108     #print STDERR "Wrap: Forced save at $date $this->{file}\n" if $date; 
    109  
    110     unless ( -e $this->{rcsFile} ) {    # 
    111                                         # SMELL: what is this for? 
    112         _lock($this); 
    113         _ci( $this, $comment, $user, $date ); 
    114     } 
    115     Foswiki::Store::VC::Handler::saveFile( $this, $this->{file}, $text ); 
    116     _lock($this); 
    117     _ci( $this, $comment, $user, $date ); 
    118 } 
    119  
    120 # implements VC::Handler 
    121 sub addRevisionFromStream { 
    122     my ( $this, $stream, $comment, $user, $date ) = @_; 
    123     $this->init(); 
    124  
    125     _lock($this); 
    126     Foswiki::Store::VC::Handler::saveStream( $this, $stream ); 
    127     _ci( $this, $comment, $user, $date ); 
    128 } 
    129  
    130 # implements VC::Handler 
    131 sub replaceRevision { 
    132     my ( $this, $text, $comment, $user, $date ) = @_; 
    133  
    134     my $rev = $this->numRevisions() || 0; 
     125 
     126    my $rev = $this->_numRevisions() || 0; 
    135127 
    136128    $comment ||= 'none'; 
     
    168160sub deleteRevision { 
    169161    my ($this) = @_; 
    170     my $rev = $this->numRevisions(); 
     162    my $rev = $this->_numRevisions(); 
    171163    return if ( $rev <= 1 ); 
    172164    return _deleteRevision( $this, $rev ); 
     
    281273 
    282274# implements VC::Handler 
    283 sub numRevisions { 
    284     my $this = shift; 
    285  
    286     unless ( -e $this->{rcsFile} ) { 
    287  
    288         # If there is no history, there can only be one. 
    289         return 1 if -e $this->{file}; 
    290         return 0; 
    291     } 
    292  
    293     my ( $rcsOutput, $exit ) = 
    294       Foswiki::Sandbox->sysCommand( $Foswiki::cfg{RCS}{histCmd}, 
    295         FILENAME => $this->{rcsFile} ); 
    296     if ($exit) { 
    297         throw Error::Simple( 'RCS: ' 
    298               . $Foswiki::cfg{RCS}{histCmd} . ' of ' 
    299               . $this->hidePath( $this->{rcsFile} ) 
    300               . ' failed: ' 
    301               . $rcsOutput ); 
    302     } 
    303     if ( $rcsOutput =~ /head:\s+\d+\.(\d+)\n/ ) { 
    304         return $1; 
    305     } 
    306     if ( $rcsOutput =~ /total revisions: (\d+)\n/ ) { 
    307         return $1; 
    308     } 
    309     return 1; 
    310 } 
    311  
    312 # implements VC::Handler 
    313275sub getInfo { 
    314276    my ( $this, $version ) = @_; 
    315277 
    316     if ( -e $this->{rcsFile} ) { 
    317         if ( !$version || $version > $this->numRevisions() ) { 
    318             $version = $this->numRevisions(); 
     278    if ( $this->noCheckinPending() ) { 
     279        if ( !$version || $version > $this->_numRevisions() ) { 
     280            $version = $this->_numRevisions(); 
    319281        } 
    320282        my ( $rcsOut, $exit ) = Foswiki::Sandbox->sysCommand( 
     
    345307 
    346308# implements VC::Handler 
     309sub _numRevisions { 
     310    my $this = shift; 
     311 
     312    unless ( -e $this->{rcsFile} ) { 
     313 
     314        # If there is no history, there can only be one. 
     315        return 1 if -e $this->{file}; 
     316        return 0; 
     317    } 
     318 
     319    my ( $rcsOutput, $exit ) = 
     320      Foswiki::Sandbox->sysCommand( $Foswiki::cfg{RCS}{histCmd}, 
     321        FILENAME => $this->{rcsFile} ); 
     322    if ($exit) { 
     323        throw Error::Simple( 'RCS: ' 
     324              . $Foswiki::cfg{RCS}{histCmd} . ' of ' 
     325              . $this->hidePath( $this->{rcsFile} ) 
     326              . ' failed: ' 
     327              . $rcsOutput ); 
     328    } 
     329    if ( $rcsOutput =~ /head:\s+\d+\.(\d+)\n/ ) { 
     330        return $1; 
     331    } 
     332    if ( $rcsOutput =~ /total revisions: (\d+)\n/ ) { 
     333        return $1; 
     334    } 
     335    return 1; 
     336} 
     337 
     338# implements VC::Handler 
    347339# rev1 is the lower, rev2 is the higher revision 
    348340sub revisionDiff { 
     
    526518    my ( $this, $date ) = @_; 
    527519 
    528     if ( !-e $this->{rcsFile} ) { 
    529         return; 
    530     } 
     520    unless( -e $this->{rcsFile} ) { 
     521        return ($date >= (stat($this->{file}))[9]) ? 1 : undef; 
     522    } 
     523 
    531524    require Foswiki::Time; 
    532     $date = Foswiki::Time::formatTime( $date, '$rcs', 'gmtime' ); 
     525    my $sdate = Foswiki::Time::formatTime( $date, '$rcs', 'gmtime' ); 
    533526    my ( $rcsOutput, $exit ) = Foswiki::Sandbox->sysCommand( 
    534527        $Foswiki::cfg{RCS}{rlogDateCmd}, 
    535         DATE     => $date, 
     528        DATE     => $sdate, 
    536529        FILENAME => $this->{file} 
    537530    ); 
    538531 
     532    my $version = undef; 
    539533    if ( $rcsOutput =~ m/revision \d+\.(\d+)/ ) { 
    540         return $1; 
    541     } 
    542     return 1; 
     534        $version = $1; 
     535    } 
     536 
     537    if ($version && !$this->noCheckinPending()) { 
     538        # Check the file date 
     539        $version++ if ($date >= (stat($this->{file}))[9]); 
     540    } 
     541    return $version; 
    543542} 
    544543 
  • trunk/core/lib/Foswiki/Store/VC/Store.pm

    r12444 r12494  
    6363 
    6464# SMELL: this module does not respect $Foswiki::inUnitTestMode; tests 
    65 # just sit on top of the store which is configured in the current LocalSite. 
     65# just sit on top of the store which is configured in the current $Foswiki::cfg. 
    6666# Most of the time this is ok, as store listeners will be told that 
    6767# the store is in test mode, so caches should be unaffected. However 
     
    106106    $topicObject->setEmbeddedStoreForm($text); 
    107107 
     108    unless ($handler->noCheckinPending()) { 
     109        # If a checkin is pending, fix the TOPICINFO 
     110        my $ri = $topicObject->get('TOPICINFO'); 
     111        my $truth = $handler->getInfo($version); 
     112        for my $i qw(author version date) { 
     113            $ri->{$i} = $truth->{$i}; 
     114        } 
     115    } 
     116 
    108117    $gotRev = $version; 
    109118    unless ( defined $gotRev ) { 
    110119 
    111         # First try the just-loaded text for the revision 
     120        # First try the just-loaded for the revision. 
    112121        my $ri = $topicObject->get('TOPICINFO'); 
    113         if ( defined($ri) ) { 
    114  
    115             # SMELL: this can end up overriding a correct rev no (the one 
    116             # requested) with an incorrect one (the one in the TOPICINFO) 
    117             $gotRev = $ri->{version}; 
    118         } 
    119     } 
    120     if ( !$gotRev ) { 
     122        $gotRev = $ri->{version} if defined $ri; 
     123    } 
     124    if ( !defined $gotRev ) { 
    121125 
    122126        # No revision from any other source; must be latest 
     
    270274sub getRevisionHistory { 
    271275    my ( $this, $topicObject, $attachment ) = @_; 
    272      
     276 
    273277    my $itr = $this->askListenersRevisionHistory($topicObject, $attachment); 
    274278 
     
    333337    my $verb = ( $topicObject->existsInStore() ) ? 'update' : 'insert'; 
    334338 
     339    # just in case they are not sequential 
     340    my $nextRev = $handler->getNextRevisionID(); 
     341    my $ti = $topicObject->get('TOPICINFO'); 
     342    $ti->{version} = $nextRev; 
     343    $ti->{author} = $cUID; 
     344 
    335345    $handler->addRevisionFromText( $topicObject->getEmbeddedStoreForm(), 
    336346        'save topic', $cUID, $options->{forcedate} ); 
    337  
    338     # just in case they are not sequential 
    339     my $nextRev = $handler->getLatestRevisionID(); 
    340347 
    341348    my $extra = $options->{minor} ? 'minor' : ''; 
     
    351358    ASSERT( $topicObject->isa('Foswiki::Meta') ) if DEBUG; 
    352359    ASSERT($cUID) if DEBUG; 
    353  
    354360    my $info    = $topicObject->getRevisionInfo(); 
    355361    my $handler = $this->getHandler($topicObject); 
    356362    $handler->replaceRevision( $topicObject->getEmbeddedStoreForm(), 
    357         'reprev', $info->{author}, $info->{date} ); 
     363        'reprev', $cUID, $info->{date} ); 
    358364    my $rev = $handler->getLatestRevisionID(); 
    359365    $handler->recordChange( $cUID, $rev, 'minor, reprev' ); 
Note: See TracChangeset for help on using the changeset viewer.