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

Side by Side Diff: gclient_scm.py

Issue 19777004: Catch and print OSError instead of Exception. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Use stderr Created 7 years, 5 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 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 """Gclient-specific SCM-specific operations.""" 5 """Gclient-specific SCM-specific operations."""
6 6
7 import collections 7 import collections
8 import logging 8 import logging
9 import os 9 import os
10 import posixpath 10 import posixpath
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 When we go from with-cache to direct, assume that the normal url-switching 754 When we go from with-cache to direct, assume that the normal url-switching
755 code already flipped the remote over, and we just need to repack and break 755 code already flipped the remote over, and we just need to repack and break
756 the dependency to the cache. 756 the dependency to the cache.
757 """ 757 """
758 758
759 altfile = os.path.join( 759 altfile = os.path.join(
760 self.checkout_path, '.git', 'objects', 'info', 'alternates') 760 self.checkout_path, '.git', 'objects', 'info', 'alternates')
761 if self.cache_dir: 761 if self.cache_dir:
762 if not os.path.exists(altfile): 762 if not os.path.exists(altfile):
763 try: 763 try:
764 with open(altfile, 'wa') as f: 764 with open(altfile, 'w') as f:
765 f.write(os.path.join(url, 'objects')) 765 f.write(os.path.join(url, 'objects'))
766 # pylint: disable=C0301 766 # pylint: disable=C0301
767 # This dance is necessary according to emperical evidence, also at: 767 # This dance is necessary according to emperical evidence, also at:
768 # http://lists-archives.com/git/713652-retrospectively-add-alternates- to-a-repository.html 768 # http://lists-archives.com/git/713652-retrospectively-add-alternates- to-a-repository.html
769 self._Run(['repack', '-ad'], options) 769 self._Run(['repack', '-ad'], options)
770 self._Run(['repack', '-adl'], options) 770 self._Run(['repack', '-adl'], options)
771 except Exception: 771 except Exception:
772 # If something goes wrong, try to remove the altfile so we'll go down 772 # If something goes wrong, try to remove the altfile so we'll go down
773 # this path again next time. 773 # this path again next time.
774 try: 774 try:
775 os.remove(altfile) 775 os.remove(altfile)
776 except Exception: 776 except OSError as e:
777 pass 777 print >> sys.stderr, "FAILED: os.remove('%s') -> %s" % (altfile, e)
778 raise 778 raise
779 else: 779 else:
780 if os.path.exists(altfile): 780 if os.path.exists(altfile):
781 self._Run(['repack', '-a'], options) 781 self._Run(['repack', '-a'], options)
782 os.remove(altfile) 782 os.remove(altfile)
783 783
784 def _CreateOrUpdateCache(self, url, options): 784 def _CreateOrUpdateCache(self, url, options):
785 """Make a new git mirror or update existing mirror for |url|, and return the 785 """Make a new git mirror or update existing mirror for |url|, and return the
786 mirror URI to clone from. 786 mirror URI to clone from.
787 787
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
1506 new_command.append('--force') 1506 new_command.append('--force')
1507 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1507 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1508 new_command.extend(('--accept', 'theirs-conflict')) 1508 new_command.extend(('--accept', 'theirs-conflict'))
1509 elif options.manually_grab_svn_rev: 1509 elif options.manually_grab_svn_rev:
1510 new_command.append('--force') 1510 new_command.append('--force')
1511 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1511 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1512 new_command.extend(('--accept', 'postpone')) 1512 new_command.extend(('--accept', 'postpone'))
1513 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1513 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1514 new_command.extend(('--accept', 'postpone')) 1514 new_command.extend(('--accept', 'postpone'))
1515 return new_command 1515 return new_command
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