Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(420)

Side by Side Diff: build/util/lastchange.py

Issue 6603022: Fix webkit build failure reported by evan@ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: regexp tweak Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """ 6 """
7 lastchange.py -- Chromium revision fetching utility. 7 lastchange.py -- Chromium revision fetching utility.
8 """ 8 """
9 9
10 import re 10 import re
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 def FetchGitSVNURL(directory): 123 def FetchGitSVNURL(directory):
124 """ 124 """
125 Fetch URL of SVN repository bound to git. 125 Fetch URL of SVN repository bound to git.
126 126
127 Errors are swallowed. 127 Errors are swallowed.
128 128
129 Returns: 129 Returns:
130 SVN URL. 130 SVN URL.
131 """ 131 """
132 if not IsGitSVN(directory): 132 if not IsGitSVN(directory):
133 return None 133 return ''
134 proc = RunGitCommand(directory, ['svn', 'info', '--url']) 134 proc = RunGitCommand(directory, ['svn', 'info', '--url'])
135 if proc: 135 if proc:
136 output = proc.communicate()[0].strip() 136 output = proc.communicate()[0].strip()
137 if proc.returncode == 0: 137 if proc.returncode == 0:
138 return output 138 match = re.search('^.*://.*$', output, re.M)
Evan Martin 2011/03/03 19:49:31 Maybe use r'^\w+://.*$' just to make it harder t
Denis Lagno 2011/03/03 20:18:39 Done. should I use those 'raw string literals'?
139 return None 139 if match:
140 return match.group(0)
141 return ''
142
143
144 def FetchGitSVNRoot(directory):
145 """
146 Fetch root of SVN repository bound to git.
Evan Martin 2011/03/03 19:49:31 This part of the change seems unrelated to the bug
Denis Lagno 2011/03/03 20:18:39 yes. But only now I realized how URL and Root are
147
148 Errors are swallowed.
149
150 Returns:
151 SVN root repository.
152 """
153 if not IsGitSVN(directory):
154 return ''
155 git_command = ['config', '--get-regexp', '^svn-remote.svn.url$']
156 proc = RunGitCommand(directory, git_command)
157 if proc:
158 output = proc.communicate()[0].strip()
159 if proc.returncode == 0:
160 match = re.search('\S*$', output)
161 if match:
162 return match.group(0)
163 return ''
140 164
141 165
142 def LookupGitSVNRevision(directory, depth): 166 def LookupGitSVNRevision(directory, depth):
143 """ 167 """
144 Fetch the Git-SVN identifier for the local tree. 168 Fetch the Git-SVN identifier for the local tree.
145 Parses first |depth| commit messages. 169 Parses first |depth| commit messages.
146 170
147 Errors are swallowed. 171 Errors are swallowed.
148 """ 172 """
149 if not IsGitSVN(directory): 173 if not IsGitSVN(directory):
150 return None 174 return None
151 git_re = re.compile('^\s*git-svn-id:\s+(\S+)@(\d+)', re.M) 175 git_re = re.compile('^\s*git-svn-id:\s+(\S+)@(\d+)')
152 proc = RunGitCommand(directory, ['log', '-' + str(depth)]) 176 proc = RunGitCommand(directory, ['log', '-' + str(depth)])
153 if proc: 177 if proc:
154 for line in proc.stdout: 178 for line in proc.stdout:
155 match = git_re.search(line) 179 match = git_re.search(line)
156 if match: 180 if match:
157 id = match.group(2) 181 id = match.group(2)
158 if id: 182 if id:
159 proc.stdout.close() # Cut pipe for fast exit. 183 proc.stdout.close() # Cut pipe for fast exit.
160 return id 184 return id
161 return None 185 return None
(...skipping 15 matching lines...) Expand all
177 Fetch the Git-SVN identifier for the local tree. 201 Fetch the Git-SVN identifier for the local tree.
178 202
179 Errors are swallowed. 203 Errors are swallowed.
180 """ 204 """
181 # We assume that at least first 999 commit messages contain svn evidence. 205 # We assume that at least first 999 commit messages contain svn evidence.
182 revision = LookupGitSVNRevision(directory, 999) 206 revision = LookupGitSVNRevision(directory, 999)
183 if not revision: 207 if not revision:
184 return None 208 return None
185 if IsGitSVNDirty(directory): 209 if IsGitSVNDirty(directory):
186 revision = revision + '-dirty' 210 revision = revision + '-dirty'
187 return VersionInfo(FetchGitSVNURL(directory), 'git-svn', revision) 211 url = FetchGitSVNURL(directory)
212 root = FetchGitSVNRoot(directory)
213 return VersionInfo(url, root, revision)
188 214
189 215
190 def FetchVersionInfo(default_lastchange, directory=None): 216 def FetchVersionInfo(default_lastchange, directory=None):
191 """ 217 """
192 Returns the last change (in the form of a branch, revision tuple), 218 Returns the last change (in the form of a branch, revision tuple),
193 from some appropriate revision control system. 219 from some appropriate revision control system.
194 """ 220 """
195 version_info = (FetchSVNRevision(directory) or 221 version_info = (FetchSVNRevision(directory) or
196 FetchGitSVNRevision(directory) or FetchGitRevision(directory)) 222 FetchGitSVNRevision(directory) or FetchGitRevision(directory))
197 if not version_info: 223 if not version_info:
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 if out_file: 277 if out_file:
252 WriteIfChanged(out_file, contents) 278 WriteIfChanged(out_file, contents)
253 else: 279 else:
254 sys.stdout.write(contents) 280 sys.stdout.write(contents)
255 281
256 return 0 282 return 0
257 283
258 284
259 if __name__ == '__main__': 285 if __name__ == '__main__':
260 sys.exit(main()) 286 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698