summaryrefslogtreecommitdiff
path: root/solenv/bin/cwstouched.py
blob: 6ed3e67757b2137bdffcb83b296ad904c25e4cc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/usr/bin/python

#*************************************************************************
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# 
# Copyright 2008 by Sun Microsystems, Inc.
#
# OpenOffice.org - a multi-platform office productivity suite
#
# This file is part of OpenOffice.org.
#
# OpenOffice.org is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# only, as published by the Free Software Foundation.
#
# OpenOffice.org 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 version 3 for more details
# (a copy is included in the LICENSE file that accompanied this code).
#
# You should have received a copy of the GNU Lesser General Public License
# version 3 along with OpenOffice.org.  If not, see
# <http://www.openoffice.org/license.html>
# for a copy of the LGPLv3 License.
#***********************************************************************/

import os
import sys
import string
from os import path

def getCurrPath():
    currPath = sys.path[0] or os.getcwd()
    currPath = path.abspath(currPath)
    return currPath
    
def getCwsWorkStamp():
    cwsWorkStamp=os.getenv('CWS_WORK_STAMP')
    
    if not cwsWorkStamp:
        currPath=getCurrPath()
        
        os.chdir(os.getenv('SOLARENV'))
        
        (input, output) = os.popen4("svn info")
        
        for outline in output.readlines():
            if outline.startswith("URL:"):
                cwsWorkStamp = outline[outline.index("svn.services"):outline.index("solenv")-1]
                cwsWorkStamp = cwsWorkStamp[cwsWorkStamp.rfind("/")+1:len(cwsWorkStamp)]
                break
                
        os.putenv("CWS_WORK_STAMP",cwsWorkStamp);
        os.chdir(currPath)
    
    return string.strip(cwsWorkStamp)
    
def getMinor(cwsWorkStamp):
    minor = os.getenv('UPDMINOR')
    
    if not minor:
        if (os.getenv('OSTYPE') == "cygwin"):
            bash=os.getenv("SHELL")
            (input, output) = os.popen4("cygpath -w "+bash)
            winbash=string.strip(output.readlines()[0])
            cws=winbash+" -c 'cws  query -c "+cwsWorkStamp+" current'"
        else:
            cws="cws query -c "+cwsWorkStamp+" current"

        (input, output) = os.popen4(cws)
        
        found=0
        for outline in output.readlines():
            if found:
                minor=outline
                break
            elif outline.find("Current milestone:") != -1:
                found=1
    
    return string.strip(minor)
    
    
workstamp = os.getenv('WORK_STAMP')
solenv= os.getenv('SOLARENV')
cwsWorkStamp=getCwsWorkStamp()
minor = getMinor(cwsWorkStamp)

oldWorkStamp = workstamp + "_" + minor
diff="svn diff --summarize --old=svn://svn.services.openoffice.org/ooo/tags/"+oldWorkStamp+" --new=svn://svn.services.openoffice.org/ooo/cws/"+cwsWorkStamp

modules=[]
(input, output) = os.popen4(diff)

for outline in output.readlines():
    if outline.find("svn://svn.services.openoffice.org"):
        index = outline.index(oldWorkStamp)+len(oldWorkStamp)+1
        newModule=""
        if outline.find("/",index) != -1:
            # seems to be a file
            newModule=string.strip(outline[index:outline.index("/",index)])
        else:
            #seems to be a folder
            if len(outline[index:]) > 0:
                newModule=string.strip(outline[index:])
        if newModule != "" and not modules.count(newModule): 
            modules.append(newModule)

for module in modules:
    print module