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 27 matching lines...) Expand all Loading... | |
38 # we are calling it in a loop. Extract the data we want and put it back | 38 # we are calling it in a loop. Extract the data we want and put it back |
39 # into the list. | 39 # into the list. |
40 paths[i] = glob.glob(subpath + '*')[0][prev+1:len(subpath)] | 40 paths[i] = glob.glob(subpath + '*')[0][prev+1:len(subpath)] |
41 path = '\\'.join(paths) | 41 path = '\\'.join(paths) |
42 return path | 42 return path |
43 | 43 |
44 | 44 |
45 def GenFakeDiff(filename): | 45 def GenFakeDiff(filename): |
46 """Generates a fake diff from a file.""" | 46 """Generates a fake diff from a file.""" |
47 file_content = gclient_utils.FileRead(filename, 'rb').splitlines(True) | 47 file_content = gclient_utils.FileRead(filename, 'rb').splitlines(True) |
48 filename = filename.replace(os.sep, '/') | |
M-A Ruel
2010/06/03 00:02:17
I don't think this one is necessary but while at i
| |
48 nb_lines = len(file_content) | 49 nb_lines = len(file_content) |
49 # We need to use / since patch on unix will fail otherwise. | 50 # We need to use / since patch on unix will fail otherwise. |
50 data = cStringIO.StringIO() | 51 data = cStringIO.StringIO() |
51 data.write("Index: %s\n" % filename) | 52 data.write("Index: %s\n" % filename) |
52 data.write('=' * 67 + '\n') | 53 data.write('=' * 67 + '\n') |
53 # Note: Should we use /dev/null instead? | 54 # Note: Should we use /dev/null instead? |
54 data.write("--- %s\n" % filename) | 55 data.write("--- %s\n" % filename) |
55 data.write("+++ %s\n" % filename) | 56 data.write("+++ %s\n" % filename) |
56 data.write("@@ -0,0 +1,%d @@\n" % nb_lines) | 57 data.write("@@ -0,0 +1,%d @@\n" % nb_lines) |
57 # Prepend '+' to every lines. | 58 # Prepend '+' to every lines. |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
723 data.close() | 724 data.close() |
724 data = tmp | 725 data = tmp |
725 else: | 726 else: |
726 data = GenFakeDiff(filename) | 727 data = GenFakeDiff(filename) |
727 else: | 728 else: |
728 if info.get("Node Kind") != "directory": | 729 if info.get("Node Kind") != "directory": |
729 # svn diff on a mv/cp'd file outputs nothing if there was no change. | 730 # svn diff on a mv/cp'd file outputs nothing if there was no change. |
730 data = SVN.Capture(command, None) | 731 data = SVN.Capture(command, None) |
731 if not data: | 732 if not data: |
732 # We put in an empty Index entry so upload.py knows about them. | 733 # We put in an empty Index entry so upload.py knows about them. |
733 data = "Index: %s\n" % filename | 734 data = "Index: %s\n" % filename.replace(os.sep, '/') |
734 # Otherwise silently ignore directories. | 735 # Otherwise silently ignore directories. |
735 else: | 736 else: |
736 if info.get("Node Kind") != "directory": | 737 if info.get("Node Kind") != "directory": |
737 # Normal simple case. | 738 # Normal simple case. |
738 data = SVN.Capture(command, None) | 739 data = SVN.Capture(command, None) |
739 # Otherwise silently ignore directories. | 740 # Otherwise silently ignore directories. |
740 return data | 741 return data |
741 | 742 |
742 @staticmethod | 743 @staticmethod |
743 def GenerateDiff(filenames, root=None, full_move=False, revision=None): | 744 def GenerateDiff(filenames, root=None, full_move=False, revision=None): |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
884 if not SVN.current_version: | 885 if not SVN.current_version: |
885 SVN.current_version = SVN.Capture(['--version']).split()[2] | 886 SVN.current_version = SVN.Capture(['--version']).split()[2] |
886 current_version_list = map(only_int, SVN.current_version.split('.')) | 887 current_version_list = map(only_int, SVN.current_version.split('.')) |
887 for min_ver in map(int, min_version.split('.')): | 888 for min_ver in map(int, min_version.split('.')): |
888 ver = current_version_list.pop(0) | 889 ver = current_version_list.pop(0) |
889 if ver < min_ver: | 890 if ver < min_ver: |
890 return (False, SVN.current_version) | 891 return (False, SVN.current_version) |
891 elif ver > min_ver: | 892 elif ver > min_ver: |
892 return (True, SVN.current_version) | 893 return (True, SVN.current_version) |
893 return (True, SVN.current_version) | 894 return (True, SVN.current_version) |
OLD | NEW |