OLD | NEW |
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 """SCM-specific utility classes.""" | 5 """SCM-specific utility classes.""" |
6 | 6 |
7 import cStringIO | 7 import cStringIO |
8 import glob | 8 import glob |
9 import logging | 9 import logging |
10 import os | 10 import os |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 # directory. | 560 # directory. |
561 if len(file_list) == previous_list_len: | 561 if len(file_list) == previous_list_len: |
562 if not IsKnownFailure(): | 562 if not IsKnownFailure(): |
563 # No known svn error was found, bail out. | 563 # No known svn error was found, bail out. |
564 raise | 564 raise |
565 # No file were checked out, so make sure the directory is | 565 # No file were checked out, so make sure the directory is |
566 # deleted in case it's messed up and try again. | 566 # deleted in case it's messed up and try again. |
567 # Warning: It's bad, it assumes args[2] is the directory | 567 # Warning: It's bad, it assumes args[2] is the directory |
568 # argument. | 568 # argument. |
569 if os.path.isdir(args[2]): | 569 if os.path.isdir(args[2]): |
570 gclient_utils.RemoveDirectory(args[2]) | 570 gclient_utils.rmtree(args[2]) |
571 else: | 571 else: |
572 # Progress was made, convert to update since an aborted checkout | 572 # Progress was made, convert to update since an aborted checkout |
573 # is now an update. | 573 # is now an update. |
574 args = ['update'] + args[1:] | 574 args = ['update'] + args[1:] |
575 else: | 575 else: |
576 # It was an update or export. | 576 # It was an update or export. |
577 # We enforce that some progress has been made or a known failure. | 577 # We enforce that some progress has been made or a known failure. |
578 if len(file_list) == previous_list_len and not IsKnownFailure(): | 578 if len(file_list) == previous_list_len and not IsKnownFailure(): |
579 # No known svn error was found and no progress, bail out. | 579 # No known svn error was found and no progress, bail out. |
580 raise | 580 raise |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 filename, cwd, data[filename], bogus_dir, full_move, revision)) | 849 filename, cwd, data[filename], bogus_dir, full_move, revision)) |
850 # Use StringIO since it can be messy when diffing a directory move with | 850 # Use StringIO since it can be messy when diffing a directory move with |
851 # full_move=True. | 851 # full_move=True. |
852 buf = cStringIO.StringIO() | 852 buf = cStringIO.StringIO() |
853 for d in filter(None, diffs): | 853 for d in filter(None, diffs): |
854 buf.write(d) | 854 buf.write(d) |
855 result = buf.getvalue() | 855 result = buf.getvalue() |
856 buf.close() | 856 buf.close() |
857 return result | 857 return result |
858 finally: | 858 finally: |
859 gclient_utils.RemoveDirectory(bogus_dir) | 859 gclient_utils.rmtree(bogus_dir) |
860 | 860 |
861 @staticmethod | 861 @staticmethod |
862 def _DiffItemInternal(filename, cwd, info, bogus_dir, full_move, revision): | 862 def _DiffItemInternal(filename, cwd, info, bogus_dir, full_move, revision): |
863 """Grabs the diff data.""" | 863 """Grabs the diff data.""" |
864 command = ["diff", "--config-dir", bogus_dir, filename] | 864 command = ["diff", "--config-dir", bogus_dir, filename] |
865 if revision: | 865 if revision: |
866 command.extend(['--revision', revision]) | 866 command.extend(['--revision', revision]) |
867 data = None | 867 data = None |
868 if SVN.IsMovedInfo(info): | 868 if SVN.IsMovedInfo(info): |
869 if full_move: | 869 if full_move: |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1047 if os.path.exists(file_path): | 1047 if os.path.exists(file_path): |
1048 # svn revert is really stupid. It fails on inconsistent line-endings, | 1048 # svn revert is really stupid. It fails on inconsistent line-endings, |
1049 # on switched directories, etc. So take no chance and delete everything! | 1049 # on switched directories, etc. So take no chance and delete everything! |
1050 # In theory, it wouldn't be necessary for property-only change but then | 1050 # In theory, it wouldn't be necessary for property-only change but then |
1051 # it'd have to look for switched directories, etc so it's not worth | 1051 # it'd have to look for switched directories, etc so it's not worth |
1052 # optimizing this use case. | 1052 # optimizing this use case. |
1053 if os.path.isfile(file_path) or os.path.islink(file_path): | 1053 if os.path.isfile(file_path) or os.path.islink(file_path): |
1054 logging.info('os.remove(%s)' % file_path) | 1054 logging.info('os.remove(%s)' % file_path) |
1055 os.remove(file_path) | 1055 os.remove(file_path) |
1056 elif os.path.isdir(file_path): | 1056 elif os.path.isdir(file_path): |
1057 logging.info('RemoveDirectory(%s)' % file_path) | 1057 logging.info('rmtree(%s)' % file_path) |
1058 gclient_utils.RemoveDirectory(file_path) | 1058 gclient_utils.rmtree(file_path) |
1059 else: | 1059 else: |
1060 logging.critical( | 1060 logging.critical( |
1061 ('No idea what is %s.\nYou just found a bug in gclient' | 1061 ('No idea what is %s.\nYou just found a bug in gclient' |
1062 ', please ping maruel@chromium.org ASAP!') % file_path) | 1062 ', please ping maruel@chromium.org ASAP!') % file_path) |
1063 | 1063 |
1064 if (file_status[0][0] in ('D', 'A', '!') or | 1064 if (file_status[0][0] in ('D', 'A', '!') or |
1065 not file_status[0][1:].isspace()): | 1065 not file_status[0][1:].isspace()): |
1066 # Added, deleted file requires manual intervention and require calling | 1066 # Added, deleted file requires manual intervention and require calling |
1067 # revert, like for properties. | 1067 # revert, like for properties. |
1068 if not os.path.isdir(cwd): | 1068 if not os.path.isdir(cwd): |
1069 # '.' was deleted. It's not worth continuing. | 1069 # '.' was deleted. It's not worth continuing. |
1070 return | 1070 return |
1071 try: | 1071 try: |
1072 SVN.Capture(['revert', file_status[1]], cwd=cwd) | 1072 SVN.Capture(['revert', file_status[1]], cwd=cwd) |
1073 except subprocess2.CalledProcessError: | 1073 except subprocess2.CalledProcessError: |
1074 if not os.path.exists(file_path): | 1074 if not os.path.exists(file_path): |
1075 continue | 1075 continue |
1076 raise | 1076 raise |
OLD | NEW |