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

Side by Side Diff: scm.py

Issue 501106: Get rid of gcl.ReadFile. (Closed)
Patch Set: Created 11 years 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
« no previous file with comments | « gcl.py ('k') | tests/gcl_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """SCM-specific utility classes.""" 5 """SCM-specific utility classes."""
6 6
7 import os 7 import os
8 import re 8 import re
9 import subprocess 9 import subprocess
10 import sys 10 import sys
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 else: 409 else:
410 parent_dir = sys.path[0] # tempdir is not secure. 410 parent_dir = sys.path[0] # tempdir is not secure.
411 bogus_dir = os.path.join(parent_dir, "temp_svn_config") 411 bogus_dir = os.path.join(parent_dir, "temp_svn_config")
412 if not os.path.exists(bogus_dir): 412 if not os.path.exists(bogus_dir):
413 os.mkdir(bogus_dir) 413 os.mkdir(bogus_dir)
414 # Grabs the diff data. 414 # Grabs the diff data.
415 data = SVN.Capture(["diff", "--config-dir", bogus_dir, filename], None) 415 data = SVN.Capture(["diff", "--config-dir", bogus_dir, filename], None)
416 416
417 # We know the diff will be incorrectly formatted. Fix it. 417 # We know the diff will be incorrectly formatted. Fix it.
418 if SVN.IsMoved(filename): 418 if SVN.IsMoved(filename):
419 # The file is "new" in the patch sense. Generate a homebrew diff. 419 file_content = gclient_utils.FileRead(filename, 'rb')
420 # We can't use ReadFile() since it's not using binary mode.
421 file_handle = open(filename, 'rb')
422 file_content = file_handle.read()
423 file_handle.close()
424 # Prepend '+' to every lines. 420 # Prepend '+' to every lines.
425 file_content = ['+' + i for i in file_content.splitlines(True)] 421 file_content = ['+' + i for i in file_content.splitlines(True)]
426 nb_lines = len(file_content) 422 nb_lines = len(file_content)
427 # We need to use / since patch on unix will fail otherwise. 423 # We need to use / since patch on unix will fail otherwise.
428 filename = filename.replace('\\', '/') 424 filename = filename.replace('\\', '/')
429 data = "Index: %s\n" % filename 425 data = "Index: %s\n" % filename
430 data += ("=============================================================" 426 data += ("============================================================="
431 "======\n") 427 "======\n")
432 # Note: Should we use /dev/null instead? 428 # Note: Should we use /dev/null instead?
433 data += "--- %s\n" % filename 429 data += "--- %s\n" % filename
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 479
484 while True: 480 while True:
485 key = ReadOneItem('K') 481 key = ReadOneItem('K')
486 if not key: 482 if not key:
487 break 483 break
488 value = ReadOneItem('V') 484 value = ReadOneItem('V')
489 if not value: 485 if not value:
490 break 486 break
491 values[key] = value 487 values[key] = value
492 return values 488 return values
OLDNEW
« no previous file with comments | « gcl.py ('k') | tests/gcl_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698