mercurial/HGRevset.st
author Jan Vrany <jan.vrany@labware.com>
Fri, 19 Feb 2021 08:29:41 +0000
changeset 924 4d92f234f671
parent 509 f92210d4585b
child 530 e95a80a12724
permissions -rw-r--r--
Rework and fix HGSourceCodeManager >> #revisionLogOf:...directory:module:` This commit changes the logic in two ways: 1. #newestRevision is now the newest revision in the branch that *contains* given file (not necesarily modidfes it). If there are multiple heads in that branch, pretty much random one is returned. This changes old behavior and therefore this commit updates tests. 2. If a specific single revision is requested, i.e., both from and to revisions are the same, revision log with that single revision is returned no matter whether it modifies the file or even contains that file at all. This is essentially a workaround to fix issue #305. Moreover, this commit simplifies the code a lot by delegating all the changeset searching and filtering to mercurial using revset expressions. See https://swing.fit.cvut.cz/projects/stx-jv/ticket/305#comment:3

"
stx:libscm - a new source code management library for Smalltalk/X
Copyright (C) 2012-2015 Jan Vrany

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License. 

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
"
"{ Package: 'stx:libscm/mercurial' }"

Object subclass:#HGRevset
	instanceVariableNames:'expression comment'
	classVariableNames:''
	poolDictionaries:''
	category:'SCM-Mercurial-Core'
!

!HGRevset class methodsFor:'documentation'!

copyright
"
stx:libscm - a new source code management library for Smalltalk/X
Copyright (C) 2012-2015 Jan Vrany

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License. 

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
"
!

documentation
"
    HGRevset represent a `revset` expression as used by Mercurial.
    Revset is an expression specifying a set of changesets (commits).


    For more on revsets see `hg help revset`

    [author:]
        Jan Vrany <jan.vrany@fit.cvut.cz>

    [instance variables:]

    [class variables:]

    [see also:]
        hg help revset

"
! !

!HGRevset class methodsFor:'instance creation'!

expression: expression comment: comment
    ^ self new setExpression: expression comment: comment.

    "Created: / 24-03-2014 / 21:55:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

fromString: aString
    ^ self new setExpression: aString

    "Created: / 07-02-2014 / 12:59:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!HGRevset methodsFor:'comparing'!

= another
    ^ (another isKindOf: self class)
        and:[ self asString = another asString ].

    "Created: / 24-03-2014 / 21:52:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

hash
    ^ expression hash

    "Created: / 24-03-2014 / 21:52:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!HGRevset methodsFor:'constructing'!

reverse
    expression isNil ifTrue:[ ^ self ].
    ^ self class    
        expression: 'reverse(', (expression ? '') , ')'
        comment:  comment

    "Created: / 25-03-2014 / 01:42:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!HGRevset methodsFor:'conversion'!

asHGRevset
    ^ self

    "Created: / 07-02-2014 / 12:59:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

asString
    ^ expression

    "Created: / 07-02-2014 / 12:59:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!HGRevset methodsFor:'displaying'!

displayString
    ^ comment notNil 
        ifTrue:[ expression asText , ((' - ', comment) asText colorizeAllWith: Color gray)]
        ifFalse:[ expression ]

    "Created: / 24-03-2014 / 21:44:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 25-03-2014 / 01:27:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!HGRevset methodsFor:'initialization'!

setComment: aString
    comment := aString

    "Created: / 24-03-2014 / 21:43:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

setExpression: aString
    expression := aString

    "Created: / 07-02-2014 / 12:59:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

setExpression: expr comment: comm
    expression := expr.
    comment := comm

    "Created: / 24-03-2014 / 21:55:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !