author | Sverre Rabbelier <srabbelier@gmail.com> |
Thu, 19 Mar 2009 00:12:59 +0000 | |
changeset 1930 | 2222bed78e7f |
parent 1888 | ef350db7f753 |
child 1981 | 8cfb054b73b2 |
permissions | -rwxr-xr-x |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
2 |
# |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
3 |
# Copyright 2009 the Melange authors. |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
4 |
# |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
8 |
# |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
10 |
# |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
16 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
17 |
from __future__ import with_statement |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
18 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
19 |
"""Google Summer of Code Melange release script. |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
20 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
21 |
This script provides automation for the various tasks involved in |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
22 |
pushing a new release of Melange to the official Google Summer of Code |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
23 |
app engine instance. |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
24 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
25 |
It does not provide a turnkey autopilot solution. Notably, each stage |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
26 |
of the release process must be started by a human operator, and some |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
27 |
commands will request confirmation or extra details before |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
28 |
proceeding. It is not a replacement for a cautious human |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
29 |
operator. |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
30 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
31 |
Note that this script requires: |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
32 |
- Python 2.5 or better (for various language features) |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
33 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
34 |
- Subversion 1.5.0 or better (for working copy depth control, which |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
35 |
cuts down checkout/update times by several orders of |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
36 |
magnitude). |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
37 |
""" |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
38 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
39 |
__authors__ = [ |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
40 |
# alphabetical order by last name, please |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
41 |
'"David Anderson" <dave@natulte.net>', |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
42 |
] |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
43 |
|
1888
ef350db7f753
Style fixes for release modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1849
diff
changeset
|
44 |
|
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
45 |
import functools |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
46 |
import os |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
47 |
import re |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
48 |
import subprocess |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
49 |
import sys |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
50 |
|
1822
c6bb25fa7f7b
Create an error module containing the top-level error class.
David Anderson <david.jc.anderson@gmail.com>
parents:
1816
diff
changeset
|
51 |
import error |
1834
0589bf1395c5
Add a log module to initialize and manage logging.
David Anderson <david.jc.anderson@gmail.com>
parents:
1827
diff
changeset
|
52 |
import log |
1849
f8728d5e2e07
Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
1847
diff
changeset
|
53 |
import subversion |
1824
c54c304e3c0e
Refactor ANSI colorization into a new utility module.
David Anderson <david.jc.anderson@gmail.com>
parents:
1823
diff
changeset
|
54 |
import util |
1822
c6bb25fa7f7b
Create an error module containing the top-level error class.
David Anderson <david.jc.anderson@gmail.com>
parents:
1816
diff
changeset
|
55 |
|
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
56 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
57 |
# Default repository URLs for Melange and the Google release |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
58 |
# repository. |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
59 |
MELANGE_REPOS = 'http://soc.googlecode.com/svn' |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
60 |
GOOGLE_SOC_REPOS = 'https://soc-google.googlecode.com/svn' |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
61 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
62 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
63 |
# Regular expression matching an apparently well formed Melange |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
64 |
# release number. |
1823
f55d0e1d3f82
Fix the Melange version regular expression to detect patch versions.
David Anderson <david.jc.anderson@gmail.com>
parents:
1822
diff
changeset
|
65 |
MELANGE_RELEASE_RE = re.compile(r'\d-\d-\d{8}p\d+') |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
66 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
67 |
|
1822
c6bb25fa7f7b
Create an error module containing the top-level error class.
David Anderson <david.jc.anderson@gmail.com>
parents:
1816
diff
changeset
|
68 |
class Error(error.Error): |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
69 |
pass |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
70 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
71 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
72 |
class AbortedByUser(Error): |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
73 |
"""The operation was aborted by the user.""" |
1888
ef350db7f753
Style fixes for release modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1849
diff
changeset
|
74 |
pass |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
75 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
76 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
77 |
class FileAccessError(Error): |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
78 |
"""An error occured while accessing a file.""" |
1888
ef350db7f753
Style fixes for release modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1849
diff
changeset
|
79 |
pass |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
80 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
81 |
|
1846
ac30e04bcbba
Redirect stdout/stderr through the logging system.
David Anderson <david.jc.anderson@gmail.com>
parents:
1835
diff
changeset
|
82 |
def getString(prompt): |
ac30e04bcbba
Redirect stdout/stderr through the logging system.
David Anderson <david.jc.anderson@gmail.com>
parents:
1835
diff
changeset
|
83 |
"""Prompt for and return a string.""" |
ac30e04bcbba
Redirect stdout/stderr through the logging system.
David Anderson <david.jc.anderson@gmail.com>
parents:
1835
diff
changeset
|
84 |
prompt += ' ' |
ac30e04bcbba
Redirect stdout/stderr through the logging system.
David Anderson <david.jc.anderson@gmail.com>
parents:
1835
diff
changeset
|
85 |
log.stdout.write(prompt) |
ac30e04bcbba
Redirect stdout/stderr through the logging system.
David Anderson <david.jc.anderson@gmail.com>
parents:
1835
diff
changeset
|
86 |
log.stdout.flush() |
ac30e04bcbba
Redirect stdout/stderr through the logging system.
David Anderson <david.jc.anderson@gmail.com>
parents:
1835
diff
changeset
|
87 |
|
ac30e04bcbba
Redirect stdout/stderr through the logging system.
David Anderson <david.jc.anderson@gmail.com>
parents:
1835
diff
changeset
|
88 |
response = sys.stdin.readline() |
ac30e04bcbba
Redirect stdout/stderr through the logging system.
David Anderson <david.jc.anderson@gmail.com>
parents:
1835
diff
changeset
|
89 |
log.terminal_echo(prompt + response.strip()) |
ac30e04bcbba
Redirect stdout/stderr through the logging system.
David Anderson <david.jc.anderson@gmail.com>
parents:
1835
diff
changeset
|
90 |
if not response: |
ac30e04bcbba
Redirect stdout/stderr through the logging system.
David Anderson <david.jc.anderson@gmail.com>
parents:
1835
diff
changeset
|
91 |
raise AbortedByUser('Aborted by ctrl+D') |
ac30e04bcbba
Redirect stdout/stderr through the logging system.
David Anderson <david.jc.anderson@gmail.com>
parents:
1835
diff
changeset
|
92 |
|
ac30e04bcbba
Redirect stdout/stderr through the logging system.
David Anderson <david.jc.anderson@gmail.com>
parents:
1835
diff
changeset
|
93 |
return response.strip() |
ac30e04bcbba
Redirect stdout/stderr through the logging system.
David Anderson <david.jc.anderson@gmail.com>
parents:
1835
diff
changeset
|
94 |
|
ac30e04bcbba
Redirect stdout/stderr through the logging system.
David Anderson <david.jc.anderson@gmail.com>
parents:
1835
diff
changeset
|
95 |
|
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
96 |
def confirm(prompt, default=False): |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
97 |
"""Ask a yes/no question and return the answer. |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
98 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
99 |
Will reprompt the user until one of "yes", "no", "y" or "n" is |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
100 |
entered. The input is case insensitive. |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
101 |
|
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
102 |
Args: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
103 |
prompt: The question to ask the user. |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
104 |
default: The answer to return if the user just hits enter. |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
105 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
106 |
Returns: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
107 |
True if the user answered affirmatively, False otherwise. |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
108 |
""" |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
109 |
if default: |
1846
ac30e04bcbba
Redirect stdout/stderr through the logging system.
David Anderson <david.jc.anderson@gmail.com>
parents:
1835
diff
changeset
|
110 |
question = prompt + ' [Yn]' |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
111 |
else: |
1846
ac30e04bcbba
Redirect stdout/stderr through the logging system.
David Anderson <david.jc.anderson@gmail.com>
parents:
1835
diff
changeset
|
112 |
question = prompt + ' [yN]' |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
113 |
while True: |
1846
ac30e04bcbba
Redirect stdout/stderr through the logging system.
David Anderson <david.jc.anderson@gmail.com>
parents:
1835
diff
changeset
|
114 |
answer = getString(question) |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
115 |
if not answer: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
116 |
return default |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
117 |
elif answer in ('y', 'yes'): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
118 |
return True |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
119 |
elif answer in ('n', 'no'): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
120 |
return False |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
121 |
else: |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
122 |
log.error('Please answer yes or no.') |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
123 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
124 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
125 |
def getNumber(prompt): |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
126 |
"""Prompt for and return a number. |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
127 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
128 |
Will reprompt the user until a number is entered. |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
129 |
""" |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
130 |
while True: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
131 |
value_str = getString(prompt) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
132 |
try: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
133 |
return int(value_str) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
134 |
except ValueError: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
135 |
log.error('Please enter a number. You entered "%s".' % value_str) |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
136 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
137 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
138 |
def getChoice(intro, prompt, choices, done=None, suggest=None): |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
139 |
"""Prompt for and return a choice from a menu. |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
140 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
141 |
Will reprompt the user until a valid menu entry is chosen. |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
142 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
143 |
Args: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
144 |
intro: Text to print verbatim before the choice menu. |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
145 |
prompt: The prompt to print right before accepting input. |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
146 |
choices: The list of string choices to display. |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
147 |
done: If not None, the list of indices of previously |
1888
ef350db7f753
Style fixes for release modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1849
diff
changeset
|
148 |
selected/completed choices. |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
149 |
suggest: If not None, the index of the choice to highlight as |
1888
ef350db7f753
Style fixes for release modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1849
diff
changeset
|
150 |
the suggested choice. |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
151 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
152 |
Returns: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
153 |
The index in the choices list of the selection the user made. |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
154 |
""" |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
155 |
done = set(done or []) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
156 |
while True: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
157 |
print intro |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
158 |
|
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
159 |
for i, entry in enumerate(choices): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
160 |
done_text = ' (done)' if i in done else '' |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
161 |
indent = '--> ' if i == suggest else ' ' |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
162 |
print '%s%2d. %s%s' % (indent, i+1, entry, done_text) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
163 |
|
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
164 |
choice = getNumber(prompt) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
165 |
if 0 < choice <= len(choices): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
166 |
return choice-1 |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
167 |
log.error('%d is not a valid choice between %d and %d' % |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
168 |
(choice, 1, len(choices))) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
169 |
|
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
170 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
171 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
172 |
def fileToLines(path): |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
173 |
"""Read a file and return it as a list of lines.""" |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
174 |
try: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
175 |
with file(path) as f: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
176 |
return f.read().split('\n') |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
177 |
except (IOError, OSError), e: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
178 |
raise FileAccessError(str(e)) |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
179 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
180 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
181 |
def linesToFile(path, lines): |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
182 |
"""Write a list of lines to a file.""" |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
183 |
try: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
184 |
with file(path, 'w') as f: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
185 |
f.write('\n'.join(lines)) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
186 |
except (IOError, OSError), e: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
187 |
raise FileAccessError(str(e)) |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
188 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
189 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
190 |
# |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
191 |
# Decorators for use in ReleaseEnvironment. |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
192 |
# |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
193 |
def pristine_wc(f): |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
194 |
"""A decorator that cleans up the release repository.""" |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
195 |
@functools.wraps(f) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
196 |
def revert_wc(self, *args, **kwargs): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
197 |
self.wc.revert() |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
198 |
return f(self, *args, **kwargs) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
199 |
return revert_wc |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
200 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
201 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
202 |
def requires_branch(f): |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
203 |
"""A decorator that checks that a release branch is active.""" |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
204 |
@functools.wraps(f) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
205 |
def check_branch(self, *args, **kwargs): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
206 |
if self.branch is None: |
1849
f8728d5e2e07
Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
1847
diff
changeset
|
207 |
raise error.ExpectationFailed( |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
208 |
'This operation requires an active release branch') |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
209 |
return f(self, *args, **kwargs) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
210 |
return check_branch |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
211 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
212 |
|
1825
a610a2df83d2
Move the Paths class to the util module.
David Anderson <david.jc.anderson@gmail.com>
parents:
1824
diff
changeset
|
213 |
class ReleaseEnvironment(util.Paths): |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
214 |
"""Encapsulates the state of a Melange release rolling environment. |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
215 |
|
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
216 |
This class contains the actual releasing logic, and makes use of |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
217 |
the previously defined utility classes to carry out user commands. |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
218 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
219 |
Attributes: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
220 |
release_repos: The URL to the Google release repository root. |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
221 |
upstream_repos: The URL to the Melange upstream repository root. |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
222 |
wc: A Subversion object encapsulating a Google SoC working copy. |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
223 |
""" |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
224 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
225 |
BRANCH_FILE = 'BRANCH' |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
226 |
|
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
227 |
def __init__(self, root, release_repos, upstream_repos): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
228 |
"""Initializer. |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
229 |
|
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
230 |
Args: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
231 |
root: The root of the release environment. |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
232 |
release_repos: The URL to the Google release repository root. |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
233 |
upstream_repos: The URL to the Melange upstream repository root. |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
234 |
""" |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
235 |
util.Paths.__init__(self, root) |
1849
f8728d5e2e07
Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
1847
diff
changeset
|
236 |
self.wc = subversion.WorkingCopy(self.path('google-soc')) |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
237 |
self.release_repos = release_repos.strip('/') |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
238 |
self.upstream_repos = upstream_repos.strip('/') |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
239 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
240 |
if not self.wc.exists(): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
241 |
self._InitializeWC() |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
242 |
else: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
243 |
self.wc.revert() |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
244 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
245 |
if self.exists(self.BRANCH_FILE): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
246 |
branch = fileToLines(self.path(self.BRANCH_FILE))[0] |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
247 |
self._switchBranch(branch) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
248 |
else: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
249 |
self._switchBranch(None) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
250 |
|
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
251 |
def _InitializeWC(self): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
252 |
"""Check out the initial release repository. |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
253 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
254 |
Will also select the latest release branch, if any, so that |
1888
ef350db7f753
Style fixes for release modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1849
diff
changeset
|
255 |
the end state is a fully ready to function release environment. |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
256 |
""" |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
257 |
log.info('Checking out the release repository') |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
258 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
259 |
# Check out a sparse view of the relevant repository paths. |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
260 |
self.wc.checkout(self.release_repos, depth='immediates') |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
261 |
self.wc.update('vendor', depth='immediates') |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
262 |
self.wc.update('branches', depth='immediates') |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
263 |
self.wc.update('tags', depth='immediates') |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
264 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
265 |
# Locate the most recent release branch, if any, and switch |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
266 |
# the release environment to it. |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
267 |
branches = self._listBranches() |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
268 |
if not branches: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
269 |
self._switchBranch(None) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
270 |
else: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
271 |
self._switchBranch(branches[-1]) |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
272 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
273 |
def _listBranches(self): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
274 |
"""Return a list of available Melange release branches. |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
275 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
276 |
Branches are returned in sorted order, from least recent to |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
277 |
most recent in release number ordering. |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
278 |
""" |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
279 |
assert self.wc.exists('branches') |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
280 |
branches = self.wc.ls('branches') |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
281 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
282 |
# Some early release branches used a different naming scheme |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
283 |
# that doesn't sort properly with new-style release names. We |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
284 |
# filter those out here, along with empty lines. |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
285 |
branches = [b.strip('/') for b in branches |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
286 |
if MELANGE_RELEASE_RE.match(b.strip('/'))] |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
287 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
288 |
return sorted(branches) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
289 |
|
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
290 |
def _switchBranch(self, release): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
291 |
"""Activate the branch matching the given release. |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
292 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
293 |
Once activated, this branch is the target of future release |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
294 |
operations. |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
295 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
296 |
None can be passed as the release. The result is that no |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
297 |
branch is active, and all operations that require an active |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
298 |
branch will fail until a branch is activated again. This is |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
299 |
used only at initialization, when it is detected that there |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
300 |
are no available release branches to activate. |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
301 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
302 |
Args: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
303 |
release: The version number of a Melange release already |
1888
ef350db7f753
Style fixes for release modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1849
diff
changeset
|
304 |
imported in the release repository, or None to activate |
ef350db7f753
Style fixes for release modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1849
diff
changeset
|
305 |
no branch. |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
306 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
307 |
""" |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
308 |
if release is None: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
309 |
self.branch = None |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
310 |
self.branch_dir = None |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
311 |
log.info('No release branch available') |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
312 |
else: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
313 |
self.wc.update() |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
314 |
assert self.wc.exists('branches/' + release) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
315 |
linesToFile(self.path(self.BRANCH_FILE), [release]) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
316 |
self.branch = release |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
317 |
self.branch_dir = 'branches/' + release |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
318 |
self.wc.update(self.branch_dir, depth='infinity') |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
319 |
log.info('Working on branch ' + self.branch) |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
320 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
321 |
def _branchPath(self, path): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
322 |
"""Return the given path with the release branch path prepended.""" |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
323 |
assert self.branch_dir is not None |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
324 |
return os.path.join(self.branch_dir, path) |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
325 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
326 |
# |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
327 |
# Release engineering commands. See further down for their |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
328 |
# integration into a commandline interface. |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
329 |
# |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
330 |
@pristine_wc |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
331 |
def update(self): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
332 |
"""Update and clean the release repository""" |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
333 |
self.wc.update() |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
334 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
335 |
@pristine_wc |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
336 |
def switchToBranch(self): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
337 |
"""Switch to another Melange release branch""" |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
338 |
branches = self._listBranches() |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
339 |
if not branches: |
1849
f8728d5e2e07
Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
1847
diff
changeset
|
340 |
raise error.ExpectationFailed( |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
341 |
'No branches available. Please import one.') |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
342 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
343 |
choice = getChoice('Available release branches:', |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
344 |
'Your choice?', |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
345 |
branches, |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
346 |
suggest=len(branches)-1) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
347 |
self._switchBranch(branches[choice]) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
348 |
|
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
349 |
def _addAppYaml(self): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
350 |
"""Create a Google production app.yaml configuration. |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
351 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
352 |
The file is copied and modified from the upstream |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
353 |
app.yaml.template, configure for Google's Summer of Code App |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
354 |
Engine instance, and committed. |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
355 |
""" |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
356 |
if self.wc.exists(self._branchPath('app/app.yaml')): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
357 |
raise ObstructionError('app/app.yaml exists already') |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
358 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
359 |
yaml_path = self._branchPath('app/app.yaml') |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
360 |
self.wc.copy(yaml_path + '.template', yaml_path) |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
361 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
362 |
yaml = fileToLines(self.wc.path(yaml_path)) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
363 |
out = [] |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
364 |
for i, line in enumerate(yaml): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
365 |
stripped_line = line.strip() |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
366 |
if 'TODO' in stripped_line: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
367 |
continue |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
368 |
elif stripped_line == '# application: FIXME': |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
369 |
out.append('application: socghop') |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
370 |
elif stripped_line.startswith('version:'): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
371 |
out.append(line.lstrip() + 'g0') |
1888
ef350db7f753
Style fixes for release modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1849
diff
changeset
|
372 |
out.append('# * initial Google fork of Melange ' + self.branch) |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
373 |
else: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
374 |
out.append(line) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
375 |
linesToFile(self.wc.path(yaml_path), out) |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
376 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
377 |
self.wc.commit('Create app.yaml with Google patch version g0 ' |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
378 |
'in branch ' + self.branch) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
379 |
|
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
380 |
def _applyGooglePatches(self): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
381 |
"""Apply Google-specific patches to a vanilla Melange release. |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
382 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
383 |
Each patch is applied and committed in turn. |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
384 |
""" |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
385 |
# Edit the base template to point users to the Google fork |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
386 |
# of the Melange codebase instead of the vanilla release. |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
387 |
tmpl_file = self.wc.path( |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
388 |
self._branchPath('app/soc/templates/soc/base.html')) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
389 |
tmpl = fileToLines(tmpl_file) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
390 |
for i, line in enumerate(tmpl): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
391 |
if 'http://code.google.com/p/soc/source/browse/tags/' in line: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
392 |
tmpl[i] = line.replace('/p/soc/', '/p/soc-google/') |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
393 |
break |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
394 |
else: |
1849
f8728d5e2e07
Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
1847
diff
changeset
|
395 |
raise error.ExpectationFailed( |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
396 |
'No source code link found in base.html') |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
397 |
linesToFile(tmpl_file, tmpl) |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
398 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
399 |
self.wc.commit( |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
400 |
'Customize the Melange release link in the sidebar menu') |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
401 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
402 |
@pristine_wc |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
403 |
def importTag(self): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
404 |
"""Import a new Melange release""" |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
405 |
release = getString('Enter the Melange release to import:') |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
406 |
if not release: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
407 |
AbortedByUser('No release provided, import aborted') |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
408 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
409 |
branch_dir = 'branches/' + release |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
410 |
if self.wc.exists(branch_dir): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
411 |
raise ObstructionError('Release %s already imported' % release) |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
412 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
413 |
tag_url = '%s/tags/%s' % (self.upstream_repos, release) |
1849
f8728d5e2e07
Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
1847
diff
changeset
|
414 |
release_rev = subversion.find_tag_rev(tag_url) |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
415 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
416 |
if confirm('Confirm import of release %s, tagged at r%d?' % |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
417 |
(release, release_rev)): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
418 |
# Add an entry to the vendor externals for the Melange |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
419 |
# release. |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
420 |
externals = self.wc.propget('svn:externals', 'vendor/soc') |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
421 |
externals.append('%s -r %d %s' % (release, release_rev, tag_url)) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
422 |
self.wc.propset('svn:externals', '\n'.join(externals), 'vendor/soc') |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
423 |
self.wc.commit('Add svn:externals entry to pull in Melange ' |
1888
ef350db7f753
Style fixes for release modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1849
diff
changeset
|
424 |
'release %s at r%d.' % (release, release_rev)) |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
425 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
426 |
# Export the tag into the release repository's branches |
1849
f8728d5e2e07
Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
1847
diff
changeset
|
427 |
subversion.export(tag_url, release_rev, self.wc.path(branch_dir)) |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
428 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
429 |
# Add and commit the branch add (very long operation!) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
430 |
self.wc.add([branch_dir]) |
1888
ef350db7f753
Style fixes for release modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1849
diff
changeset
|
431 |
self.wc.commit('Branch of Melange release %s' % release, branch_dir) |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
432 |
self._switchBranch(release) |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
433 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
434 |
# Commit the production GSoC configuration and |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
435 |
# google-specific patches. |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
436 |
self._addAppYaml() |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
437 |
self._applyGooglePatches() |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
438 |
|
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
439 |
# All done! |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
440 |
log.info('Melange release %s imported and googlified' % self.branch) |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
441 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
442 |
@requires_branch |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
443 |
@pristine_wc |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
444 |
def cherryPickChange(self): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
445 |
"""Cherry-pick a change from the Melange trunk""" |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
446 |
rev = getNumber('Revision number to cherry-pick:') |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
447 |
bug = getNumber('Issue fixed by this change:') |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
448 |
|
1849
f8728d5e2e07
Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
1847
diff
changeset
|
449 |
diff = subversion.diff(self.upstream_repos + '/trunk', rev) |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
450 |
if not diff.strip(): |
1849
f8728d5e2e07
Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
1847
diff
changeset
|
451 |
raise error.ExpectationFailed( |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
452 |
'Retrieved diff is empty. ' |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
453 |
'Did you accidentally cherry-pick a branch change?') |
1888
ef350db7f753
Style fixes for release modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1849
diff
changeset
|
454 |
util.run(['patch', '-p0'], cwd=self.wc.path(self.branch_dir), stdin=diff) |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
455 |
self.wc.addRemove(self.branch_dir) |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
456 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
457 |
yaml_path = self.wc.path(self._branchPath('app/app.yaml')) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
458 |
out = [] |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
459 |
updated_patchlevel = False |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
460 |
for line in fileToLines(yaml_path): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
461 |
if line.strip().startswith('version: '): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
462 |
version = line.strip().split()[-1] |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
463 |
base, patch = line.rsplit('g', 1) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
464 |
new_version = '%sg%d' % (base, int(patch) + 1) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
465 |
message = ('Cherry-picked r%d from /p/soc/ to fix issue %d' % |
1888
ef350db7f753
Style fixes for release modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1849
diff
changeset
|
466 |
(rev, bug)) |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
467 |
out.append('version: ' + new_version) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
468 |
out.append('# * ' + message) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
469 |
updated_patchlevel = True |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
470 |
else: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
471 |
out.append(line) |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
472 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
473 |
if not updated_patchlevel: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
474 |
log.error('Failed to update Google patch revision') |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
475 |
log.error('Cherry-picking failed') |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
476 |
|
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
477 |
linesToFile(yaml_path, out) |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
478 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
479 |
log.info('Check the diff about to be committed with:') |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
480 |
log.info('svn diff ' + self.wc.path(self.branch_dir)) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
481 |
if not confirm('Commit this change?'): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
482 |
raise AbortedByUser('Cherry-pick aborted') |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
483 |
self.wc.commit(message) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
484 |
log.info('Cherry-picked r%d from the Melange trunk.' % rev) |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
485 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
486 |
MENU_ORDER = [ |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
487 |
update, |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
488 |
switchToBranch, |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
489 |
importTag, |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
490 |
cherryPickChange, |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
491 |
] |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
492 |
|
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
493 |
MENU_STRINGS = [d.__doc__ for d in MENU_ORDER] |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
494 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
495 |
MENU_SUGGESTIONS = { |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
496 |
None: update, |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
497 |
update: cherryPickChange, |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
498 |
switchToBranch: cherryPickChange, |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
499 |
importTag: cherryPickChange, |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
500 |
cherryPickChange: None, |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
501 |
} |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
502 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
503 |
def interactiveMenu(self): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
504 |
done = [] |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
505 |
last_choice = None |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
506 |
while True: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
507 |
# Show the user their previously completed operations and |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
508 |
# a suggested next op, to remind them where they are in |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
509 |
# the release process (useful after long operations that |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
510 |
# may have caused lunch or an extended context switch). |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
511 |
if last_choice is not None: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
512 |
last_command = self.MENU_ORDER[last_choice] |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
513 |
else: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
514 |
last_command = None |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
515 |
suggested_next = self.MENU_ORDER.index( |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
516 |
self.MENU_SUGGESTIONS[last_command]) |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
517 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
518 |
try: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
519 |
choice = getChoice('Main menu:', 'Your choice?', |
1888
ef350db7f753
Style fixes for release modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1849
diff
changeset
|
520 |
self.MENU_STRINGS, done=done, suggest=suggested_next) |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
521 |
except (KeyboardInterrupt, AbortedByUser): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
522 |
log.info('Exiting.') |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
523 |
return |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
524 |
try: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
525 |
self.MENU_ORDER[choice](self) |
1849
f8728d5e2e07
Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
1847
diff
changeset
|
526 |
except error.Error, e: |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
527 |
log.error(str(e)) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
528 |
else: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
529 |
done.append(choice) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
530 |
last_choice = choice |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
531 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
532 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
533 |
def main(argv): |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
534 |
if not (1 <= len(argv) <= 3): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
535 |
print ('Usage: gsoc-release.py [release repos root URL] ' |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
536 |
'[upstream repos root URL]') |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
537 |
sys.exit(1) |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
538 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
539 |
release_repos, upstream_repos = GOOGLE_SOC_REPOS, MELANGE_REPOS |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
540 |
if len(argv) >= 2: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
541 |
release_repos = argv[1] |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
542 |
if len(argv) == 3: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
543 |
upstream_repos = argv[2] |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
544 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
545 |
log.init('release.log') |
1834
0589bf1395c5
Add a log module to initialize and manage logging.
David Anderson <david.jc.anderson@gmail.com>
parents:
1827
diff
changeset
|
546 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
547 |
log.info('Release repository: ' + release_repos) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
548 |
log.info('Upstream repository: ' + upstream_repos) |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
549 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
550 |
r = ReleaseEnvironment(os.path.abspath('_release_'), |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
551 |
release_repos, |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
552 |
upstream_repos) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
553 |
r.interactiveMenu() |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
554 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
555 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
556 |
if __name__ == '__main__': |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
557 |
main(sys.argv) |