LEFT | RIGHT |
1 # This file is part of the Adblock Plus web scripts, | 1 # This file is part of the Adblock Plus web scripts, |
2 # Copyright (C) 2006-2016 Eyeo GmbH | 2 # Copyright (C) 2006-2016 Eyeo GmbH |
3 # | 3 # |
4 # Adblock Plus is free software: you can redistribute it and/or modify | 4 # Adblock Plus is free software: you can redistribute it and/or modify |
5 # it under the terms of the GNU General Public License version 3 as | 5 # it under the terms of the GNU General Public License version 3 as |
6 # published by the Free Software Foundation. | 6 # published by the Free Software Foundation. |
7 # | 7 # |
8 # Adblock Plus is distributed in the hope that it will be useful, | 8 # Adblock Plus is distributed in the hope that it will be useful, |
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 Performs the build process for an extension, | 58 Performs the build process for an extension, |
59 generating changelogs and documentation. | 59 generating changelogs and documentation. |
60 """ | 60 """ |
61 | 61 |
62 def __init__(self, config): | 62 def __init__(self, config): |
63 """ | 63 """ |
64 Creates a NightlyBuild instance; we are simply | 64 Creates a NightlyBuild instance; we are simply |
65 recording the configuration settings here. | 65 recording the configuration settings here. |
66 """ | 66 """ |
67 self.config = config | 67 self.config = config |
68 try: | |
69 self.bookmark = self.config.get( | |
70 'extensions', 'abp{}_bookmark'.format(self.config.type) | |
71 ) | |
72 except ConfigParser.NoOptionError: | |
73 self.bookmark = 'master' | |
74 | |
75 self.revision = self.getCurrentRevision() | 68 self.revision = self.getCurrentRevision() |
76 try: | 69 try: |
77 self.previousRevision = config.latestRevision | 70 self.previousRevision = config.latestRevision |
78 except: | 71 except: |
79 self.previousRevision = '0' | 72 self.previousRevision = '0' |
80 self.buildNum = None | 73 self.buildNum = None |
81 self.tempdir = None | 74 self.tempdir = None |
82 self.outputFilename = None | 75 self.outputFilename = None |
83 self.changelogFilename = None | 76 self.changelogFilename = None |
84 | 77 |
85 def hasChanges(self): | 78 def hasChanges(self): |
86 return self.revision != self.previousRevision | 79 return self.revision != self.previousRevision |
87 | 80 |
88 def getCurrentRevision(self): | 81 def getCurrentRevision(self): |
89 """ | 82 """ |
90 retrieves the current revision ID from the repository | 83 retrieves the current revision ID from the repository |
91 """ | 84 """ |
92 command = [ | 85 command = [ |
93 'hg', 'id', '-i', '-r', self.bookmark, '--config', | 86 'hg', 'id', '-i', '-r', self.config.revision, '--config', |
94 'defaults.id=', self.config.repository | 87 'defaults.id=', self.config.repository |
95 ] | 88 ] |
96 return subprocess.check_output(command).strip() | 89 return subprocess.check_output(command).strip() |
97 | 90 |
98 def getCurrentBuild(self): | 91 def getCurrentBuild(self): |
99 """ | 92 """ |
100 calculates the (typically numerical) build ID for the current build | 93 calculates the (typically numerical) build ID for the current build |
101 """ | 94 """ |
102 command = ['hg', 'id', '-n', '--config', 'defaults.id=', self.tempdir] | 95 command = ['hg', 'id', '-n', '--config', 'defaults.id=', self.tempdir] |
103 build = subprocess.check_output(command).strip() | 96 build = subprocess.check_output(command).strip() |
104 if self.config.type == 'gecko': | 97 if self.config.type == 'gecko': |
105 build += '-beta' | 98 build += '-beta' |
106 return build | 99 return build |
107 | 100 |
108 def getChanges(self): | 101 def getChanges(self): |
109 """ | 102 """ |
110 retrieve changes between the current and previous ("first") revision | 103 retrieve changes between the current and previous ("first") revision |
111 """ | 104 """ |
112 | 105 |
113 command = [ | 106 command = [ |
114 'hg', 'log', '-R', self.tempdir, '-r', self.bookmark + ':0', | 107 'hg', 'log', '-R', self.tempdir, '-r', |
115 '-b', 'default', '-l', '50', '--encoding', 'utf-8', '--template', | 108 'ancestors({})'.format(self.config.revision), '-l', '50', |
| 109 '--encoding', 'utf-8', '--template', |
116 '{date|isodate}\\0{author|person}\\0{rev}\\0{desc}\\0\\0', | 110 '{date|isodate}\\0{author|person}\\0{rev}\\0{desc}\\0\\0', |
117 '--config', 'defaults.log=' | 111 '--config', 'defaults.log=' |
118 ] | 112 ] |
119 result = subprocess.check_output(command).decode('utf-8') | 113 result = subprocess.check_output(command).decode('utf-8') |
120 | 114 |
121 for change in result.split('\x00\x00'): | 115 for change in result.split('\x00\x00'): |
122 if change: | 116 if change: |
123 date, author, revision, description = change.split('\x00') | 117 date, author, revision, description = change.split('\x00') |
124 yield {'date': date, 'author': author, 'revision': revision, 'de
scription': description} | 118 yield {'date': date, 'author': author, 'revision': revision, 'de
scription': description} |
125 | 119 |
126 def copyRepository(self): | 120 def copyRepository(self): |
127 """ | 121 """ |
128 Create a repository copy in a temporary directory | 122 Create a repository copy in a temporary directory |
129 """ | 123 """ |
130 self.tempdir = tempfile.mkdtemp(prefix=self.config.repositoryName) | 124 self.tempdir = tempfile.mkdtemp(prefix=self.config.repositoryName) |
131 command = ['hg', 'clone', '-q', self.config.repository, '-u', | 125 command = ['hg', 'clone', '-q', self.config.repository, '-u', |
132 'default', self.tempdir] | 126 self.config.revision, self.tempdir] |
133 subprocess.check_call(command) | 127 subprocess.check_call(command) |
134 | 128 |
135 # Make sure to run ensure_dependencies.py if present | 129 # Make sure to run ensure_dependencies.py if present |
136 depscript = os.path.join(self.tempdir, 'ensure_dependencies.py') | 130 depscript = os.path.join(self.tempdir, 'ensure_dependencies.py') |
137 if os.path.isfile(depscript): | 131 if os.path.isfile(depscript): |
138 subprocess.check_call([sys.executable, depscript, '-q']) | 132 subprocess.check_call([sys.executable, depscript, '-q']) |
139 | 133 |
140 def writeChangelog(self, changes): | 134 def writeChangelog(self, changes): |
141 """ | 135 """ |
142 write the changelog file into the cloned repository | 136 write the changelog file into the cloned repository |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 except Exception as ex: | 585 except Exception as ex: |
592 logging.error('The build for %s failed:', repo) | 586 logging.error('The build for %s failed:', repo) |
593 logging.exception(ex) | 587 logging.exception(ex) |
594 | 588 |
595 file = open(nightlyConfigFile, 'wb') | 589 file = open(nightlyConfigFile, 'wb') |
596 nightlyConfig.write(file) | 590 nightlyConfig.write(file) |
597 | 591 |
598 | 592 |
599 if __name__ == '__main__': | 593 if __name__ == '__main__': |
600 main() | 594 main() |
LEFT | RIGHT |