#!/usr/bin/python2.3
# arch-tag: tool to note that a particular version is "golden"
# Copyright (C) 2003 John Goerzen
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program 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 General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
#

import sys, os
from tbppy import versions, extcmd, tbpconfig, configs, tla

debver, upstreamver, package, wcdir = tbpconfig.pkginit()
startdir = os.getcwd()
os.chdir(wcdir)

if configs.hasconfig('debian', package, debver):
    print " *** ERROR: configuration for %s %s already exists; not modifying"%\
          (package, debver)
    sys.exit(100)

os.chdir(startdir)
tlaversion = tla.gettreeversion()
newrev_base = extcmd.run('tla revisions')[-1]
newrev = '%s--%s' % (tlaversion, newrev_base)
os.chdir(wcdir)
configs.writelatest('debian', package, debver, tlaversion)
configs.writeconfig('debian', package, debver, newrev)
extcmd.qrun('tla commit -L "Added configs for Debian %s %s"' % \
            (package, debver))

print " *** Success: Noted Debian %s version %s\n *** at %s" % \
      (package, debver, newrev)
