xref: /aoo41x/main/solenv/bin/cwstouched.py (revision b0ad9294)
1#!/usr/bin/python
2
3#**************************************************************
4#
5#  Licensed to the Apache Software Foundation (ASF) under one
6#  or more contributor license agreements.  See the NOTICE file
7#  distributed with this work for additional information
8#  regarding copyright ownership.  The ASF licenses this file
9#  to you under the Apache License, Version 2.0 (the
10#  "License"); you may not use this file except in compliance
11#  with the License.  You may obtain a copy of the License at
12#
13#    http://www.apache.org/licenses/LICENSE-2.0
14#
15#  Unless required by applicable law or agreed to in writing,
16#  software distributed under the License is distributed on an
17#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18#  KIND, either express or implied.  See the License for the
19#  specific language governing permissions and limitations
20#  under the License.
21#
22#**************************************************************
23
24import os
25import sys
26import string
27from os import path
28
29def getCurrPath():
30    currPath = sys.path[0] or os.getcwd()
31    currPath = path.abspath(currPath)
32    return currPath
33
34def getCwsWorkStamp():
35    cwsWorkStamp=os.getenv('CWS_WORK_STAMP')
36
37    if not cwsWorkStamp:
38        currPath=getCurrPath()
39
40        os.chdir(os.getenv('SOLARENV'))
41
42        (input, output) = os.popen4("svn info")
43
44        for outline in output.readlines():
45            if outline.startswith("URL:"):
46                cwsWorkStamp = outline[outline.index("svn.services"):outline.index("solenv")-1]
47                cwsWorkStamp = cwsWorkStamp[cwsWorkStamp.rfind("/")+1:len(cwsWorkStamp)]
48                break
49
50        os.putenv("CWS_WORK_STAMP",cwsWorkStamp);
51        os.chdir(currPath)
52
53    return string.strip(cwsWorkStamp)
54
55def getMinor(cwsWorkStamp):
56    minor = os.getenv('UPDMINOR')
57
58    if not minor:
59        if (os.getenv('OSTYPE') == "cygwin"):
60            bash=os.getenv("SHELL")
61            (input, output) = os.popen4("cygpath -w "+bash)
62            winbash=string.strip(output.readlines()[0])
63            cws=winbash+" -c 'cws  query -c "+cwsWorkStamp+" current'"
64        else:
65            cws="cws query -c "+cwsWorkStamp+" current"
66
67        (input, output) = os.popen4(cws)
68
69        found=0
70        for outline in output.readlines():
71            if found:
72                minor=outline
73                break
74            elif outline.find("Current milestone:") != -1:
75                found=1
76
77    return string.strip(minor)
78
79
80workstamp = os.getenv('WORK_STAMP')
81solenv= os.getenv('SOLARENV')
82cwsWorkStamp=getCwsWorkStamp()
83minor = getMinor(cwsWorkStamp)
84
85oldWorkStamp = workstamp + "_" + minor
86diff="svn diff --summarize --old=svn://svn.services.openoffice.org/ooo/tags/"+oldWorkStamp+" --new=svn://svn.services.openoffice.org/ooo/cws/"+cwsWorkStamp
87
88modules=[]
89(input, output) = os.popen4(diff)
90
91for outline in output.readlines():
92    if outline.find("svn://svn.services.openoffice.org"):
93        index = outline.index(oldWorkStamp)+len(oldWorkStamp)+1
94        newModule=""
95        if outline.find("/",index) != -1:
96            # seems to be a file
97            newModule=string.strip(outline[index:outline.index("/",index)])
98        else:
99            #seems to be a folder
100            if len(outline[index:]) > 0:
101                newModule=string.strip(outline[index:])
102        if newModule != "" and not modules.count(newModule):
103            modules.append(newModule)
104
105for module in modules:
106    print(module)
107