xref: /AOO41X/main/solenv/bin/cwstouched.py (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir#!/usr/bin/python
2*cdf0e10cSrcweir
3*cdf0e10cSrcweir#*************************************************************************
4*cdf0e10cSrcweir# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5*cdf0e10cSrcweir#
6*cdf0e10cSrcweir# Copyright 2000, 2010 Oracle and/or its affiliates.
7*cdf0e10cSrcweir#
8*cdf0e10cSrcweir# OpenOffice.org - a multi-platform office productivity suite
9*cdf0e10cSrcweir#
10*cdf0e10cSrcweir# This file is part of OpenOffice.org.
11*cdf0e10cSrcweir#
12*cdf0e10cSrcweir# OpenOffice.org is free software: you can redistribute it and/or modify
13*cdf0e10cSrcweir# it under the terms of the GNU Lesser General Public License version 3
14*cdf0e10cSrcweir# only, as published by the Free Software Foundation.
15*cdf0e10cSrcweir#
16*cdf0e10cSrcweir# OpenOffice.org is distributed in the hope that it will be useful,
17*cdf0e10cSrcweir# but WITHOUT ANY WARRANTY; without even the implied warranty of
18*cdf0e10cSrcweir# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19*cdf0e10cSrcweir# GNU Lesser General Public License version 3 for more details
20*cdf0e10cSrcweir# (a copy is included in the LICENSE file that accompanied this code).
21*cdf0e10cSrcweir#
22*cdf0e10cSrcweir# You should have received a copy of the GNU Lesser General Public License
23*cdf0e10cSrcweir# version 3 along with OpenOffice.org.  If not, see
24*cdf0e10cSrcweir# <http://www.openoffice.org/license.html>
25*cdf0e10cSrcweir# for a copy of the LGPLv3 License.
26*cdf0e10cSrcweir#
27*cdf0e10cSrcweir#***********************************************************************/
28*cdf0e10cSrcweir
29*cdf0e10cSrcweirimport os
30*cdf0e10cSrcweirimport sys
31*cdf0e10cSrcweirimport string
32*cdf0e10cSrcweirfrom os import path
33*cdf0e10cSrcweir
34*cdf0e10cSrcweirdef getCurrPath():
35*cdf0e10cSrcweir    currPath = sys.path[0] or os.getcwd()
36*cdf0e10cSrcweir    currPath = path.abspath(currPath)
37*cdf0e10cSrcweir    return currPath
38*cdf0e10cSrcweir
39*cdf0e10cSrcweirdef getCwsWorkStamp():
40*cdf0e10cSrcweir    cwsWorkStamp=os.getenv('CWS_WORK_STAMP')
41*cdf0e10cSrcweir
42*cdf0e10cSrcweir    if not cwsWorkStamp:
43*cdf0e10cSrcweir        currPath=getCurrPath()
44*cdf0e10cSrcweir
45*cdf0e10cSrcweir        os.chdir(os.getenv('SOLARENV'))
46*cdf0e10cSrcweir
47*cdf0e10cSrcweir        (input, output) = os.popen4("svn info")
48*cdf0e10cSrcweir
49*cdf0e10cSrcweir        for outline in output.readlines():
50*cdf0e10cSrcweir            if outline.startswith("URL:"):
51*cdf0e10cSrcweir                cwsWorkStamp = outline[outline.index("svn.services"):outline.index("solenv")-1]
52*cdf0e10cSrcweir                cwsWorkStamp = cwsWorkStamp[cwsWorkStamp.rfind("/")+1:len(cwsWorkStamp)]
53*cdf0e10cSrcweir                break
54*cdf0e10cSrcweir
55*cdf0e10cSrcweir        os.putenv("CWS_WORK_STAMP",cwsWorkStamp);
56*cdf0e10cSrcweir        os.chdir(currPath)
57*cdf0e10cSrcweir
58*cdf0e10cSrcweir    return string.strip(cwsWorkStamp)
59*cdf0e10cSrcweir
60*cdf0e10cSrcweirdef getMinor(cwsWorkStamp):
61*cdf0e10cSrcweir    minor = os.getenv('UPDMINOR')
62*cdf0e10cSrcweir
63*cdf0e10cSrcweir    if not minor:
64*cdf0e10cSrcweir        if (os.getenv('OSTYPE') == "cygwin"):
65*cdf0e10cSrcweir            bash=os.getenv("SHELL")
66*cdf0e10cSrcweir            (input, output) = os.popen4("cygpath -w "+bash)
67*cdf0e10cSrcweir            winbash=string.strip(output.readlines()[0])
68*cdf0e10cSrcweir            cws=winbash+" -c 'cws  query -c "+cwsWorkStamp+" current'"
69*cdf0e10cSrcweir        else:
70*cdf0e10cSrcweir            cws="cws query -c "+cwsWorkStamp+" current"
71*cdf0e10cSrcweir
72*cdf0e10cSrcweir        (input, output) = os.popen4(cws)
73*cdf0e10cSrcweir
74*cdf0e10cSrcweir        found=0
75*cdf0e10cSrcweir        for outline in output.readlines():
76*cdf0e10cSrcweir            if found:
77*cdf0e10cSrcweir                minor=outline
78*cdf0e10cSrcweir                break
79*cdf0e10cSrcweir            elif outline.find("Current milestone:") != -1:
80*cdf0e10cSrcweir                found=1
81*cdf0e10cSrcweir
82*cdf0e10cSrcweir    return string.strip(minor)
83*cdf0e10cSrcweir
84*cdf0e10cSrcweir
85*cdf0e10cSrcweirworkstamp = os.getenv('WORK_STAMP')
86*cdf0e10cSrcweirsolenv= os.getenv('SOLARENV')
87*cdf0e10cSrcweircwsWorkStamp=getCwsWorkStamp()
88*cdf0e10cSrcweirminor = getMinor(cwsWorkStamp)
89*cdf0e10cSrcweir
90*cdf0e10cSrcweiroldWorkStamp = workstamp + "_" + minor
91*cdf0e10cSrcweirdiff="svn diff --summarize --old=svn://svn.services.openoffice.org/ooo/tags/"+oldWorkStamp+" --new=svn://svn.services.openoffice.org/ooo/cws/"+cwsWorkStamp
92*cdf0e10cSrcweir
93*cdf0e10cSrcweirmodules=[]
94*cdf0e10cSrcweir(input, output) = os.popen4(diff)
95*cdf0e10cSrcweir
96*cdf0e10cSrcweirfor outline in output.readlines():
97*cdf0e10cSrcweir    if outline.find("svn://svn.services.openoffice.org"):
98*cdf0e10cSrcweir        index = outline.index(oldWorkStamp)+len(oldWorkStamp)+1
99*cdf0e10cSrcweir        newModule=""
100*cdf0e10cSrcweir        if outline.find("/",index) != -1:
101*cdf0e10cSrcweir            # seems to be a file
102*cdf0e10cSrcweir            newModule=string.strip(outline[index:outline.index("/",index)])
103*cdf0e10cSrcweir        else:
104*cdf0e10cSrcweir            #seems to be a folder
105*cdf0e10cSrcweir            if len(outline[index:]) > 0:
106*cdf0e10cSrcweir                newModule=string.strip(outline[index:])
107*cdf0e10cSrcweir        if newModule != "" and not modules.count(newModule):
108*cdf0e10cSrcweir            modules.append(newModule)
109*cdf0e10cSrcweir
110*cdf0e10cSrcweirfor module in modules:
111*cdf0e10cSrcweir    print module