OLD | NEW |
1 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2006-2009 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 os | 9 import os |
10 import re | 10 import re |
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
793 # work, since they can have another diff executable in their path that | 793 # work, since they can have another diff executable in their path that |
794 # gives different line endings. So we use a bogus temp directory as the | 794 # gives different line endings. So we use a bogus temp directory as the |
795 # config directory, which gets around these problems. | 795 # config directory, which gets around these problems. |
796 bogus_dir = tempfile.mkdtemp() | 796 bogus_dir = tempfile.mkdtemp() |
797 try: | 797 try: |
798 os.chdir(root) | 798 os.chdir(root) |
799 # Cleanup filenames | 799 # Cleanup filenames |
800 filenames = [RelativePath(f, root) for f in filenames] | 800 filenames = [RelativePath(f, root) for f in filenames] |
801 # Get information about the modified items (files and directories) | 801 # Get information about the modified items (files and directories) |
802 data = dict([(f, SVN.CaptureInfo(f)) for f in filenames]) | 802 data = dict([(f, SVN.CaptureInfo(f)) for f in filenames]) |
| 803 diffs = [] |
803 if full_move: | 804 if full_move: |
804 # Eliminate modified files inside moved/copied directory. | 805 # Eliminate modified files inside moved/copied directory. |
805 for (filename, info) in data.iteritems(): | 806 for (filename, info) in data.iteritems(): |
806 if SVN.IsMovedInfo(info) and info.get("Node Kind") == "directory": | 807 if SVN.IsMovedInfo(info) and info.get("Node Kind") == "directory": |
807 # Remove files inside the directory. | 808 # Remove files inside the directory. |
808 filenames = [f for f in filenames | 809 filenames = [f for f in filenames |
809 if not f.startswith(filename + os.path.sep)] | 810 if not f.startswith(filename + os.path.sep)] |
810 for filename in data.keys(): | 811 for filename in data.keys(): |
811 if not filename in filenames: | 812 if not filename in filenames: |
812 # Remove filtered out items. | 813 # Remove filtered out items. |
813 del data[filename] | 814 del data[filename] |
| 815 else: |
| 816 metaheaders = [] |
| 817 for (filename, info) in data.iteritems(): |
| 818 if SVN.IsMovedInfo(info): |
| 819 # for now, the most common case is a head copy, |
| 820 # so let's just encode that as a straight up cp. |
| 821 srcurl = info.get('Copied From URL') |
| 822 root = info.get('Repository Root') |
| 823 rev = int(info.get('Copied From Rev')) |
| 824 assert srcurl.startswith(root) |
| 825 src = srcurl[len(root)+1:] |
| 826 srcinfo = SVN.CaptureInfo(srcurl) |
| 827 if (srcinfo.get('Revision') != rev and |
| 828 SVN.Capture(['diff', '-r', '%d:head' % rev, srcurl])): |
| 829 metaheaders.append("#$ svn cp -r %d %s %s " |
| 830 "### WARNING: note non-trunk copy\n" % |
| 831 (rev, src, filename)) |
| 832 else: |
| 833 metaheaders.append("#$ cp %s %s\n" % (src, |
| 834 filename)) |
| 835 |
| 836 if metaheaders: |
| 837 diffs.append("### BEGIN SVN COPY METADATA\n") |
| 838 diffs.extend(metaheaders) |
| 839 diffs.append("### END SVN COPY METADATA\n") |
814 # Now ready to do the actual diff. | 840 # Now ready to do the actual diff. |
815 diffs = [] | |
816 for filename in sorted(data.iterkeys()): | 841 for filename in sorted(data.iterkeys()): |
817 diffs.append(SVN._DiffItemInternal(filename, data[filename], bogus_dir, | 842 diffs.append(SVN._DiffItemInternal(filename, data[filename], bogus_dir, |
818 full_move=full_move, | 843 full_move=full_move, |
819 revision=revision)) | 844 revision=revision)) |
820 # Use StringIO since it can be messy when diffing a directory move with | 845 # Use StringIO since it can be messy when diffing a directory move with |
821 # full_move=True. | 846 # full_move=True. |
822 buf = cStringIO.StringIO() | 847 buf = cStringIO.StringIO() |
823 for d in filter(None, diffs): | 848 for d in filter(None, diffs): |
824 buf.write(d) | 849 buf.write(d) |
825 result = buf.getvalue() | 850 result = buf.getvalue() |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
915 if not SVN.current_version: | 940 if not SVN.current_version: |
916 SVN.current_version = SVN.Capture(['--version']).split()[2] | 941 SVN.current_version = SVN.Capture(['--version']).split()[2] |
917 current_version_list = map(only_int, SVN.current_version.split('.')) | 942 current_version_list = map(only_int, SVN.current_version.split('.')) |
918 for min_ver in map(int, min_version.split('.')): | 943 for min_ver in map(int, min_version.split('.')): |
919 ver = current_version_list.pop(0) | 944 ver = current_version_list.pop(0) |
920 if ver < min_ver: | 945 if ver < min_ver: |
921 return (False, SVN.current_version) | 946 return (False, SVN.current_version) |
922 elif ver > min_ver: | 947 elif ver > min_ver: |
923 return (True, SVN.current_version) | 948 return (True, SVN.current_version) |
924 return (True, SVN.current_version) | 949 return (True, SVN.current_version) |
OLD | NEW |