# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
# $Id: Portfile 119819 2014-05-07 18:22:46Z sean@macports.org $

PortSystem              1.0
PortGroup               python 1.0
PortGroup               bitbucket 1.0

set realname            evolve
name                    py-hg$realname

categories-append       devel
platforms               darwin
license                 GPL-2+
maintainers             sean openmaintainer
supported_archs         noarch

description             Mutable history for mercurial
long_description        This extension provides several commands to mutate history \
                        and deal with issues it may raise.

# can't set python.versions before adding custom subports
subport py27-hgevolve-devel {
}

if {[string match "*-devel" $subport]} {
    bitbucket.setup     marmoute mutable-history 154510dc4318
    name                py-hg$realname-devel
    version             3.3.99
    revision            5

    checksums           rmd160  9b22bf9b87d2aae627235614758efe11e4edb933 \
                        sha256  21dae295312df08250a52f5931d999bb91d9a74fc2c2bf66c8994df00dd516fa
} else {
    bitbucket.setup     marmoute mutable-history 3.3.1
    name                py-hg$realname

    checksums           rmd160  cafed5e41ee87c5d6a8f52c5fdd8182c67667069 \
                        sha256  96c2c704a72811dff953ce8ae475be1342a75e05664c9eb5edf99f5601b1ac95
}

python.versions         27

if {${name} ne ${subport}} {
    depends_lib         path:bin/hg:mercurial

    conflicts           py${python.version}-hg$realname-devel
    if {[string match "*-devel" $subport]} {
        conflicts       py${python.version}-hg$realname
    }

    post-destroot {
        file delete ${destroot}${python.pkgd}/hgext/__init__.py
        file delete ${destroot}${python.pkgd}/hgext/__init__.pyc

        move ${destroot}${python.pkgd}/hgext/${realname}.py  ${destroot}${python.pkgd}/hg${realname}.py
        move ${destroot}${python.pkgd}/hgext/${realname}.pyc ${destroot}${python.pkgd}/hg${realname}.pyc

        foreach f [glob -nocomplain ${destroot}${python.pkgd}/hgext/*.py] {
            move $f ${destroot}${python.pkgd}
        }
        foreach f [glob -nocomplain ${destroot}${python.pkgd}/hgext/*.pyc] {
            move $f ${destroot}${python.pkgd}
        }
    }

    notes               "
To enable hg${realname}, add the following to your ~/.hgrc:

\[extensions\]
rebase =
hg${realname} =
"

    if {![string match "*-devel" $subport]} {
        livecheck.type      none
    }
}
