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

Side by Side Diff: tools/svndiff.py

Issue 23902030: Use relative paths in svndiff, so results can be exported by Apache (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 3 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/python 1 #!/usr/bin/python
2 ''' 2 '''
3 Copyright 2012 Google Inc. 3 Copyright 2012 Google Inc.
4 4
5 Use of this source code is governed by a BSD-style license that can be 5 Use of this source code is governed by a BSD-style license that can be
6 found in the LICENSE file. 6 found in the LICENSE file.
7 ''' 7 '''
8 8
9 ''' 9 '''
10 Generates a visual diff of all pending changes in the local SVN (or git!) 10 Generates a visual diff of all pending changes in the local SVN (or git!)
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 """Generates a visual diff of all pending changes in source_dir. 213 """Generates a visual diff of all pending changes in source_dir.
214 214
215 @param path_to_skdiff 215 @param path_to_skdiff
216 @param dest_dir existing directory within which to write results 216 @param dest_dir existing directory within which to write results
217 @param source_dir 217 @param source_dir
218 """ 218 """
219 # Validate parameters, filling in default values if necessary and possible. 219 # Validate parameters, filling in default values if necessary and possible.
220 path_to_skdiff = os.path.abspath(FindPathToSkDiff(path_to_skdiff)) 220 path_to_skdiff = os.path.abspath(FindPathToSkDiff(path_to_skdiff))
221 if not dest_dir: 221 if not dest_dir:
222 dest_dir = tempfile.mkdtemp() 222 dest_dir = tempfile.mkdtemp()
223 dest_dir = os.path.abspath(dest_dir)
224 223
225 os.chdir(source_dir) 224 using_svn = os.path.isdir(os.path.join(source_dir, '.svn'))
226 using_svn = os.path.isdir('.svn')
227 225
228 # Prepare temporary directories. 226 # Prepare temporary directories.
229 modified_flattened_dir = os.path.join(dest_dir, 'modified_flattened') 227 modified_flattened_dir = os.path.join(dest_dir, 'modified_flattened')
230 original_flattened_dir = os.path.join(dest_dir, 'original_flattened') 228 original_flattened_dir = os.path.join(dest_dir, 'original_flattened')
231 diff_dir = os.path.join(dest_dir, 'diffs') 229 diff_dir = os.path.join(dest_dir, 'diffs')
232 for dir in [modified_flattened_dir, original_flattened_dir, diff_dir] : 230 for dir in [modified_flattened_dir, original_flattened_dir, diff_dir] :
233 shutil.rmtree(dir, ignore_errors=True) 231 shutil.rmtree(dir, ignore_errors=True)
234 os.mkdir(dir) 232 os.mkdir(dir)
235 233
236 # Get a list of all locally modified (including added/deleted) files, 234 # Get a list of all locally modified (including added/deleted) files,
237 # descending subdirectories. 235 # descending subdirectories.
238 if using_svn: 236 if using_svn:
239 svn_repo = svn.Svn('.') 237 svn_repo = svn.Svn(source_dir)
240 modified_file_paths = svn_repo.GetFilesWithStatus( 238 modified_file_paths = svn_repo.GetFilesWithStatus(
241 svn.STATUS_ADDED | svn.STATUS_DELETED | svn.STATUS_MODIFIED) 239 svn.STATUS_ADDED | svn.STATUS_DELETED | svn.STATUS_MODIFIED)
242 else: 240 else:
243 modified_file_paths = _GitGetModifiedFiles() 241 modified_file_paths = _GitGetModifiedFiles()
epoger 2013/09/13 20:26:27 DO NOT COMMIT AS-IS... this won't work with git.
244 242
245 # For each modified file: 243 # For each modified file:
246 # 1. copy its current contents into modified_flattened_dir 244 # 1. copy its current contents into modified_flattened_dir
247 # 2. copy its original contents into original_flattened_dir 245 # 2. copy its original contents into original_flattened_dir
248 for modified_file_path in modified_file_paths: 246 for modified_file_path in modified_file_paths:
249 if modified_file_path.endswith('.json'): 247 if modified_file_path.endswith('.json'):
250 # Special handling for JSON files, in the hopes that they 248 # Special handling for JSON files, in the hopes that they
251 # contain GM result summaries. 249 # contain GM result summaries.
252 (_unused, original_file_path) = tempfile.mkstemp() 250 (_unused, original_file_path) = tempfile.mkstemp()
253 if using_svn: 251 if using_svn:
254 svn_repo.ExportBaseVersionOfFile( 252 svn_repo.ExportBaseVersionOfFile(
255 modified_file_path, original_file_path) 253 modified_file_path, original_file_path)
256 else: 254 else:
257 _GitExportBaseVersionOfFile( 255 _GitExportBaseVersionOfFile(
258 modified_file_path, original_file_path) 256 modified_file_path, original_file_path)
259 platform_prefix = re.sub(os.sep, '__', 257 platform_prefix = re.sub(os.sep, '__',
260 os.path.dirname(modified_file_path)) + '__' 258 os.path.dirname(modified_file_path)) + '__'
261 _CallJsonDiff(old_json_path=original_file_path, 259 _CallJsonDiff(old_json_path=original_file_path,
262 new_json_path=modified_file_path, 260 new_json_path=os.path.join(source_dir, modified_file_p ath),
263 old_flattened_dir=original_flattened_dir, 261 old_flattened_dir=original_flattened_dir,
264 new_flattened_dir=modified_flattened_dir, 262 new_flattened_dir=modified_flattened_dir,
265 filename_prefix=platform_prefix) 263 filename_prefix=platform_prefix)
266 os.remove(original_file_path) 264 os.remove(original_file_path)
267 else: 265 else:
268 dest_filename = re.sub(os.sep, '__', modified_file_path) 266 dest_filename = re.sub(os.sep, '__', modified_file_path)
269 # If the file had STATUS_DELETED, it won't exist anymore... 267 # If the file had STATUS_DELETED, it won't exist anymore...
270 if os.path.isfile(modified_file_path): 268 if os.path.isfile(modified_file_path):
271 shutil.copyfile(modified_file_path, 269 shutil.copyfile(modified_file_path,
272 os.path.join(modified_flattened_dir, 270 os.path.join(modified_flattened_dir,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 help='path to already-built skdiff tool; if not set, ' 308 help='path to already-built skdiff tool; if not set, '
311 'will search for it in typical directories near this ' 309 'will search for it in typical directories near this '
312 'script') 310 'script')
313 parser.add_option(OPTION_SOURCE_DIR, 311 parser.add_option(OPTION_SOURCE_DIR,
314 action='store', type='string', 312 action='store', type='string',
315 default=os.path.join('expectations', 'gm'), 313 default=os.path.join('expectations', 'gm'),
316 help='root directory within which to compare all ' + 314 help='root directory within which to compare all ' +
317 'files; defaults to "%default"') 315 'files; defaults to "%default"')
318 (options, args) = parser.parse_args() 316 (options, args) = parser.parse_args()
319 Main(options, args) 317 Main(options, args)
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