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 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 SVN.CaptureLocalInfo([filename], cwd), | 796 SVN.CaptureLocalInfo([filename], cwd), |
797 bogus_dir, | 797 bogus_dir, |
798 full_move, | 798 full_move, |
799 revision) | 799 revision) |
800 finally: | 800 finally: |
801 gclient_utils.RemoveDirectory(bogus_dir) | 801 gclient_utils.RemoveDirectory(bogus_dir) |
802 | 802 |
803 @staticmethod | 803 @staticmethod |
804 def _DiffItemInternal(filename, cwd, info, bogus_dir, full_move, revision): | 804 def _DiffItemInternal(filename, cwd, info, bogus_dir, full_move, revision): |
805 """Grabs the diff data.""" | 805 """Grabs the diff data.""" |
806 command = ["diff", "--config-dir", bogus_dir, filename] | 806 command = ["diff", "--diff-cmd", "diff", "--config-dir", bogus_dir, |
| 807 filename] |
807 if revision: | 808 if revision: |
808 command.extend(['--revision', revision]) | 809 command.extend(['--revision', revision]) |
809 data = None | 810 data = None |
810 if SVN.IsMovedInfo(info): | 811 if SVN.IsMovedInfo(info): |
811 if full_move: | 812 if full_move: |
812 if info.get("Node Kind") == "directory": | 813 if info.get("Node Kind") == "directory": |
813 # Things become tricky here. It's a directory copy/move. We need to | 814 # Things become tricky here. It's a directory copy/move. We need to |
814 # diff all the files inside it. | 815 # diff all the files inside it. |
815 # This will put a lot of pressure on the heap. This is why StringIO | 816 # This will put a lot of pressure on the heap. This is why StringIO |
816 # is used and converted back into a string at the end. The reason to | 817 # is used and converted back into a string at the end. The reason to |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
908 src = srcurl[len(file_root)+1:] | 909 src = srcurl[len(file_root)+1:] |
909 try: | 910 try: |
910 srcinfo = SVN.CaptureRemoteInfo(srcurl) | 911 srcinfo = SVN.CaptureRemoteInfo(srcurl) |
911 except subprocess2.CalledProcessError, e: | 912 except subprocess2.CalledProcessError, e: |
912 if not 'Not a valid URL' in e.stderr: | 913 if not 'Not a valid URL' in e.stderr: |
913 raise | 914 raise |
914 # Assume the file was deleted. No idea how to figure out at which | 915 # Assume the file was deleted. No idea how to figure out at which |
915 # revision the file was deleted. | 916 # revision the file was deleted. |
916 srcinfo = {'Revision': rev} | 917 srcinfo = {'Revision': rev} |
917 if (srcinfo.get('Revision') != rev and | 918 if (srcinfo.get('Revision') != rev and |
918 SVN.Capture(['diff', '-r', '%d:head' % rev, srcurl], cwd)): | 919 SVN.Capture(['diff', '--diff-cmd', 'diff', '-r', |
| 920 '%d:head' % rev, srcurl], cwd)): |
919 metaheaders.append("#$ svn cp -r %d %s %s " | 921 metaheaders.append("#$ svn cp -r %d %s %s " |
920 "### WARNING: note non-trunk copy\n" % | 922 "### WARNING: note non-trunk copy\n" % |
921 (rev, src, filename)) | 923 (rev, src, filename)) |
922 else: | 924 else: |
923 metaheaders.append("#$ cp %s %s\n" % (src, | 925 metaheaders.append("#$ cp %s %s\n" % (src, |
924 filename)) | 926 filename)) |
925 | 927 |
926 if metaheaders: | 928 if metaheaders: |
927 diffs.append("### BEGIN SVN COPY METADATA\n") | 929 diffs.append("### BEGIN SVN COPY METADATA\n") |
928 diffs.extend(metaheaders) | 930 diffs.extend(metaheaders) |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1096 # revert, like for properties. | 1098 # revert, like for properties. |
1097 if not os.path.isdir(cwd): | 1099 if not os.path.isdir(cwd): |
1098 # '.' was deleted. It's not worth continuing. | 1100 # '.' was deleted. It's not worth continuing. |
1099 return | 1101 return |
1100 try: | 1102 try: |
1101 SVN.Capture(['revert', file_status[1]], cwd=cwd) | 1103 SVN.Capture(['revert', file_status[1]], cwd=cwd) |
1102 except subprocess2.CalledProcessError: | 1104 except subprocess2.CalledProcessError: |
1103 if not os.path.exists(file_path): | 1105 if not os.path.exists(file_path): |
1104 continue | 1106 continue |
1105 raise | 1107 raise |
OLD | NEW |