author | Lennard de Rijk <ljvderijk@gmail.com> |
Sun, 28 Jun 2009 17:53:58 +0200 | |
changeset 2440 | 05c430d1c147 |
parent 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 |
1981
8cfb054b73b2
Factor out input and file utils into io.py.
David Anderson <david.jc.anderson@gmail.com>
parents:
1888
diff
changeset
|
22 |
releasing a new version of Melange and pushing it to various app |
8cfb054b73b2
Factor out input and file utils into io.py.
David Anderson <david.jc.anderson@gmail.com>
parents:
1888
diff
changeset
|
23 |
engine instances. |
1816
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 |
1981
8cfb054b73b2
Factor out input and file utils into io.py.
David Anderson <david.jc.anderson@gmail.com>
parents:
1888
diff
changeset
|
28 |
proceeding. It is not a replacement for a cautious human operator. |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
29 |
|
1981
8cfb054b73b2
Factor out input and file utils into io.py.
David Anderson <david.jc.anderson@gmail.com>
parents:
1888
diff
changeset
|
30 |
Note that this script requires Python 2.5 or better (for various |
8cfb054b73b2
Factor out input and file utils into io.py.
David Anderson <david.jc.anderson@gmail.com>
parents:
1888
diff
changeset
|
31 |
language features) |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
32 |
""" |
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 |
__authors__ = [ |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
35 |
# 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
|
36 |
'"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
|
37 |
] |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
38 |
|
1888
ef350db7f753
Style fixes for release modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1849
diff
changeset
|
39 |
|
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
40 |
import functools |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
41 |
import os |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
42 |
import re |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
43 |
import subprocess |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
44 |
import sys |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
45 |
|
1822
c6bb25fa7f7b
Create an error module containing the top-level error class.
David Anderson <david.jc.anderson@gmail.com>
parents:
1816
diff
changeset
|
46 |
import error |
1981
8cfb054b73b2
Factor out input and file utils into io.py.
David Anderson <david.jc.anderson@gmail.com>
parents:
1888
diff
changeset
|
47 |
import io |
1834
0589bf1395c5
Add a log module to initialize and manage logging.
David Anderson <david.jc.anderson@gmail.com>
parents:
1827
diff
changeset
|
48 |
import log |
1849
f8728d5e2e07
Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
1847
diff
changeset
|
49 |
import subversion |
1824
c54c304e3c0e
Refactor ANSI colorization into a new utility module.
David Anderson <david.jc.anderson@gmail.com>
parents:
1823
diff
changeset
|
50 |
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
|
51 |
|
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
52 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
53 |
# 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
|
54 |
# repository. |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
55 |
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
|
56 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
57 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
58 |
# 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
|
59 |
# 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
|
60 |
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
|
61 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
62 |
|
1822
c6bb25fa7f7b
Create an error module containing the top-level error class.
David Anderson <david.jc.anderson@gmail.com>
parents:
1816
diff
changeset
|
63 |
class Error(error.Error): |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
64 |
pass |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
65 |
|
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 |
# |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
68 |
# 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
|
69 |
# |
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
70 |
def pristine_wc(f): |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
71 |
"""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
|
72 |
@functools.wraps(f) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
73 |
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
|
74 |
self.wc.revert() |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
75 |
return f(self, *args, **kwargs) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
76 |
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
|
77 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
78 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
79 |
def requires_branch(f): |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
80 |
"""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
|
81 |
@functools.wraps(f) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
82 |
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
|
83 |
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
|
84 |
raise error.ExpectationFailed( |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
85 |
'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
|
86 |
return f(self, *args, **kwargs) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
87 |
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
|
88 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
89 |
|
1825
a610a2df83d2
Move the Paths class to the util module.
David Anderson <david.jc.anderson@gmail.com>
parents:
1824
diff
changeset
|
90 |
class ReleaseEnvironment(util.Paths): |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
91 |
"""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
|
92 |
|
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
93 |
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
|
94 |
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
|
95 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
96 |
Attributes: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
97 |
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
|
98 |
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
|
99 |
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
|
100 |
""" |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
101 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
102 |
BRANCH_FILE = 'BRANCH' |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
103 |
|
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
104 |
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
|
105 |
"""Initializer. |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
106 |
|
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
107 |
Args: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
108 |
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
|
109 |
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
|
110 |
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
|
111 |
""" |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
112 |
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
|
113 |
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
|
114 |
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
|
115 |
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
|
116 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
117 |
if not self.wc.exists(): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
118 |
self._InitializeWC() |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
119 |
else: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
120 |
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
|
121 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
122 |
if self.exists(self.BRANCH_FILE): |
1981
8cfb054b73b2
Factor out input and file utils into io.py.
David Anderson <david.jc.anderson@gmail.com>
parents:
1888
diff
changeset
|
123 |
branch = io.fileToLines(self.path(self.BRANCH_FILE))[0] |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
124 |
self._switchBranch(branch) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
125 |
else: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
126 |
self._switchBranch(None) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
127 |
|
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
128 |
def _InitializeWC(self): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
129 |
"""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
|
130 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
131 |
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
|
132 |
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
|
133 |
""" |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
134 |
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
|
135 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
136 |
# 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
|
137 |
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
|
138 |
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
|
139 |
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
|
140 |
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
|
141 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
142 |
# 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
|
143 |
# the release environment to it. |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
144 |
branches = self._listBranches() |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
145 |
if not branches: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
146 |
self._switchBranch(None) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
147 |
else: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
148 |
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
|
149 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
150 |
def _listBranches(self): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
151 |
"""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
|
152 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
153 |
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
|
154 |
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
|
155 |
""" |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
156 |
assert self.wc.exists('branches') |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
157 |
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
|
158 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
159 |
# 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
|
160 |
# 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
|
161 |
# 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
|
162 |
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
|
163 |
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
|
164 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
165 |
return sorted(branches) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
166 |
|
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
167 |
def _switchBranch(self, release): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
168 |
"""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
|
169 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
170 |
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
|
171 |
operations. |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
172 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
173 |
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
|
174 |
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
|
175 |
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
|
176 |
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
|
177 |
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
|
178 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
179 |
Args: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
180 |
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
|
181 |
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
|
182 |
no branch. |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
183 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
184 |
""" |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
185 |
if release is None: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
186 |
self.branch = None |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
187 |
self.branch_dir = None |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
188 |
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
|
189 |
else: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
190 |
self.wc.update() |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
191 |
assert self.wc.exists('branches/' + release) |
1981
8cfb054b73b2
Factor out input and file utils into io.py.
David Anderson <david.jc.anderson@gmail.com>
parents:
1888
diff
changeset
|
192 |
io.linesToFile(self.path(self.BRANCH_FILE), [release]) |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
193 |
self.branch = release |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
194 |
self.branch_dir = 'branches/' + release |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
195 |
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
|
196 |
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
|
197 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
198 |
def _branchPath(self, path): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
199 |
"""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
|
200 |
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
|
201 |
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
|
202 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
203 |
# |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
204 |
# 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
|
205 |
# integration into a commandline interface. |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
206 |
# |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
207 |
@pristine_wc |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
208 |
def update(self): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
209 |
"""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
|
210 |
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
|
211 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
212 |
@pristine_wc |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
213 |
def switchToBranch(self): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
214 |
"""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
|
215 |
branches = self._listBranches() |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
216 |
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
|
217 |
raise error.ExpectationFailed( |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
218 |
'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
|
219 |
|
1981
8cfb054b73b2
Factor out input and file utils into io.py.
David Anderson <david.jc.anderson@gmail.com>
parents:
1888
diff
changeset
|
220 |
choice = io.getChoice('Available release branches:', |
8cfb054b73b2
Factor out input and file utils into io.py.
David Anderson <david.jc.anderson@gmail.com>
parents:
1888
diff
changeset
|
221 |
'Your choice?', |
8cfb054b73b2
Factor out input and file utils into io.py.
David Anderson <david.jc.anderson@gmail.com>
parents:
1888
diff
changeset
|
222 |
branches, |
8cfb054b73b2
Factor out input and file utils into io.py.
David Anderson <david.jc.anderson@gmail.com>
parents:
1888
diff
changeset
|
223 |
suggest=len(branches)-1) |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
224 |
self._switchBranch(branches[choice]) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
225 |
|
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
226 |
def _addAppYaml(self): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
227 |
"""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
|
228 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
229 |
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
|
230 |
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
|
231 |
Engine instance, and committed. |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
232 |
""" |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
233 |
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
|
234 |
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
|
235 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
236 |
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
|
237 |
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
|
238 |
|
1981
8cfb054b73b2
Factor out input and file utils into io.py.
David Anderson <david.jc.anderson@gmail.com>
parents:
1888
diff
changeset
|
239 |
yaml = io.fileToLines(self.wc.path(yaml_path)) |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
240 |
out = [] |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
241 |
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
|
242 |
stripped_line = line.strip() |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
243 |
if 'TODO' in stripped_line: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
244 |
continue |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
245 |
elif stripped_line == '# application: FIXME': |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
246 |
out.append('application: socghop') |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
247 |
elif stripped_line.startswith('version:'): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
248 |
out.append(line.lstrip() + 'g0') |
1888
ef350db7f753
Style fixes for release modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1849
diff
changeset
|
249 |
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
|
250 |
else: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
251 |
out.append(line) |
1981
8cfb054b73b2
Factor out input and file utils into io.py.
David Anderson <david.jc.anderson@gmail.com>
parents:
1888
diff
changeset
|
252 |
io.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
|
253 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
254 |
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
|
255 |
'in branch ' + self.branch) |
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 |
def _applyGooglePatches(self): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
258 |
"""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
|
259 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
260 |
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
|
261 |
""" |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
262 |
# 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
|
263 |
# 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
|
264 |
tmpl_file = self.wc.path( |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
265 |
self._branchPath('app/soc/templates/soc/base.html')) |
1981
8cfb054b73b2
Factor out input and file utils into io.py.
David Anderson <david.jc.anderson@gmail.com>
parents:
1888
diff
changeset
|
266 |
tmpl = io.fileToLines(tmpl_file) |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
267 |
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
|
268 |
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
|
269 |
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
|
270 |
break |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
271 |
else: |
1849
f8728d5e2e07
Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
1847
diff
changeset
|
272 |
raise error.ExpectationFailed( |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
273 |
'No source code link found in base.html') |
1981
8cfb054b73b2
Factor out input and file utils into io.py.
David Anderson <david.jc.anderson@gmail.com>
parents:
1888
diff
changeset
|
274 |
io.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
|
275 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
276 |
self.wc.commit( |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
277 |
'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
|
278 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
279 |
@pristine_wc |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
280 |
def importTag(self): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
281 |
"""Import a new Melange release""" |
1981
8cfb054b73b2
Factor out input and file utils into io.py.
David Anderson <david.jc.anderson@gmail.com>
parents:
1888
diff
changeset
|
282 |
release = io.getString('Enter the Melange release to import:') |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
283 |
if not release: |
1981
8cfb054b73b2
Factor out input and file utils into io.py.
David Anderson <david.jc.anderson@gmail.com>
parents:
1888
diff
changeset
|
284 |
error.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
|
285 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
286 |
branch_dir = 'branches/' + release |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
287 |
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
|
288 |
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
|
289 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
290 |
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
|
291 |
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
|
292 |
|
1981
8cfb054b73b2
Factor out input and file utils into io.py.
David Anderson <david.jc.anderson@gmail.com>
parents:
1888
diff
changeset
|
293 |
if io.confirm('Confirm import of release %s, tagged at r%d?' % |
8cfb054b73b2
Factor out input and file utils into io.py.
David Anderson <david.jc.anderson@gmail.com>
parents:
1888
diff
changeset
|
294 |
(release, release_rev)): |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
295 |
# 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
|
296 |
# release. |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
297 |
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
|
298 |
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
|
299 |
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
|
300 |
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
|
301 |
'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
|
302 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
303 |
# 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
|
304 |
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
|
305 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
306 |
# 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
|
307 |
self.wc.add([branch_dir]) |
1888
ef350db7f753
Style fixes for release modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1849
diff
changeset
|
308 |
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
|
309 |
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
|
310 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
311 |
# 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
|
312 |
# google-specific patches. |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
313 |
self._addAppYaml() |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
314 |
self._applyGooglePatches() |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
315 |
|
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
316 |
# All done! |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
317 |
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
|
318 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
319 |
@requires_branch |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
320 |
@pristine_wc |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
321 |
def cherryPickChange(self): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
322 |
"""Cherry-pick a change from the Melange trunk""" |
1981
8cfb054b73b2
Factor out input and file utils into io.py.
David Anderson <david.jc.anderson@gmail.com>
parents:
1888
diff
changeset
|
323 |
rev = io.getNumber('Revision number to cherry-pick:') |
8cfb054b73b2
Factor out input and file utils into io.py.
David Anderson <david.jc.anderson@gmail.com>
parents:
1888
diff
changeset
|
324 |
bug = io.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
|
325 |
|
1849
f8728d5e2e07
Factor out the Subversion wrapper to a separate module.
David Anderson <david.jc.anderson@gmail.com>
parents:
1847
diff
changeset
|
326 |
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
|
327 |
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
|
328 |
raise error.ExpectationFailed( |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
329 |
'Retrieved diff is empty. ' |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
330 |
'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
|
331 |
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
|
332 |
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
|
333 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
334 |
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
|
335 |
out = [] |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
336 |
updated_patchlevel = False |
1981
8cfb054b73b2
Factor out input and file utils into io.py.
David Anderson <david.jc.anderson@gmail.com>
parents:
1888
diff
changeset
|
337 |
for line in io.fileToLines(yaml_path): |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
338 |
if line.strip().startswith('version: '): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
339 |
version = line.strip().split()[-1] |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
340 |
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
|
341 |
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
|
342 |
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
|
343 |
(rev, bug)) |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
344 |
out.append('version: ' + new_version) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
345 |
out.append('# * ' + message) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
346 |
updated_patchlevel = True |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
347 |
else: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
348 |
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
|
349 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
350 |
if not updated_patchlevel: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
351 |
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
|
352 |
log.error('Cherry-picking failed') |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
353 |
|
1981
8cfb054b73b2
Factor out input and file utils into io.py.
David Anderson <david.jc.anderson@gmail.com>
parents:
1888
diff
changeset
|
354 |
io.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
|
355 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
356 |
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
|
357 |
log.info('svn diff ' + self.wc.path(self.branch_dir)) |
1981
8cfb054b73b2
Factor out input and file utils into io.py.
David Anderson <david.jc.anderson@gmail.com>
parents:
1888
diff
changeset
|
358 |
if not io.confirm('Commit this change?'): |
8cfb054b73b2
Factor out input and file utils into io.py.
David Anderson <david.jc.anderson@gmail.com>
parents:
1888
diff
changeset
|
359 |
raise error.AbortedByUser('Cherry-pick aborted') |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
360 |
self.wc.commit(message) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
361 |
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
|
362 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
363 |
MENU_ORDER = [ |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
364 |
update, |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
365 |
switchToBranch, |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
366 |
importTag, |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
367 |
cherryPickChange, |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
368 |
] |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
369 |
|
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
370 |
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
|
371 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
372 |
MENU_SUGGESTIONS = { |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
373 |
None: update, |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
374 |
update: cherryPickChange, |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
375 |
switchToBranch: cherryPickChange, |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
376 |
importTag: cherryPickChange, |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
377 |
cherryPickChange: None, |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
378 |
} |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
379 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
380 |
def interactiveMenu(self): |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
381 |
done = [] |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
382 |
last_choice = None |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
383 |
while True: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
384 |
# 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
|
385 |
# 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
|
386 |
# 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
|
387 |
# 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
|
388 |
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
|
389 |
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
|
390 |
else: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
391 |
last_command = None |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
392 |
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
|
393 |
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
|
394 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
395 |
try: |
1981
8cfb054b73b2
Factor out input and file utils into io.py.
David Anderson <david.jc.anderson@gmail.com>
parents:
1888
diff
changeset
|
396 |
choice = io.getChoice('Main menu:', 'Your choice?', |
8cfb054b73b2
Factor out input and file utils into io.py.
David Anderson <david.jc.anderson@gmail.com>
parents:
1888
diff
changeset
|
397 |
self.MENU_STRINGS, done=done, |
8cfb054b73b2
Factor out input and file utils into io.py.
David Anderson <david.jc.anderson@gmail.com>
parents:
1888
diff
changeset
|
398 |
suggest=suggested_next) |
8cfb054b73b2
Factor out input and file utils into io.py.
David Anderson <david.jc.anderson@gmail.com>
parents:
1888
diff
changeset
|
399 |
except (KeyboardInterrupt, error.AbortedByUser): |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
400 |
log.info('Exiting.') |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
401 |
return |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
402 |
try: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
403 |
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
|
404 |
except error.Error, e: |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
405 |
log.error(str(e)) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
406 |
else: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
407 |
done.append(choice) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
408 |
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
|
409 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
410 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
411 |
def main(argv): |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
412 |
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
|
413 |
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
|
414 |
'[upstream repos root URL]') |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
415 |
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
|
416 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
417 |
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
|
418 |
if len(argv) >= 2: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
419 |
release_repos = argv[1] |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
420 |
if len(argv) == 3: |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
421 |
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
|
422 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
423 |
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
|
424 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
425 |
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
|
426 |
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
|
427 |
|
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
428 |
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
|
429 |
release_repos, |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
430 |
upstream_repos) |
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
431 |
r.interactiveMenu() |
1816
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
432 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
433 |
|
07743b5295d3
Add the Google SoC release script to the Melange repository.
David Anderson <david.jc.anderson@gmail.com>
parents:
diff
changeset
|
434 |
if __name__ == '__main__': |
1835
3f30b7b14c57
Fix indentation to match Melange/Google style.
David Anderson <david.jc.anderson@gmail.com>
parents:
1834
diff
changeset
|
435 |
main(sys.argv) |