mercurial/HGCachedFileData.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Tue, 05 Feb 2013 15:24:24 +0100
changeset 219 475366f8ba6f
parent 210 54a73fa50d40
child 335 7e19ab19148b
permissions -rw-r--r--
Bugfix: HGCommandParser>>parseCommandMerge: handle correctly clear merges.

"
 COPYRIGHT (c) 2012-2013 by Jan Vrany
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
"{ Package: 'stx:libscm/mercurial' }"

Object subclass:#HGCachedFileData
	instanceVariableNames:'file timestamp size data reader'
	classVariableNames:''
	poolDictionaries:''
	category:'SCM-Mercurial-Internal'
!

!HGCachedFileData class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 2012-2013 by Jan Vrany
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
! !

!HGCachedFileData class methodsFor:'instance creation'!

on: file reader: reader
    ^self new setFile: file reader: reader

    "Created: / 14-01-2013 / 16:27:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!HGCachedFileData methodsFor:'accessing'!

value
    | fmtime fsize |
    fmtime := file modificationTime.
    fsize := file fileSize.

    (data notNil and:[timestamp notNil]) and:[
        (fmtime <= timestamp 
            and:[fsize = size]) ifTrue:[ ^ data ].
    ].
    data := reader valueWithOptionalArgument: data.
    timestamp := fmtime.
    size := fsize.
    ^data

    "Created: / 14-01-2013 / 16:25:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 25-01-2013 / 18:46:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!HGCachedFileData methodsFor:'initialization'!

flush
    data := timestamp := size := nil.

    "Created: / 14-01-2013 / 16:26:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

setData: anObject
    data := anObject

    "Created: / 25-01-2013 / 18:52:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

setFile:fileArg reader:readerArg 
    file := fileArg.
    reader := readerArg.

    "Created: / 14-01-2013 / 16:20:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!HGCachedFileData class methodsFor:'documentation'!

version_HG

    ^ '$Changeset: <not expanded> $'
! !