Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: sitescripts/extensions/bin/createNightlies.py

Issue 29358368: Issue 4540 - Add Platform Specific Branch Support to createNightlies.py (Closed)
Left Patch Set: Adressing comments adds single unit test Created Oct. 24, 2016, 5:24 p.m.
Right Patch Set: Created Oct. 26, 2016, 5:53 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « .sitescripts.example ('k') | sitescripts/extensions/test/conftest.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
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 = ['hg', 'log', '-R', self.tempdir, '-r', self.bookmark + ':0', 106 command = [
114 '-l', '50', '--encoding', 'utf-8', '--template', 107 'hg', 'log', '-R', self.tempdir, '-r',
115 '{date|isodate}\\0{author|person}\\0{rev}\\0{desc}\\0\\0', 108 'ancestors({})'.format(self.config.revision), '-l', '50',
116 '--config', 'defaults.log='] 109 '--encoding', 'utf-8', '--template',
110 '{date|isodate}\\0{author|person}\\0{rev}\\0{desc}\\0\\0',
111 '--config', 'defaults.log='
112 ]
117 result = subprocess.check_output(command).decode('utf-8') 113 result = subprocess.check_output(command).decode('utf-8')
118 114
119 for change in result.split('\x00\x00'): 115 for change in result.split('\x00\x00'):
120 if change: 116 if change:
121 date, author, revision, description = change.split('\x00') 117 date, author, revision, description = change.split('\x00')
122 yield {'date': date, 'author': author, 'revision': revision, 'de scription': description} 118 yield {'date': date, 'author': author, 'revision': revision, 'de scription': description}
123 119
124 def copyRepository(self): 120 def copyRepository(self):
125 """ 121 """
126 Create a repository copy in a temporary directory 122 Create a repository copy in a temporary directory
127 """ 123 """
128 self.tempdir = tempfile.mkdtemp(prefix=self.config.repositoryName) 124 self.tempdir = tempfile.mkdtemp(prefix=self.config.repositoryName)
129 command = ['hg', 'clone', '-q', self.config.repository, '-u', 125 command = ['hg', 'clone', '-q', self.config.repository, '-u',
130 'default', self.tempdir] 126 self.config.revision, self.tempdir]
131 subprocess.check_call(command) 127 subprocess.check_call(command)
132 128
133 # Make sure to run ensure_dependencies.py if present 129 # Make sure to run ensure_dependencies.py if present
134 depscript = os.path.join(self.tempdir, 'ensure_dependencies.py') 130 depscript = os.path.join(self.tempdir, 'ensure_dependencies.py')
135 if os.path.isfile(depscript): 131 if os.path.isfile(depscript):
136 subprocess.check_call([sys.executable, depscript, '-q']) 132 subprocess.check_call([sys.executable, depscript, '-q'])
137 133
138 def writeChangelog(self, changes): 134 def writeChangelog(self, changes):
139 """ 135 """
140 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
589 except Exception as ex: 585 except Exception as ex:
590 logging.error('The build for %s failed:', repo) 586 logging.error('The build for %s failed:', repo)
591 logging.exception(ex) 587 logging.exception(ex)
592 588
593 file = open(nightlyConfigFile, 'wb') 589 file = open(nightlyConfigFile, 'wb')
594 nightlyConfig.write(file) 590 nightlyConfig.write(file)
595 591
596 592
597 if __name__ == '__main__': 593 if __name__ == '__main__':
598 main() 594 main()
LEFTRIGHT

Powered by Google App Engine
This is Rietveld