mercurial/HGStatus.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Fri, 01 Feb 2013 12:02:22 +0000
changeset 210 54a73fa50d40
parent 115 b1ed2d29054b
child 282 fb71143ed353
permissions -rw-r--r--
Added copyright notice.

"
 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' }"

Singleton subclass:#HGStatus
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'SCM-Mercurial-Core'
!

HGStatus subclass:#Added
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	privateIn:HGStatus
!

HGStatus subclass:#Clean
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	privateIn:HGStatus
!

HGStatus subclass:#Copied
	instanceVariableNames:'source'
	classVariableNames:''
	poolDictionaries:''
	privateIn:HGStatus
!

HGStatus subclass:#Ignored
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	privateIn:HGStatus
!

HGStatus subclass:#Missing
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	privateIn:HGStatus
!

HGStatus subclass:#Modified
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	privateIn:HGStatus
!

HGStatus subclass:#NotTracked
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	privateIn:HGStatus
!

HGStatus subclass:#Removed
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	privateIn:HGStatus
!

!HGStatus 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.
"
! !

!HGStatus class methodsFor:'instance creation'!

forCode: aCharacter
    self allSubclasses do:[:cls|
        cls code == aCharacter ifTrue:[ ^ cls theOnlyInstance ]
    ].
    self error:'Invalid status code: ', aCharacter

    "Created: / 23-10-2012 / 10:56:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

theOnlyInstance
    theOnlyInstance isNil ifTrue:[
        Lock critical:[
            theOnlyInstance isNil ifTrue:[
                theOnlyInstance := self new
            ].
        ]
    ].
    ^ theOnlyInstance.

    "Created: / 09-11-2012 / 12:04:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!HGStatus class methodsFor:'accessing'!

code
    "Return one-char code as used by 'hg status' command,
    i.e., $A for added, $!! for missing, ..."

    ^self subclassResponsibility

    "Created: / 22-10-2012 / 21:27:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 21-11-2012 / 01:10:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!HGStatus class methodsFor:'accessing-statuses'!

added
    ^ Added theOnlyInstance

    "Created: / 23-10-2012 / 09:56:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

clean
    ^ Clean theOnlyInstance

    "Created: / 23-10-2012 / 09:56:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

copied
    ^ Copied new

    "Created: / 21-11-2012 / 01:04:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

ignored
    ^ Ignored theOnlyInstance

    "Created: / 23-10-2012 / 09:57:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

missing
    ^ Missing theOnlyInstance

    "Created: / 23-10-2012 / 09:56:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

notTracked
    ^ NotTracked theOnlyInstance

    "Created: / 23-10-2012 / 09:57:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

removed
    ^ Removed theOnlyInstance

    "Created: / 23-10-2012 / 09:56:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!HGStatus methodsFor:'accessing'!

code
    ^ self class code
!

name
    "Return a human-readable name of the status code,
    i.e., 'modified', 'ignored', ..."

    ^self class nameWithoutPrefix asLowercase

    "Created: / 22-10-2012 / 21:26:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 23-10-2012 / 09:58:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!HGStatus methodsFor:'testing'!

isAdded
    ^ false
!

isClean
    ^ false
!

isCleanOrIgnored
    ^ false

    "Created: / 15-11-2012 / 01:29:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

isCopied
    ^ false

    "Created: / 21-11-2012 / 01:07:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

isIgnored
    ^ false
!

isMissing
    ^ false
!

isModified
    ^ false
!

isNotTracked
    ^ false
!

isRemoved
    ^ false
!

isUntracked
    ^ self isNotTracked

    "Created: / 21-11-2012 / 00:57:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!HGStatus::Added class methodsFor:'accessing'!

code
    "Return one-char code as used by 'hg status' command,
     i.e., $A for added, $!! for missing, ..."

    ^ $A

    "Modified: / 23-10-2012 / 09:57:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!HGStatus::Added methodsFor:'testing'!

isAdded
    ^ true
! !

!HGStatus::Clean class methodsFor:'accessing'!

code
    "Return one-char code as used by 'hg status' command,
     i.e., $A for added, $!! for missing, ..."

    ^ $C

    "Modified: / 23-10-2012 / 09:57:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!HGStatus::Clean methodsFor:'testing'!

isClean
    ^ true
!

isCleanOrIgnored
    ^ true

    "Created: / 15-11-2012 / 01:29:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!HGStatus::Copied class methodsFor:'accessing'!

code
    ^Character space

    "Created: / 21-11-2012 / 01:10:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!HGStatus::Copied methodsFor:'accessing'!

code
    "Return one-char code as used by 'hg status' command,
    i.e., $A for added, $!! for missing, ..."

    ^Character space

    "Created: / 22-10-2012 / 21:27:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 21-11-2012 / 01:10:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

source
    ^ source
!

source:something
    source := something.
! !

!HGStatus::Copied methodsFor:'testing'!

isCopied
    ^ true

    "Created: / 21-11-2012 / 01:07:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!HGStatus::Ignored class methodsFor:'accessing'!

code
    "Return one-char code as used by 'hg status' command,
     i.e., $A for added, $!! for missing, ..."

    ^ $I

    "Modified: / 23-10-2012 / 09:57:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!HGStatus::Ignored methodsFor:'testing'!

isCleanOrIgnored
    ^ true

    "Created: / 15-11-2012 / 01:30:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

isIgnored
    ^ true
! !

!HGStatus::Missing class methodsFor:'accessing'!

code
    "Return one-char code as used by 'hg status' command,
     i.e., $A for added, $!! for missing, ..."

    ^ $!!

    "Modified: / 23-10-2012 / 09:57:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!HGStatus::Missing methodsFor:'testing'!

isMissing
    ^ true
! !

!HGStatus::Modified class methodsFor:'accessing'!

code
    "Return one-char code as used by 'hg status' command,
     i.e., $A for added, $!! for missing, ..."

    ^ $M

    "Modified: / 23-10-2012 / 09:57:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!HGStatus::Modified methodsFor:'testing'!

isModified
    ^ true
! !

!HGStatus::NotTracked class methodsFor:'accessing'!

code
    "Return one-char code as used by 'hg status' command,
     i.e., $A for added, $!! for missing, ..."

    ^ $?

    "Modified: / 23-10-2012 / 09:58:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!HGStatus::NotTracked methodsFor:'testing'!

isNotTracked
    ^ true
! !

!HGStatus::Removed class methodsFor:'accessing'!

code
    "Return one-char code as used by 'hg status' command,
     i.e., $A for added, $!! for missing, ..."

    ^ $R

    "Modified: / 23-10-2012 / 11:24:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!HGStatus::Removed methodsFor:'testing'!

isRemoved
    ^ true
! !

!HGStatus class methodsFor:'documentation'!

version_HG

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

version_SVN
    ^ '§Id::                                                                                                                        §'
! !