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

Side by Side Diff: gclient_scm.py

Issue 3171015: Add flushing to gclient revert. (Closed)
Patch Set: Created 10 years, 4 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
« 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) 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
11 import subprocess 11 import subprocess
12 import time 12 import time
13 import sys
chase 2010/08/18 16:59:57 nit: move above 'import time'
13 14
14 import scm 15 import scm
15 import gclient_utils 16 import gclient_utils
16 17
17 18
18 class DiffFilterer(object): 19 class DiffFilterer(object):
19 """Simple class which tracks which file is being diffed and 20 """Simple class which tracks which file is being diffed and
20 replaces instances of its file name in the original and 21 replaces instances of its file name in the original and
21 working copy lines of the svn/git diff output.""" 22 working copy lines of the svn/git diff output."""
22 index_string = "Index: " 23 index_string = "Index: "
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 doesn't know about them. 867 doesn't know about them.
867 """ 868 """
868 path = os.path.join(self._root_dir, self.relpath) 869 path = os.path.join(self._root_dir, self.relpath)
869 if not os.path.isdir(path): 870 if not os.path.isdir(path):
870 # svn revert won't work if the directory doesn't exist. It needs to 871 # svn revert won't work if the directory doesn't exist. It needs to
871 # checkout instead. 872 # checkout instead.
872 print("\n_____ %s is missing, synching instead" % self.relpath) 873 print("\n_____ %s is missing, synching instead" % self.relpath)
873 # Don't reuse the args. 874 # Don't reuse the args.
874 return self.update(options, [], file_list) 875 return self.update(options, [], file_list)
875 876
877 # Do a flush of sys.stdout every 10 secs or so otherwise it may never be
878 # flushed fast enough for buildbot.
879 last_flushed_at = time.time()
880 sys.stdout.flush()
881
876 for file_status in scm.SVN.CaptureStatus(path): 882 for file_status in scm.SVN.CaptureStatus(path):
877 file_path = os.path.join(path, file_status[1]) 883 file_path = os.path.join(path, file_status[1])
878 if file_status[0][0] == 'X': 884 if file_status[0][0] == 'X':
879 # Ignore externals. 885 # Ignore externals.
880 logging.info('Ignoring external %s' % file_path) 886 logging.info('Ignoring external %s' % file_path)
881 continue 887 continue
882 888
883 if logging.getLogger().isEnabledFor(logging.INFO): 889 if logging.getLogger().isEnabledFor(logging.INFO):
884 logging.info('%s%s' % (file[0], file[1])) 890 logging.info('%s%s' % (file[0], file[1]))
885 else: 891 else:
886 print(file_path) 892 print(file_path)
893 # Flush at least 10 seconds between line writes. We wait at least 10
894 # seconds to avoid overloading the reader that called us with output,
895 # which can slow busy readers down.
896 if (time.time() - last_flushed_at) > 10:
897 last_flushed_at = time.time()
898 sys.stdout.flush()
899
887 if file_status[0].isspace(): 900 if file_status[0].isspace():
888 logging.error('No idea what is the status of %s.\n' 901 logging.error('No idea what is the status of %s.\n'
889 'You just found a bug in gclient, please ping ' 902 'You just found a bug in gclient, please ping '
890 'maruel@chromium.org ASAP!' % file_path) 903 'maruel@chromium.org ASAP!' % file_path)
891 # svn revert is really stupid. It fails on inconsistent line-endings, 904 # svn revert is really stupid. It fails on inconsistent line-endings,
892 # on switched directories, etc. So take no chance and delete everything! 905 # on switched directories, etc. So take no chance and delete everything!
893 try: 906 try:
894 if not os.path.exists(file_path): 907 if not os.path.exists(file_path):
895 pass 908 pass
896 elif os.path.isfile(file_path) or os.path.islink(file_path): 909 elif os.path.isfile(file_path) or os.path.islink(file_path):
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 961
949 This method returns a new list to be used as a command.""" 962 This method returns a new list to be used as a command."""
950 new_command = command[:] 963 new_command = command[:]
951 if revision: 964 if revision:
952 new_command.extend(['--revision', str(revision).strip()]) 965 new_command.extend(['--revision', str(revision).strip()])
953 # --force was added to 'svn update' in svn 1.5. 966 # --force was added to 'svn update' in svn 1.5.
954 if ((options.force or options.manually_grab_svn_rev) and 967 if ((options.force or options.manually_grab_svn_rev) and
955 scm.SVN.AssertVersion("1.5")[0]): 968 scm.SVN.AssertVersion("1.5")[0]):
956 new_command.append('--force') 969 new_command.append('--force')
957 return new_command 970 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