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: Adressing comments adds single unit test Created Oct. 24, 2016, 5:24 p.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 )
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 = ['hg', 'log', '-R', self.tempdir, '-r', self.bookmark + ':0',
107 '-b', 'default', '-l', '50', '--encoding', 'utf-8', 114 '-l', '50', '--encoding', 'utf-8', '--template',
108 '--template', '{date|isodate}\\0{author|person}\\0{rev}\\0{de sc}\\0\\0', 115 '{date|isodate}\\0{author|person}\\0{rev}\\0{desc}\\0\\0',
109 '--config', 'defaults.log='] 116 '--config', 'defaults.log=']
110 result = subprocess.check_output(command).decode('utf-8') 117 result = subprocess.check_output(command).decode('utf-8')
111 118
112 for change in result.split('\x00\x00'): 119 for change in result.split('\x00\x00'):
113 if change: 120 if change:
114 date, author, revision, description = change.split('\x00') 121 date, author, revision, description = change.split('\x00')
115 yield {'date': date, 'author': author, 'revision': revision, 'de scription': description} 122 yield {'date': date, 'author': author, 'revision': revision, 'de scription': description}
116 123
117 def copyRepository(self): 124 def copyRepository(self):
118 """ 125 """
119 Create a repository copy in a temporary directory 126 Create a repository copy in a temporary directory
120 """ 127 """
121 self.tempdir = tempfile.mkdtemp(prefix=self.config.repositoryName) 128 self.tempdir = tempfile.mkdtemp(prefix=self.config.repositoryName)
122 command = ['hg', 'clone', '-q', self.config.repository, '-u', 'default', self.tempdir] 129 command = ['hg', 'clone', '-q', self.config.repository, '-u',
130 'default', self.tempdir]
123 subprocess.check_call(command) 131 subprocess.check_call(command)
124 132
125 # Make sure to run ensure_dependencies.py if present 133 # Make sure to run ensure_dependencies.py if present
126 depscript = os.path.join(self.tempdir, 'ensure_dependencies.py') 134 depscript = os.path.join(self.tempdir, 'ensure_dependencies.py')
127 if os.path.isfile(depscript): 135 if os.path.isfile(depscript):
128 subprocess.check_call([sys.executable, depscript, '-q']) 136 subprocess.check_call([sys.executable, depscript, '-q'])
129 137
130 def writeChangelog(self, changes): 138 def writeChangelog(self, changes):
131 """ 139 """
132 write the changelog file into the cloned repository 140 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: 589 except Exception as ex:
582 logging.error('The build for %s failed:', repo) 590 logging.error('The build for %s failed:', repo)
583 logging.exception(ex) 591 logging.exception(ex)
584 592
585 file = open(nightlyConfigFile, 'wb') 593 file = open(nightlyConfigFile, 'wb')
586 nightlyConfig.write(file) 594 nightlyConfig.write(file)
587 595
588 596
589 if __name__ == '__main__': 597 if __name__ == '__main__':
590 main() 598 main()
OLDNEW

Powered by Google App Engine
This is Rietveld