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

Side by Side Diff: gclient_scm.py

Issue 6250177: Move reverting code from gclient_scm to scm to be able to reuse the code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Fix presubmit check Created 9 years, 10 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 | presubmit_canned_checks.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) 2010 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2010 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 logging 7 import logging
8 import os 8 import os
9 import posixpath 9 import posixpath
10 import re 10 import re
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 All reverted files will be appended to file_list, even if Subversion 831 All reverted files will be appended to file_list, even if Subversion
832 doesn't know about them. 832 doesn't know about them.
833 """ 833 """
834 if not os.path.isdir(self.checkout_path): 834 if not os.path.isdir(self.checkout_path):
835 # svn revert won't work if the directory doesn't exist. It needs to 835 # svn revert won't work if the directory doesn't exist. It needs to
836 # checkout instead. 836 # checkout instead.
837 print('\n_____ %s is missing, synching instead' % self.relpath) 837 print('\n_____ %s is missing, synching instead' % self.relpath)
838 # Don't reuse the args. 838 # Don't reuse the args.
839 return self.update(options, [], file_list) 839 return self.update(options, [], file_list)
840 840
841 for file_status in scm.SVN.CaptureStatus(self.checkout_path): 841 def printcb(file_status):
842 file_path = os.path.join(self.checkout_path, file_status[1]) 842 file_list.append(file_status[1])
843 # Temporarily forcibly delete externals to make sure chromium can build
844 # without svn:external's.
845 #if file_status[0][0] == 'X':
846 # # Ignore externals.
847 # logging.info('Ignoring external %s' % file_path)
848 # continue
849
850 if logging.getLogger().isEnabledFor(logging.INFO): 843 if logging.getLogger().isEnabledFor(logging.INFO):
851 logging.info('%s%s' % (file[0], file[1])) 844 logging.info('%s%s' % (file_status[0], file_status[1]))
852 else: 845 else:
853 print(file_path) 846 print(os.path.join(self.checkout_path, file_status[1]))
854 847 scm.SVN.Revert(self.checkout_path, callback=printcb)
855 if file_status[0].isspace():
856 logging.error('No idea what is the status of %s.\n'
857 'You just found a bug in gclient, please ping '
858 'maruel@chromium.org ASAP!' % file_path)
859 # svn revert is really stupid. It fails on inconsistent line-endings,
860 # on switched directories, etc. So take no chance and delete everything!
861 try:
862 if not os.path.exists(file_path):
863 pass
864 elif os.path.isfile(file_path) or os.path.islink(file_path):
865 logging.info('os.remove(%s)' % file_path)
866 os.remove(file_path)
867 elif os.path.isdir(file_path):
868 logging.info('gclient_utils.RemoveDirectory(%s)' % file_path)
869 gclient_utils.RemoveDirectory(file_path)
870 else:
871 logging.error('no idea what is %s.\nYou just found a bug in gclient'
872 ', please ping maruel@chromium.org ASAP!' % file_path)
873 except EnvironmentError:
874 logging.error('Failed to remove %s.' % file_path)
875 848
876 try: 849 try:
877 # svn revert is so broken we don't even use it. Using 850 # svn revert is so broken we don't even use it. Using
878 # "svn up --revision BASE" achieve the same effect. 851 # "svn up --revision BASE" achieve the same effect.
852 # file_list will contain duplicates.
879 self._RunAndGetFileList(['update', '--revision', 'BASE'], options, 853 self._RunAndGetFileList(['update', '--revision', 'BASE'], options,
880 file_list) 854 file_list)
881 except OSError, e: 855 except OSError, e:
882 # Maybe the directory disapeared meanwhile. We don't want it to throw an 856 # Maybe the directory disapeared meanwhile. Do not throw an exception.
883 # exception.
884 logging.error('Failed to update:\n%s' % str(e)) 857 logging.error('Failed to update:\n%s' % str(e))
885 858
886 def revinfo(self, options, args, file_list): 859 def revinfo(self, options, args, file_list):
887 """Display revision""" 860 """Display revision"""
888 try: 861 try:
889 return scm.SVN.CaptureRevision(self.checkout_path) 862 return scm.SVN.CaptureRevision(self.checkout_path)
890 except gclient_utils.Error: 863 except gclient_utils.Error:
891 return None 864 return None
892 865
893 def runhooks(self, options, args, file_list): 866 def runhooks(self, options, args, file_list):
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 904
932 This method returns a new list to be used as a command.""" 905 This method returns a new list to be used as a command."""
933 new_command = command[:] 906 new_command = command[:]
934 if revision: 907 if revision:
935 new_command.extend(['--revision', str(revision).strip()]) 908 new_command.extend(['--revision', str(revision).strip()])
936 # --force was added to 'svn update' in svn 1.5. 909 # --force was added to 'svn update' in svn 1.5.
937 if ((options.force or options.manually_grab_svn_rev) and 910 if ((options.force or options.manually_grab_svn_rev) and
938 scm.SVN.AssertVersion("1.5")[0]): 911 scm.SVN.AssertVersion("1.5")[0]):
939 new_command.append('--force') 912 new_command.append('--force')
940 return new_command 913 return new_command
OLDNEW
« no previous file with comments | « no previous file | presubmit_canned_checks.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698