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

Side by Side Diff: sitescripts/extensions/bin/createNightlies.py

Issue 29358368: Issue 4540 - Add Platform Specific Branch Support to createNightlies.py (Closed)
Patch Set: adds fixture to generate place holder nightlies file, removes nightlies file from repo Created Oct. 25, 2016, 10:29 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
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 )
Wladimir Palant 2016/10/25 16:32:04 Ok, so the config example makes the impression as
Jon Sonesen 2016/10/25 16:39:58 so adding this will cause whatever option ending w
Jon Sonesen 2016/10/25 16:46:48 also then do I need to change it to bookmark? I th
72 except ConfigParser.NoOptionError:
73 self.bookmark = 'master'
74
68 self.revision = self.getCurrentRevision() 75 self.revision = self.getCurrentRevision()
69 try: 76 try:
70 self.previousRevision = config.latestRevision 77 self.previousRevision = config.latestRevision
71 except: 78 except:
72 self.previousRevision = '0' 79 self.previousRevision = '0'
73 self.buildNum = None 80 self.buildNum = None
74 self.tempdir = None 81 self.tempdir = None
75 self.outputFilename = None 82 self.outputFilename = None
76 self.changelogFilename = None 83 self.changelogFilename = None
77 84
78 def hasChanges(self): 85 def hasChanges(self):
79 return self.revision != self.previousRevision 86 return self.revision != self.previousRevision
80 87
81 def getCurrentRevision(self): 88 def getCurrentRevision(self):
82 """ 89 """
83 retrieves the current revision ID from the repository 90 retrieves the current revision ID from the repository
84 """ 91 """
85 command = [ 92 command = [
86 'hg', 'id', '-i', '-r', 'default', '--config', 'defaults.id=', 93 'hg', 'id', '-i', '-r', self.bookmark, '--config',
87 self.config.repository 94 'defaults.id=', self.config.repository
88 ] 95 ]
89 return subprocess.check_output(command).strip() 96 return subprocess.check_output(command).strip()
90 97
91 def getCurrentBuild(self): 98 def getCurrentBuild(self):
92 """ 99 """
93 calculates the (typically numerical) build ID for the current build 100 calculates the (typically numerical) build ID for the current build
94 """ 101 """
95 command = ['hg', 'id', '-n', '--config', 'defaults.id=', self.tempdir] 102 command = ['hg', 'id', '-n', '--config', 'defaults.id=', self.tempdir]
96 build = subprocess.check_output(command).strip() 103 build = subprocess.check_output(command).strip()
97 if self.config.type == 'gecko': 104 if self.config.type == 'gecko':
98 build += '-beta' 105 build += '-beta'
99 return build 106 return build
100 107
101 def getChanges(self): 108 def getChanges(self):
102 """ 109 """
103 retrieve changes between the current and previous ("first") revision 110 retrieve changes between the current and previous ("first") revision
104 """ 111 """
105 112
106 command = ['hg', 'log', '-R', self.tempdir, '-r', 'tip:0', 113 command = [
107 '-b', 'default', '-l', '50', '--encoding', 'utf-8', 114 'hg', 'log', '-R', self.tempdir, '-r', self.bookmark + ':0',
108 '--template', '{date|isodate}\\0{author|person}\\0{rev}\\0{de sc}\\0\\0', 115 '-b', 'default', '-l', '50', '--encoding', 'utf-8', '--template',
Wladimir Palant 2016/10/25 16:32:04 This is actually tricky now. The purpose of the `-
Jon Sonesen 2016/10/25 16:39:58 Are you saying I should literally change it to `hg
Wladimir Palant 2016/10/26 15:34:03 It should be ancestors({}) of course, with {} repl
109 '--config', 'defaults.log='] 116 '{date|isodate}\\0{author|person}\\0{rev}\\0{desc}\\0\\0',
117 '--config', 'defaults.log='
118 ]
110 result = subprocess.check_output(command).decode('utf-8') 119 result = subprocess.check_output(command).decode('utf-8')
111 120
112 for change in result.split('\x00\x00'): 121 for change in result.split('\x00\x00'):
113 if change: 122 if change:
114 date, author, revision, description = change.split('\x00') 123 date, author, revision, description = change.split('\x00')
115 yield {'date': date, 'author': author, 'revision': revision, 'de scription': description} 124 yield {'date': date, 'author': author, 'revision': revision, 'de scription': description}
116 125
117 def copyRepository(self): 126 def copyRepository(self):
118 """ 127 """
119 Create a repository copy in a temporary directory 128 Create a repository copy in a temporary directory
120 """ 129 """
121 self.tempdir = tempfile.mkdtemp(prefix=self.config.repositoryName) 130 self.tempdir = tempfile.mkdtemp(prefix=self.config.repositoryName)
122 command = ['hg', 'clone', '-q', self.config.repository, '-u', 'default', self.tempdir] 131 command = ['hg', 'clone', '-q', self.config.repository, '-u',
132 'default', self.tempdir]
Wladimir Palant 2016/10/25 16:32:04 Shouldn't this update to the bookmark?
Jon Sonesen 2016/10/25 16:39:58 I am not sure, are you saying I should add the -r
123 subprocess.check_call(command) 133 subprocess.check_call(command)
124 134
125 # Make sure to run ensure_dependencies.py if present 135 # Make sure to run ensure_dependencies.py if present
126 depscript = os.path.join(self.tempdir, 'ensure_dependencies.py') 136 depscript = os.path.join(self.tempdir, 'ensure_dependencies.py')
127 if os.path.isfile(depscript): 137 if os.path.isfile(depscript):
128 subprocess.check_call([sys.executable, depscript, '-q']) 138 subprocess.check_call([sys.executable, depscript, '-q'])
129 139
130 def writeChangelog(self, changes): 140 def writeChangelog(self, changes):
131 """ 141 """
132 write the changelog file into the cloned repository 142 write the changelog file into the cloned repository
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 except Exception as ex: 591 except Exception as ex:
582 logging.error('The build for %s failed:', repo) 592 logging.error('The build for %s failed:', repo)
583 logging.exception(ex) 593 logging.exception(ex)
584 594
585 file = open(nightlyConfigFile, 'wb') 595 file = open(nightlyConfigFile, 'wb')
586 nightlyConfig.write(file) 596 nightlyConfig.write(file)
587 597
588 598
589 if __name__ == '__main__': 599 if __name__ == '__main__':
590 main() 600 main()
OLDNEW

Powered by Google App Engine
This is Rietveld