hg_hooks/applylocaltags/applylocaltags.py
author andy simpson <andrews@symbian.org>
Wed, 01 Sep 2010 14:50:53 +0100
changeset 315 db97abaca812
permissions -rw-r--r--
Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
315
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
     1
#! /usr/bin/python
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
     2
# Copyright (c) 2009 Symbian Foundation Ltd
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
     3
# This component and the accompanying materials are made available
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
     4
# under the terms of the License "Eclipse Public License v1.0"
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
     5
# which accompanies this distribution, and is available
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
     6
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
     7
#
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
     8
# Initial Contributors:
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
     9
# Symbian Foundation Ltd - initial contribution.
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    10
#
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    11
# Contributors:
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    12
#
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    13
# applytag.py - apply local mercurial tag based on one or more csv files
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    14
#                which contain a list of repos and changesets
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    15
#                for any <name>.csv file use the <name> is used as the tag name
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    16
#
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    17
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    18
repo_root='c:/sf'
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    19
debugfile = "debug.out"
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    20
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    21
import re
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    22
import StringIO
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    23
import os
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    24
import sys
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    25
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    26
from mercurial import util
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    27
from mercurial.i18n import _
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    28
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    29
import subprocess
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    30
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    31
sourceline = re.compile('(.*?)(oss|sfl)/(FCL|MCL)/(.*)',re.I)
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    32
MCL = re.compile('^MCL$',re.I)
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    33
re_csvfile = re.compile(r"(.*?)\.csv$",re.I)
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    34
csvfields = re.compile(r"(.*?),(.*?),(.*?),(.*?),.*")
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    35
verbose = True
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    36
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    37
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    38
def debug_info(str):
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    39
    hgui.debug(_(str))
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    40
    dbgfile.write(str)
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    41
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    42
def debug_warn(str):
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    43
    hgui.write(_(str))
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    44
    dbgfile.write(str)
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    45
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    46
def debug_verbose(str):
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    47
    if verbose:
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    48
        hgui.debug(_(str))
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    49
        dbgfile.write(str)
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    50
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    51
def commit_hook(ui, repo, hooktype, node=None, source=None, **kwargs):
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    52
    # iterate over all the files in added changeset
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    53
    global hgui
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    54
    global dbgfile
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    55
    hgui = ui
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    56
    ctx = repo[node]
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    57
    dbgfile = file(debugfile,'w')  #open file f for write
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    58
    for f in ctx.files():
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    59
        debug_info(('file %s \n') % (f))
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    60
        csvname = re_csvfile.match(f)
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    61
        if (csvname):
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    62
            debug_info(('csv file %s\n') % f)
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    63
            fctx = ctx.filectx(f)
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    64
            filecontent = fctx.data()
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    65
            tagname = csvname.group(1).upper()
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    66
            debug_info(('tag to use : %s\n')% tagname)
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    67
            csvfp = StringIO.StringIO(filecontent)
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    68
            parse_csv(ui,csvfp,tagname)
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    69
            csvfp.close()
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    70
    dbgfile.close()
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    71
    # return False meand "don't block"
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    72
    return False
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    73
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    74
def walk_repos(ui,rootpath):
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    75
    p = util.pconvert(rootpath)
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    76
    for path in util.walkrepos(p, followsym=True):
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    77
        debug_info(('repo %s\n') % path)
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    78
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    79
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    80
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    81
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    82
def parse_csv(ui,fp,tagname):
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    83
    '''
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    84
        Take a list of repositories (from csv file)
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    85
        For each repository apply a local tag
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    86
        to the local copy of the repo using the
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    87
        specified changeset
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    88
    '''
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    89
    global verbose
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    90
    for line in fp.readlines():
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    91
        # check it is basic csv and extract repo url and changeset
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    92
        cline = csvfields.match(line)
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    93
        if(cline):
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    94
            reposrc = cline.group(1)
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    95
            changeset = cline.group(4)
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    96
        else:
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    97
            debug_warn(('ignoring : %s\n' %line))
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    98
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
    99
        # now check the repo url looks valid
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
   100
        m = sourceline.match(reposrc)
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
   101
        if (m):
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
   102
            # construct local path
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
   103
            applytag(ui,repo_root,m.group(2),m.group(3),m.group(4),changeset,tagname)
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
   104
            #if we have just tagged the MCL then tag the FCL as well
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
   105
            if(MCL.match(m.group(3))):
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
   106
                applytag(ui,repo_root,m.group(2),"FCL",m.group(4),changeset,tagname)
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
   107
        else:
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
   108
            debug_warn(('Ignoring Source Line: %s\n' %reposrc))
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
   109
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
   110
def applytag(ui,path_root,p_license,p_branch,p_repo,rev,tagname):
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
   111
    repoabs = '/'.join([path_root,p_license,p_branch,p_repo])
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
   112
    repoabs.replace("\\","/")
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
   113
    tagcmd = ['hg','-R',repoabs,'tag','--local','--force','-r',rev,tagname]
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
   114
    #print tagcmd
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
   115
    run(ui,tagcmd)
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
   116
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
   117
def run(ui,cmd):
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
   118
    debug_verbose(('cmd %s\n' % ' '.join(cmd)))
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
   119
    try:
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
   120
        p = subprocess.Popen(args=cmd, bufsize=1024, shell = False, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
   121
	cmdout, errtxt = p.communicate()
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
   122
        debug_warn((cmdout))
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
   123
    except IOError as err:
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
   124
        debug_warn(("IOError : ",err))
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
   125
    except OSError as err:
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
   126
        debug_warn(("OSError : ",err))
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
   127
    except:
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
   128
        debug_warn(("Error %s : Could not run %s\n" % (sys.exc_info()[0],cmd)))
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
   129
        return -1
db97abaca812 Simple hg hook to apply a local tag to a list of repos specified in a csv file (following format of fbf sources.csv file used in PDK builds). Used to create movable tags such as "S3_LATESTGOOD".
andy simpson <andrews@symbian.org>
parents:
diff changeset
   130