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

Side by Side Diff: tools/svndiff.py

Issue 49323006: svndiff for the windows (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Address Elliot's comments Created 7 years, 1 month 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!)
11 checkout. 11 checkout.
12 12
13 Launch with --help to see more information. 13 Launch with --help to see more information.
14 14
15 TODO(epoger): Now that this tool supports either git or svn, rename it. 15 TODO(epoger): Now that this tool supports either git or svn, rename it.
16 TODO(epoger): Fix indentation in this file (2-space indents, not 4-space). 16 TODO(epoger): Fix indentation in this file (2-space indents, not 4-space).
17 ''' 17 '''
18 18
19 # common Python modules 19 # common Python modules
20 import optparse 20 import optparse
21 import os 21 import os
22 import posixpath
22 import re 23 import re
23 import shutil 24 import shutil
24 import subprocess 25 import subprocess
25 import sys 26 import sys
26 import tempfile 27 import tempfile
27 import urllib2 28 import urllib2
28 29
29 # Imports from within Skia 30 # Imports from within Skia
30 # 31 #
31 # We need to add the 'gm' directory, so that we can import gm_json.py within 32 # We need to add the 'gm' directory, so that we can import gm_json.py within
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 81
81 @param user_set_path if None, the user did not specify a path, so look in 82 @param user_set_path if None, the user did not specify a path, so look in
82 some likely places; otherwise, only check at this path 83 some likely places; otherwise, only check at this path
83 """ 84 """
84 if user_set_path is not None: 85 if user_set_path is not None:
85 if os.path.isfile(user_set_path): 86 if os.path.isfile(user_set_path):
86 return user_set_path 87 return user_set_path
87 raise Exception('unable to find skdiff at user-set path %s' % 88 raise Exception('unable to find skdiff at user-set path %s' %
88 user_set_path) 89 user_set_path)
89 trunk_path = os.path.join(os.path.dirname(__file__), os.pardir) 90 trunk_path = os.path.join(os.path.dirname(__file__), os.pardir)
90 possible_paths = [os.path.join(trunk_path, 'out', 'Release', 'skdiff'), 91
91 os.path.join(trunk_path, 'out', 'Debug', 'skdiff')] 92 extension = ''
93 if os.name is 'nt':
94 extension = '.exe'
95
96 possible_paths = [os.path.join(trunk_path, 'out', 'Release',
97 'skdiff' + extension),
98 os.path.join(trunk_path, 'out', 'Debug',
99 'skdiff' + extension)]
92 for try_path in possible_paths: 100 for try_path in possible_paths:
93 if os.path.isfile(try_path): 101 if os.path.isfile(try_path):
94 return try_path 102 return try_path
95 raise Exception('cannot find skdiff in paths %s; maybe you need to ' 103 raise Exception('cannot find skdiff in paths %s; maybe you need to '
96 'specify the %s option or build skdiff?' % ( 104 'specify the %s option or build skdiff?' % (
97 possible_paths, OPTION_PATH_TO_SKDIFF)) 105 possible_paths, OPTION_PATH_TO_SKDIFF))
98 106
99 def _DownloadUrlToFile(source_url, dest_path): 107 def _DownloadUrlToFile(source_url, dest_path):
100 """Download source_url, and save its contents to dest_path. 108 """Download source_url, and save its contents to dest_path.
101 Raises an exception if there were any problems.""" 109 Raises an exception if there were any problems."""
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 """ 203 """
196 # TODO(epoger): Replace use of "git show" command with lower-level git 204 # TODO(epoger): Replace use of "git show" command with lower-level git
197 # commands? senorblanco points out that "git show" is a "porcelain" 205 # commands? senorblanco points out that "git show" is a "porcelain"
198 # command, intended for human use, as opposed to the "plumbing" commands 206 # command, intended for human use, as opposed to the "plumbing" commands
199 # generally more suitable for scripting. (See 207 # generally more suitable for scripting. (See
200 # http://git-scm.com/book/en/Git-Internals-Plumbing-and-Porcelain ) 208 # http://git-scm.com/book/en/Git-Internals-Plumbing-and-Porcelain )
201 # 209 #
202 # For now, though, "git show" is the most straightforward implementation 210 # For now, though, "git show" is the most straightforward implementation
203 # I could come up with. I tried using "git cat-file", but I had trouble 211 # I could come up with. I tried using "git cat-file", but I had trouble
204 # getting it to work as desired. 212 # getting it to work as desired.
205 args = ['git', 'show', os.path.join('HEAD:.', file_within_repo)] 213 # Note that git expects / rather than \ as a path separator even on
214 # windows.
215 args = ['git', 'show', posixpath.join('HEAD:.', file_within_repo)]
206 with open(dest_path, 'wb') as outfile: 216 with open(dest_path, 'wb') as outfile:
207 proc = subprocess.Popen(args, stdout=outfile) 217 proc = subprocess.Popen(args, stdout=outfile)
208 proc.communicate() 218 proc.communicate()
209 if proc.returncode is not 0: 219 if proc.returncode is not 0:
210 raise Exception('command "%s" failed' % args) 220 raise Exception('command "%s" failed' % args)
211 221
212 def SvnDiff(path_to_skdiff, dest_dir, source_dir): 222 def SvnDiff(path_to_skdiff, dest_dir, source_dir):
213 """Generates a visual diff of all pending changes in source_dir. 223 """Generates a visual diff of all pending changes in source_dir.
214 224
215 @param path_to_skdiff 225 @param path_to_skdiff
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 help='path to already-built skdiff tool; if not set, ' 327 help='path to already-built skdiff tool; if not set, '
318 'will search for it in typical directories near this ' 328 'will search for it in typical directories near this '
319 'script') 329 'script')
320 parser.add_option(OPTION_SOURCE_DIR, 330 parser.add_option(OPTION_SOURCE_DIR,
321 action='store', type='string', 331 action='store', type='string',
322 default=os.path.join('expectations', 'gm'), 332 default=os.path.join('expectations', 'gm'),
323 help='root directory within which to compare all ' + 333 help='root directory within which to compare all ' +
324 'files; defaults to "%default"') 334 'files; defaults to "%default"')
325 (options, args) = parser.parse_args() 335 (options, args) = parser.parse_args()
326 Main(options, args) 336 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